client-cpp  0.6.3
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 
24 #include "kaa/KaaThread.hpp"
28 
29 namespace kaa {
30 
31 class IKaaClientStateStorage;
32 
43 class ConfigurationPersistenceManager : public IConfigurationPersistenceManager {
44 public:
45  ConfigurationPersistenceManager(IKaaClientStateStoragePtr state)
46  : storage_(nullptr)
47  , processor_(nullptr)
48  , ignoreConfigurationUpdate_(false)
49  , state_(state)
50  {}
51  ~ConfigurationPersistenceManager() {}
52 
56  void setConfigurationStorage(IConfigurationStorage *storage);
57 
61  void onConfigurationUpdated(const ICommonRecord &configuration);
62 
66  void onSchemaUpdated(std::shared_ptr<avro::ValidSchema> schema);
67 
71  EndpointObjectHash getConfigurationHash();
72 
79  void setConfigurationProcessor(IConfigurationProcessor *processor);
80 private:
81  void readStoredConfiguration();
82 
83  KAA_MUTEX_DECLARE(schemaGuard_);
84  KAA_MUTEX_DECLARE(confPersistenceGuard_);
85 
86  IConfigurationStorage * storage_;
87  IConfigurationProcessor * processor_;
88 
89  std::shared_ptr<avro::ValidSchema> schema_;
90  EndpointObjectHash configurationHash_;
91  bool ignoreConfigurationUpdate_;
92 
94 };
95 
96 } // namespace kaa
97 
98 #endif
99 
100 #endif /* CONFIGURATIONPERSISTENCEMANAGER_HPP_ */
#define KAA_MUTEX_DECLARE(name)
Definition: KaaThread.hpp:71
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr