Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 1 | // Copyright (c) 2014 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 5 | #ifndef SHILL_SERVICE_PROPERTY_CHANGE_NOTIFIER_H_ |
| 6 | #define SHILL_SERVICE_PROPERTY_CHANGE_NOTIFIER_H_ |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 7 | |
Ben Chan | cd47732 | 2014-10-17 14:19:30 -0700 | [diff] [blame^] | 8 | #include <memory> |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 12 | #include <base/callback.h> |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 13 | #include <base/macros.h> |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 14 | |
| 15 | #include "shill/accessor_interface.h" |
| 16 | |
| 17 | namespace shill { |
| 18 | |
| 19 | class PropertyObserverInterface; |
| 20 | class ServiceAdaptorInterface; |
| 21 | |
| 22 | // A collection of property observers used by objects to deliver |
| 23 | // property change notifications. This object holds an un-owned |
| 24 | // pointer to the ServiceAdaptor to which notifications should be |
| 25 | // posted. This pointer must be valid for the lifetime of this |
| 26 | // property change notifier. |
| 27 | class ServicePropertyChangeNotifier { |
| 28 | public: |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 29 | explicit ServicePropertyChangeNotifier(ServiceAdaptorInterface *adaptor); |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 30 | virtual ~ServicePropertyChangeNotifier(); |
| 31 | |
| 32 | virtual void AddBoolPropertyObserver(const std::string &name, |
| 33 | BoolAccessor accessor); |
| 34 | virtual void AddUint8PropertyObserver(const std::string &name, |
| 35 | Uint8Accessor accessor); |
| 36 | virtual void AddUint16PropertyObserver(const std::string &name, |
| 37 | Uint16Accessor accessor); |
| 38 | virtual void AddUint16sPropertyObserver(const std::string &name, |
| 39 | Uint16sAccessor accessor); |
| 40 | virtual void AddUintPropertyObserver(const std::string &name, |
| 41 | Uint32Accessor accessor); |
| 42 | virtual void AddIntPropertyObserver(const std::string &name, |
| 43 | Int32Accessor accessor); |
| 44 | virtual void AddRpcIdentifierPropertyObserver(const std::string &name, |
| 45 | RpcIdentifierAccessor accessor); |
| 46 | virtual void AddStringPropertyObserver(const std::string &name, |
| 47 | StringAccessor accessor); |
| 48 | virtual void AddStringmapPropertyObserver(const std::string &name, |
| 49 | StringmapAccessor accessor); |
| 50 | virtual void UpdatePropertyObservers(); |
| 51 | |
| 52 | private: |
| 53 | // Redirects templated calls to a value reference to a by-copy version. |
| 54 | void BoolPropertyUpdater(const std::string &name, const bool &value); |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 55 | void Uint8PropertyUpdater(const std::string &name, const uint8_t &value); |
| 56 | void Uint16PropertyUpdater(const std::string &name, const uint16_t &value); |
| 57 | void Uint32PropertyUpdater(const std::string &name, const uint32_t &value); |
| 58 | void Int32PropertyUpdater(const std::string &name, const int32_t &value); |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 59 | |
| 60 | ServiceAdaptorInterface *rpc_adaptor_; |
Ben Chan | cd47732 | 2014-10-17 14:19:30 -0700 | [diff] [blame^] | 61 | std::vector<std::unique_ptr<PropertyObserverInterface>> property_observers_; |
Paul Stewart | 0153cf0 | 2014-06-02 11:53:36 -0700 | [diff] [blame] | 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(ServicePropertyChangeNotifier); |
| 64 | }; |
| 65 | |
| 66 | } // namespace shill |
| 67 | |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 68 | #endif // SHILL_SERVICE_PROPERTY_CHANGE_NOTIFIER_H_ |