hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DRCEResourceUsage.hpp
Go to the documentation of this file.
1 
14 #ifndef DRCE_RESOURCE_USAGE_HPP
15 #define DRCE_RESOURCE_USAGE_HPP
16 
17 #include <utility>
18 #include <stddef.h>
19 
20 #include "JsonSerializable.hpp"
21 
22 namespace HCE
23 {
24 namespace drce
25 {
26 //-----------------------------------------------------------------------------
28 {
29  ResourceUsage(void);
30  ResourceUsage(const ResourceUsage& rhs);
32 
35 
36  void clear(void);
37 
38  double cpu;
39  double iowait;
40 
41  size_t vramUsed;
43  size_t rramUsed;
45  size_t diskUsed;
47 
48  unsigned int processes;
50  unsigned int threads;
52 
53  double loadAverage;
54 };
55 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
58 {
59  static const char DELIMITER = ',';
60 public:
62  explicit ResourceUsageConverter(const ResourceUsage& rhs);
63  explicit ResourceUsageConverter(const std::string& rhs);
64 
65  ResourceUsage toObject(void) const {return resourceUsage;}
66  std::string toString(const char delimiter=DELIMITER);
67 
68  void fromObject(const ResourceUsage& rhs);
69  void fromString(const std::string& rhs, const char delimiter=DELIMITER);
70 private:
71  ResourceUsage resourceUsage;
72 };
73 //-----------------------------------------------------------------------------
74 //-----------------------------------------------------------------------------
76 {
77 public:
78  explicit ResourceUsageSerializator(ResourceUsage& resourceUsage_);
79  ResourceUsageSerializator(ResourceUsage& resourceUsage_, const std::string& json);
80 
81  bool serialize(std::string& json);
82  bool unserialize(const std::string& json);
83 
84  void clear(void);
85 private:
86  ResourceUsage& resourceUsage;
88 };
89 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
91 } // end namespace drce
92 } // end namespace HCE
93 
94 #endif // DRCE_RESOURCE_USAGE_HPP