client-cpp  0.0.1-SNAPSHOT
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 
21 
22 #include <boost/thread/mutex.hpp>
23 #include <boost/smart_ptr/shared_ptr.hpp>
24 #include <boost/signals2.hpp>
25 
26 namespace kaa {
27 
40 public:
43 
50 
54  void onDeltaRecevied(int index, const avro::GenericDatum & data, bool full_resync);
55 
60 
61 private:
68  void updateRecord(boost::shared_ptr<ICommonRecord> rec, const avro::GenericDatum &data);
69 
75  bool isSubscribed(uuid_t uuid);
76 
83  void subscribe(uuid_t uuid, boost::shared_ptr<ICommonRecord> record);
84 
90  void unsubscribe(uuid_t uuid);
91 
92  typedef boost::mutex mutex_type;
93  typedef boost::unique_lock<mutex_type> lock_type;
94 
95  std::map<uuid_t, boost::shared_ptr<ICommonRecord> > records_;
96  boost::shared_ptr<ICommonRecord> root_;
97 
98  mutex_type configurationGuard_;
99  boost::signals2::signal<void (ICommonRecord &)> configurationReceivers_;
100 };
101 
102 } // namespace kaa
103 
104 
105 #endif /* CONFIGURATION_MANAGER_HPP_ */
boost::uuids::uuid uuid_t
void subscribeForConfigurationChanges(IConfigurationReceiver &receiver)
void unsubscribeFromConfigurationChanges(IConfigurationReceiver &receiver)
void onDeltaRecevied(int index, const avro::GenericDatum &data, bool full_resync)
ICommonRecord & getConfiguration()