PolicyManager: Add a generic copy variable.
This patch includes a generic class of Variable that creates copies
of a referenced object using the copy constructor. A provider that
needs to return the value of fixed object like a private member can
simply use this generic CopyVariable class.
BUG=None
TEST=unittest
Change-Id: I4e7703c0d25990f42c9c83228ba177baffadc194
Reviewed-on: https://chromium-review.googlesource.com/181963
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/generic_variables-inl.h b/policy_manager/generic_variables-inl.h
new file mode 100644
index 0000000..f44a287
--- /dev/null
+++ b/policy_manager/generic_variables-inl.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_GENERIC_VARIABLES_INL_H
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_GENERIC_VARIABLES_INL_H
+
+namespace chromeos_policy_manager {
+
+template<typename T>
+CopyVariable<T>::CopyVariable(const T& ref) : ref_(ref) {}
+
+template<typename T>
+const T* CopyVariable<T>::GetValue(base::TimeDelta /* timeout */,
+ std::string* /* errmsg */) {
+ return new T(ref_);
+};
+
+} // namespace chromeos_policy_manager
+
+#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_GENERIC_VARIABLES_INL_H