hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AdminClientsSerializator.hpp
Go to the documentation of this file.
1 
14 #ifndef ADMIN_CLIENTS_SERIALIZATOR_HPP
15 #define ADMIN_CLIENTS_SERIALIZATOR_HPP
16 
17 #include "JsonSerializable.hpp"
18 #include "ClientWorkerItem.hpp"
19 
20 namespace HCE
21 {
22 namespace handlers
23 {
24 //-----------------------------------------------------------------------------
26 {
27  // json route message names
28  const std::string PURGE_COUNTER = "purgeCounter";
29  const std::string REFRESH_NOT_FOUND_COUNTER = "refreshNotFoundCounter";
30  const std::string CLIENTS_COUNT = "clientsCount";
31  const std::string CLIENTS = "clients";
32  const std::string IDENTITY = "identity";
33  const std::string COUNT = "count";
34  const std::string FREQUENCY = "frequency";
35  const std::string EXPIRY = "expiry";
36  const std::string CPU = "cpu";
37  const std::string IOWAIT = "iowait";
38 public:
40  {
44  };
45 public:
46  explicit AdminClientsSerializator(std::vector<ClientWorkerItem>& clients_);
47  AdminClientsSerializator(std::vector<ClientWorkerItem>& clients_, unsigned long long purgeCounter_, unsigned long long refreshNotFoundCounter_);
49 
50  bool serialize(std::string& json);
51  bool unserialize(const std::string& json);
52 
53  void clear(void);
54 
55  void setPurgeCounter(unsigned long long purgeCounter_) {purgeCounter=purgeCounter_;}
56  unsigned long long getPurgeCounter(void) const {return purgeCounter;}
57 
58  void setRefreshNotFoundCounter(unsigned long long refreshNotFoundCounter_) {refreshNotFoundCounter=refreshNotFoundCounter_;}
59  unsigned long long getRefreshNotFoundCounter(void) const {return refreshNotFoundCounter;}
60 
61  size_t getClientsCount(void) const {return clients.size();}
62 private:
63  std::vector<ClientWorkerItem>& clients;
64  unsigned long long purgeCounter;
65  unsigned long long refreshNotFoundCounter;
66 
67  typedef IJsonSerializable inherited;
68 };
69 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
71 } // end namespace handlers
72 } // end namespace HCE
73 
74 #endif // ADMIN_CLIENTS_SERIALIZATOR_HPP