[shill] Use composition instead of inheritance with PropertyStore
Instead of having Device, Manager, etc all inherit from PropertyStore
and have it be difficult to follow the getting/setting property code,
have each include a PropertyStore as a data member. Provide an
accessor so that RPC adaptor classes can get and set properties
directly and continue to handle any necessary type conversion
themselves.
BUG=None
TEST=unit tests
Change-Id: I34781bde4de0e152550ca636e28d472abde756af
Reviewed-on: http://gerrit.chromium.org/gerrit/3616
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
diff --git a/manager.h b/manager.h
index d92f27b..abbf904 100644
--- a/manager.h
+++ b/manager.h
@@ -24,7 +24,7 @@
class EventDispatcher;
class ManagerAdaptorInterface;
-class Manager : public PropertyStore {
+class Manager {
public:
// A constructor for the Manager object
Manager(ControlInterface *control_interface,
@@ -44,21 +44,7 @@
ServiceRefPtr FindService(const std::string& name);
- // Implementation of PropertyStore
- virtual bool SetBoolProperty(const std::string &name,
- bool value,
- Error *error);
- virtual bool SetStringProperty(const std::string &name,
- const std::string &value,
- Error *error);
-
- protected:
- void RegisterDerivedString(const std::string &name,
- std::string(Manager::*get)(void),
- bool(Manager::*set)(const std::string&));
- void RegisterDerivedStrings(const std::string &name,
- Strings(Manager::*get)(void),
- bool(Manager::*set)(const Strings&));
+ PropertyStore *store() { return &store_; }
private:
std::string CalculateState();
@@ -72,6 +58,13 @@
std::vector<std::string> EnumerateAvailableServices();
std::vector<std::string> EnumerateWatchedServices();
+ void HelpRegisterDerivedString(const std::string &name,
+ std::string(Manager::*get)(void),
+ bool(Manager::*set)(const std::string&));
+ void HelpRegisterDerivedStrings(const std::string &name,
+ Strings(Manager::*get)(void),
+ bool(Manager::*set)(const Strings&));
+
scoped_ptr<ManagerAdaptorInterface> adaptor_;
DeviceInfo device_info_;
bool running_;
@@ -85,6 +78,8 @@
std::string country_;
std::string portal_url_;
+ PropertyStore store_;
+
std::string active_profile_; // This is supposed to be, essentially,
// an RPC-visible object handle