client-cpp  0.0.1-SNAPSHOT
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 <boost/cstdint.hpp>
23 #include <boost/bimap.hpp>
24 #include <boost/thread/mutex.hpp>
25 
26 #include "kaa/gen/EndpointGen.hpp"
29 
30 namespace kaa {
31 
32 /* Fwd declarations */
33 enum class ClientParameterT;
34 class IPersistentParameter;
35 
36 typedef boost::bimaps::bimap<
37  boost::bimaps::set_of<ClientParameterT> /* Client parameter type */
38  , boost::bimaps::set_of<std::string> /* String token for mapping in status file */
39  , boost::bimaps::left_based
40 > bimap;
41 
43 public:
44  ClientStatus(const std::string& filename);
46 
47  boost::int32_t getEventSequenceNumber() const;
48  void setEventSequenceNumber(boost::int32_t sequenceNumber);
49 
50  boost::int32_t getConfigurationSequenceNumber() const;
51  void setConfigurationSequenceNumber(boost::int32_t sequenceNumber);
52 
53  boost::int32_t getNotificationSequenceNumber() const;
54  void setNotificationSequenceNumber(boost::int32_t sequenceNumber);
55 
57  void setAppSeqNumber(SequenceNumber appSeqNumber);
58 
59  bool isRegistered() const;
60  void setRegistered(bool isRegistered);
61 
63  void setTopicStates(const DetailedTopicStates& stateContainer);
64 
67 
69  void setAttachedEndpoints(const AttachedEndpoints& endpoints);
70 
71  std::string getEndpointAccessToken() const;
72  void setEndpointAccessToken(const std::string& token);
73 
74  bool getEndpointAttachStatus() const;
75  void setEndpointAttachStatus(bool isAttached);
76 
77  std::string getEndpointKeyHash() const;
78  void setEndpointKeyHash(const std::string& keyHash);
79 
80  void read();
81  void save();
82 
83 private:
84  typedef boost::mutex mutex_type;
85  typedef boost::unique_lock<mutex_type> lock_type;
86 
87  std::string filename_;
88  std::map<ClientParameterT, boost::shared_ptr<IPersistentParameter> > parameters_;
89 
90  mutable mutex_type sequenceNumberGuard_;
91 
92  static const bimap parameterToToken_;
93  static const SequenceNumber appSeqNumberDefault_;
94  static const bool isRegisteredDefault_;
95  static const SharedDataBuffer endpointHashDefault_;
96  static const DetailedTopicStates topicStatesDefault_;
97  static const AttachedEndpoints attachedEndpoints_;
98  static const std::string endpointAccessToken_;
99  static const bool endpointDefaultAttachStatus_;
100  static const std::string endpointKeyHashDefault_;
101 };
102 
103 }
104 
105 
106 #endif /* CLIENTSTATUS_HPP_ */
void setAttachedEndpoints(const AttachedEndpoints &endpoints)
std::map< std::string, std::string > AttachedEndpoints
std::string getEndpointKeyHash() const
void setEndpointAccessToken(const std::string &token)
void setConfigurationSequenceNumber(boost::int32_t sequenceNumber)
std::string getEndpointAccessToken() const
ClientStatus(const std::string &filename)
void setEventSequenceNumber(boost::int32_t sequenceNumber)
SharedDataBuffer getProfileHash() 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
boost::int32_t getConfigurationSequenceNumber() const
boost::int32_t getNotificationSequenceNumber() const
std::pair< boost::shared_array< boost::uint8_t >, boost::uint32_t > SharedDataBuffer
boost::int32_t getEventSequenceNumber() const
void setEndpointAttachStatus(bool isAttached)
void setAppSeqNumber(SequenceNumber appSeqNumber)
void setNotificationSequenceNumber(boost::int32_t sequenceNumber)
bool isRegistered() const
void setEndpointKeyHash(const std::string &keyHash)
AttachedEndpoints getAttachedEndpoints() const
DetailedTopicStates getTopicStates() const
void setRegistered(bool isRegistered)
std::map< std::string, DetailedTopicState > DetailedTopicStates
bool getEndpointAttachStatus() const
void setProfileHash(SharedDataBuffer hash)