client-cpp  0.6.1
ConfigurationPersistenceManager.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 CONFIGURATIONPERSISTENCEMANAGER_HPP_
18 #define CONFIGURATIONPERSISTENCEMANAGER_HPP_
19 
20 #include "kaa/KaaDefaults.hpp"
21 
22 #ifdef KAA_USE_CONFIGURATION
23 
25 #include "kaa/KaaThread.hpp"
27 
28 namespace kaa {
29 
40 class ConfigurationPersistenceManager : public IConfigurationPersistenceManager {
41 public:
42  ConfigurationPersistenceManager()
43  : storage_(nullptr)
44  , processor_(nullptr)
45  , ignoreConfigurationUpdate_(false)
46  {}
47  ~ConfigurationPersistenceManager() {}
48 
52  void setConfigurationStorage(IConfigurationStorage *storage);
53 
57  void onConfigurationUpdated(const ICommonRecord &configuration);
58 
62  void onSchemaUpdated(std::shared_ptr<avro::ValidSchema> schema);
63 
67  EndpointObjectHash getConfigurationHash();
68 
75  void setConfigurationProcessor(IConfigurationProcessor *processor);
76 private:
77  void readStoredConfiguration();
78 
79  KAA_MUTEX_DECLARE(schemaGuard_);
80  KAA_MUTEX_DECLARE(confPersistenceGuard_);
81 
82  IConfigurationStorage * storage_;
83  IConfigurationProcessor * processor_;
84 
85  std::shared_ptr<avro::ValidSchema> schema_;
86  EndpointObjectHash configurationHash_;
87  bool ignoreConfigurationUpdate_;
88 };
89 
90 } // namespace kaa
91 
92 #endif
93 
94 #endif /* CONFIGURATIONPERSISTENCEMANAGER_HPP_ */
#define KAA_MUTEX_DECLARE(name)
Definition: KaaThread.hpp:71