client-cpp  0.6.1
ConfigurationManager.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CONFIGURATION_MANAGER_HPP_
18 #define CONFIGURATION_MANAGER_HPP_
19 
20 #include "kaa/KaaDefaults.hpp"
21 
22 #ifdef KAA_USE_CONFIGURATION
23 
26 
27 #include <memory>
28 
29 namespace kaa {
30 
42 class ConfigurationManager : public IConfigurationManager {
43 public:
44  ConfigurationManager() {}
45  ~ConfigurationManager() {}
46 
50  void subscribeForConfigurationChanges(IConfigurationReceiver &receiver);
51  void unsubscribeFromConfigurationChanges(IConfigurationReceiver &receiver);
52  ICommonRecord &getConfiguration();
53 
57  void onDeltaRecevied(int index, const avro::GenericDatum & data, bool full_resync);
58 
62  void onConfigurationProcessed();
63 
64 private:
71  void updateRecord(std::shared_ptr<ICommonRecord> rec, const avro::GenericDatum &data);
72 
78  bool isSubscribed(uuid_t uuid);
79 
86  void subscribe(uuid_t uuid, std::shared_ptr<ICommonRecord> record);
87 
93  void unsubscribe(uuid_t uuid);
94 
95  std::map<uuid_t, std::shared_ptr<ICommonRecord> > records_;
96  std::shared_ptr<ICommonRecord> root_;
97 
98  KAA_MUTEX_DECLARE(configurationGuard_);
99  KaaObservable<void (ICommonRecord &), IConfigurationReceiver *> configurationReceivers_;
100 };
101 
102 } // namespace kaa
103 
104 #endif
105 
106 #endif /* CONFIGURATION_MANAGER_HPP_ */
#define KAA_MUTEX_DECLARE(name)
Definition: KaaThread.hpp:71