client-cpp  0.9.0
ConfigurationManager.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 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 
26 #include "kaa/configuration/gen/ConfigurationDefinitions.hpp"
28 
29 namespace kaa {
30 
31 class IExecutorContext;
32 class IConfigurationReceiver;
33 
45 public:
47 
48  virtual void init();
49 
50  virtual void processConfigurationData(const std::vector<std::uint8_t>& data, bool fullResync);
51 
52  virtual void addReceiver(IConfigurationReceiver &receiver);
53  virtual void removeReceiver(IConfigurationReceiver &receiver);
54  virtual const KaaRootConfiguration& getConfiguration();
55 
57 
59  {
60  return *this;
61  }
62 
64  {
65  return *this;
66  }
67 
69  {
70  return configurationHash_;
71  }
72 
73 private:
74  void updateConfiguration(const std::uint8_t* data, const std::uint32_t dataSize);
75  void loadConfiguration();
76  void notifySubscribers(const KaaRootConfiguration& configuration);
77 
78 private:
79  bool isConfigurationLoaded_;
80 
81  IKaaClientContext &context_;
82  KaaRootConfiguration configuration_;
83 
84  IConfigurationStoragePtr storage_;
85  EndpointObjectHash configurationHash_;
86 
87  KAA_MUTEX_DECLARE(configurationGuard_);
89 };
90 
91 } // namespace kaa
92 
93 #endif /* CONFIGURATION_MANAGER_HPP_ */
virtual IConfigurationProcessor & getConfigurationProcessor()
ConfigurationManager(IKaaClientContext &context)
virtual void addReceiver(IConfigurationReceiver &receiver)
virtual void processConfigurationData(const std::vector< std::uint8_t > &data, bool fullResync)
virtual EndpointObjectHash getConfigurationHash()
virtual void removeReceiver(IConfigurationReceiver &receiver)
virtual void setConfigurationStorage(IConfigurationStoragePtr storage)
std::shared_ptr< IConfigurationStorage > IConfigurationStoragePtr
virtual IConfigurationHashContainer & getConfigurationHashContainer()
virtual const KaaRootConfiguration & getConfiguration()