client-cpp  0.7.0
ClientStatus.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 CLIENTSTATUS_HPP_
18 #define CLIENTSTATUS_HPP_
19 
20 #include <string>
21 #include <map>
22 #include <cstdint>
23 #include <memory>
24 #include <boost/bimap.hpp>
25 
26 #include "kaa/KaaThread.hpp"
27 #include "kaa/gen/EndpointGen.hpp"
30 
31 namespace kaa {
32 
33 /* Fwd declarations */
34 enum class ClientParameterT;
35 class IPersistentParameter;
36 
37 typedef boost::bimaps::bimap<
38  boost::bimaps::set_of<ClientParameterT> /* Client parameter type */
39  , boost::bimaps::set_of<std::string> /* String token for mapping in status file */
40  , boost::bimaps::left_based
41 > bimap;
42 
44 public:
45  ClientStatus(const std::string& filename);
47 
48  std::int32_t getEventSequenceNumber() const;
49  void setEventSequenceNumber(std::int32_t sequenceNumber);
50 
51  std::int32_t getConfigurationSequenceNumber() const;
52  void setConfigurationSequenceNumber(std::int32_t sequenceNumber);
53 
54  std::int32_t getNotificationSequenceNumber() const;
55  void setNotificationSequenceNumber(std::int32_t sequenceNumber);
56 
58  void setAppSeqNumber(SequenceNumber appSeqNumber);
59 
60  bool isRegistered() const;
61  void setRegistered(bool isRegistered);
62 
64  void setTopicStates(const DetailedTopicStates& stateContainer);
65 
66  HashDigest getProfileHash() const;
67  void setProfileHash(HashDigest hash);
68 
70  void setAttachedEndpoints(const AttachedEndpoints& endpoints);
71 
72  std::string getEndpointAccessToken();
73  void setEndpointAccessToken(const std::string& token);
74  std::string refreshEndpointAccessToken();
75 
76  bool getEndpointAttachStatus() const;
77  void setEndpointAttachStatus(bool isAttached);
78 
79  std::string getEndpointKeyHash() const;
80  void setEndpointKeyHash(const std::string& keyHash);
81 
82  virtual bool isConfigurationVersionUpdated() const { return isConfigVersionUpdated; }
83 
84  void read();
85  void save();
86 
87 private:
88  void checkSDKPropertiesForUpdates();
89  void checkConfigVersionForUpdates();
90 
91 private:
92  std::string filename_;
93  std::map<ClientParameterT, std::shared_ptr<IPersistentParameter> > parameters_;
94 
95  bool isConfigVersionUpdated;
96 
97  KAA_MUTEX_MUTABLE_DECLARE(sequenceNumberGuard_);
98 
99  static const bimap parameterToToken_;
100  static const SequenceNumber appSeqNumberDefault_;
101  static const bool isRegisteredDefault_;
102  static const HashDigest endpointHashDefault_;
103  static const DetailedTopicStates topicStatesDefault_;
104  static const AttachedEndpoints attachedEndpoints_;
105  static const bool endpointDefaultAttachStatus_;
106  static const std::string endpointKeyHashDefault_;
107 };
108 
109 }
110 
111 
112 #endif /* CLIENTSTATUS_HPP_ */
std::string getEndpointAccessToken()
void setAttachedEndpoints(const AttachedEndpoints &endpoints)
void setProfileHash(HashDigest hash)
std::string getEndpointKeyHash() const
std::int32_t getConfigurationSequenceNumber() const
void setEndpointAccessToken(const std::string &token)
ClientStatus(const std::string &filename)
std::int32_t getEventSequenceNumber() const
void setNotificationSequenceNumber(std::int32_t sequenceNumber)
void setConfigurationSequenceNumber(std::int32_t sequenceNumber)
virtual bool isConfigurationVersionUpdated() const
void setTopicStates(const DetailedTopicStates &stateContainer)
SequenceNumber getAppSeqNumber() const
boost::bimaps::bimap< boost::bimaps::set_of< ClientParameterT >, boost::bimaps::set_of< std::string >, boost::bimaps::left_based > bimap
std::map< std::string, std::string > AttachedEndpoints
std::vector< std::uint8_t > HashDigest
void setEndpointAttachStatus(bool isAttached)
void setAppSeqNumber(SequenceNumber appSeqNumber)
bool isRegistered() const
void setEndpointKeyHash(const std::string &keyHash)
void setEventSequenceNumber(std::int32_t sequenceNumber)
AttachedEndpoints getAttachedEndpoints() const
DetailedTopicStates getTopicStates() const
void setRegistered(bool isRegistered)
std::map< std::string, DetailedTopicState > DetailedTopicStates
HashDigest getProfileHash() const
std::string refreshEndpointAccessToken()
std::int32_t getNotificationSequenceNumber() const
bool getEndpointAttachStatus() const