PolicyManager: Add an base Variable class without type.
The Variable<T> is a parametric type that requires to know the type T
of the exported variable. This new BaseVariable class isn't
parametric and allows to keep a list of variable pointers on the
EvaluationContext to cache their provided results and dump the names
of those variables.
BUG=chromium:338590
TEST=unittest passes.
Change-Id: I1677e3975d44575ed12f35c36381101d4379c5fc
Reviewed-on: https://chromium-review.googlesource.com/184428
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/variable.h b/policy_manager/variable.h
index 22039c0..9b933d7 100644
--- a/policy_manager/variable.h
+++ b/policy_manager/variable.h
@@ -12,11 +12,30 @@
namespace chromeos_policy_manager {
-// Interface to a Policy Manager variable. Implementation internals are hidden
-// as protected members, since policies should not be using them directly.
-template<typename T>
-class Variable {
+// This class is a base class with the common functionality that doesn't
+// deppend on the variable's type, implemented by all the variables.
+class BaseVariable {
public:
+ BaseVariable(const std::string& name) : name_(name) {}
+ virtual ~BaseVariable() {}
+
+ // Returns the variable name as a string.
+ virtual const std::string& GetName() {
+ return name_;
+ }
+
+ private:
+ // The variable's name as a string.
+ const std::string name_;
+};
+
+// Interface to a Policy Manager variable of a given type. Implementation
+// internals are hidden as protected members, since policies should not be
+// using them directly.
+template<typename T>
+class Variable : public BaseVariable {
+ public:
+ Variable(const std::string& name) : BaseVariable(name) {}
virtual ~Variable() {}
protected: