hce-node application
1.4.3
HCE Hierarchical Cluster Engine node application
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
DRCEStatVariablesConverter.cpp
Go to the documentation of this file.
1
#include "
DRCEStatVariablesConverter.hpp
"
2
#include "
DRCEJsonMessageConst.hpp
"
3
4
namespace
HCE
5
{
6
namespace
drce
7
{
8
//-----------------------------------------------------------------------------
9
StatVariablesConverter::StatVariablesConverter
(
void
)
10
: statVariables()
11
{
12
}
13
//-----------------------------------------------------------------------------
14
StatVariablesConverter::StatVariablesConverter
(
const
StatVariables
& rhs)
15
: statVariables(rhs)
16
{
17
}
18
//-----------------------------------------------------------------------------
19
StatVariablesConverter::StatVariablesConverter
(
const
Dictionary
& rhs)
20
: statVariables()
21
{
22
fromDictionary
(rhs);
23
}
24
//-----------------------------------------------------------------------------
25
template
<
typename
T>
void
StatVariablesConverter::toDictionary
(
const
std::string&
key
,
const
StatVariableData<T>
&
data
, Dictionary& dic)
26
{
27
dic[key+
HCE::drce::drce_json_message_const::STAT_DELIMITER
+
HCE::drce::drce_json_message_const::MIN
] = data.
min
;
28
dic[key+
HCE::drce::drce_json_message_const::STAT_DELIMITER
+
HCE::drce::drce_json_message_const::AVG
] = data.
avg
;
29
dic[key+
HCE::drce::drce_json_message_const::STAT_DELIMITER
+
HCE::drce::drce_json_message_const::MAX
] = data.
max
;
30
}
31
//-----------------------------------------------------------------------------
32
template
<
typename
T>
void
StatVariablesConverter::fromDictionary
(
const
std::string&
key
, StatVariableData<T>&
data
,
const
Dictionary& dic)
33
{
34
Dictionary
dictionary(dic);
35
Poco::Dynamic::Var tmp = dictionary[key+
HCE::drce::drce_json_message_const::STAT_DELIMITER
+
HCE::drce::drce_json_message_const::MIN
];
36
if
(tmp.isNumeric())
37
data.min = tmp.convert<T>();
38
39
tmp = dictionary[key+
HCE::drce::drce_json_message_const::STAT_DELIMITER
+
HCE::drce::drce_json_message_const::AVG
];
40
if
(tmp.isNumeric())
41
data.avg = tmp.convert<T>();
42
43
tmp = dictionary[key+
HCE::drce::drce_json_message_const::STAT_DELIMITER
+
HCE::drce::drce_json_message_const::MAX
];
44
if
(tmp.isNumeric())
45
data.max = tmp.convert<T>();
46
}
47
//-----------------------------------------------------------------------------
48
void
StatVariablesConverter::toDictionary
(
const
std::string& key,
const
size_t
& value, Dictionary& dic)
49
{
50
dic[
key
] = value;
51
}
52
//-----------------------------------------------------------------------------
53
void
StatVariablesConverter::fromDictionary
(
const
std::string& key,
size_t
& value,
const
Dictionary& dic)
54
{
55
Dictionary
dictionary(dic);
56
Poco::Dynamic::Var tmp = dictionary[
key
];
57
if
(tmp.isInteger())
58
value = tmp.convert<
size_t
>();
59
}
60
//-----------------------------------------------------------------------------
61
StatVariablesConverter::Dictionary
StatVariablesConverter::toDictionary
(
void
)
62
{
63
Dictionary
dictionary;
64
toDictionary
(
HCE::drce::drce_json_message_const::TIME_ASYNC_TASK
, statVariables.
timeAsyncTask
, dictionary);
65
toDictionary
(
HCE::drce::drce_json_message_const::TIME_SYNC_TASK
, statVariables.
timeSyncTask
, dictionary);
66
toDictionary
(
HCE::drce::drce_json_message_const::SIZE_INPUT_BUFFER_SYNC_TASKS
, statVariables.
sizeInputBufferSyncTasks
, dictionary);
67
toDictionary
(
HCE::drce::drce_json_message_const::SIZE_OUTPUT_BUFFER_SYNC_TASKS
, statVariables.
sizeOutputBufferSyncTasks
, dictionary);
68
toDictionary
(
HCE::drce::drce_json_message_const::SIZE_INPUT_BUFFER_ASYNC_TASKS
, statVariables.
sizeInputBufferAsyncTasks
, dictionary);
69
toDictionary
(
HCE::drce::drce_json_message_const::SIZE_OUTPUT_BUFFER_ASYNC_TASKS
, statVariables.
sizeOutputBufferAsyncTasks
, dictionary);
70
toDictionary
(
HCE::drce::drce_json_message_const::CPU_USAGE_ASYNC_TASKS
, statVariables.
cpuUsageAsyncTasks
, dictionary);
71
toDictionary
(
HCE::drce::drce_json_message_const::MEMORY_USAGE_ASYNC_TASKS
, statVariables.
memoryUsageAsyncTasks
, dictionary);
72
toDictionary
(
HCE::drce::drce_json_message_const::COUNT_SYNC_TASKS_FOR_MINUTE
, statVariables.
countSyncTasksForMinute
, dictionary);
73
toDictionary
(
HCE::drce::drce_json_message_const::COUNT_ASYNC_TASKS_FOR_MINUTE
, statVariables.
countAsyncTasksForMinute
, dictionary);
74
toDictionary
(
HCE::drce::drce_json_message_const::COUNT_SYNC_TASKS
, statVariables.
countSyncTasks
, dictionary);
75
toDictionary
(
HCE::drce::drce_json_message_const::COUNT_ASYNC_TASKS
, statVariables.
countAsyncTasks
, dictionary);
76
toDictionary
(
HCE::drce::drce_json_message_const::COUNT_SYNC_TASKS_FAIL
, statVariables.
countSyncTasksFail
, dictionary);
77
toDictionary
(
HCE::drce::drce_json_message_const::COUNT_ASYNC_TASKS_FAIL
, statVariables.
countAsyncTasksFail
, dictionary);
78
79
return
dictionary;
80
}
81
//-----------------------------------------------------------------------------
82
void
StatVariablesConverter::fromObject
(
const
StatVariables
& rhs)
83
{
84
statVariables = rhs;
85
}
86
//-----------------------------------------------------------------------------
87
void
StatVariablesConverter::fromDictionary
(
const
Dictionary
& rhs)
88
{
89
fromDictionary
(
HCE::drce::drce_json_message_const::TIME_ASYNC_TASK
, statVariables.
timeAsyncTask
, rhs);
90
fromDictionary
(
HCE::drce::drce_json_message_const::TIME_SYNC_TASK
, statVariables.
timeSyncTask
, rhs);
91
fromDictionary
(
HCE::drce::drce_json_message_const::SIZE_INPUT_BUFFER_SYNC_TASKS
, statVariables.
sizeInputBufferSyncTasks
, rhs);
92
fromDictionary
(
HCE::drce::drce_json_message_const::SIZE_OUTPUT_BUFFER_SYNC_TASKS
, statVariables.
sizeOutputBufferSyncTasks
, rhs);
93
fromDictionary
(
HCE::drce::drce_json_message_const::SIZE_INPUT_BUFFER_ASYNC_TASKS
, statVariables.
sizeInputBufferAsyncTasks
, rhs);
94
fromDictionary
(
HCE::drce::drce_json_message_const::SIZE_OUTPUT_BUFFER_ASYNC_TASKS
, statVariables.
sizeOutputBufferAsyncTasks
, rhs);
95
fromDictionary
(
HCE::drce::drce_json_message_const::CPU_USAGE_ASYNC_TASKS
, statVariables.
cpuUsageAsyncTasks
, rhs);
96
fromDictionary
(
HCE::drce::drce_json_message_const::MEMORY_USAGE_ASYNC_TASKS
, statVariables.
memoryUsageAsyncTasks
, rhs);
97
fromDictionary
(
HCE::drce::drce_json_message_const::COUNT_SYNC_TASKS_FOR_MINUTE
, statVariables.
countSyncTasksForMinute
, rhs);
98
fromDictionary
(
HCE::drce::drce_json_message_const::COUNT_ASYNC_TASKS_FOR_MINUTE
, statVariables.
countAsyncTasksForMinute
, rhs);
99
fromDictionary
(
HCE::drce::drce_json_message_const::COUNT_SYNC_TASKS
, statVariables.
countSyncTasks
, rhs);
100
fromDictionary
(
HCE::drce::drce_json_message_const::COUNT_ASYNC_TASKS
, statVariables.
countAsyncTasks
, rhs);
101
fromDictionary
(
HCE::drce::drce_json_message_const::COUNT_SYNC_TASKS_FAIL
, statVariables.
countSyncTasksFail
, rhs);
102
fromDictionary
(
HCE::drce::drce_json_message_const::COUNT_ASYNC_TASKS_FAIL
, statVariables.
countAsyncTasksFail
, rhs);
103
}
104
//-----------------------------------------------------------------------------
105
//-----------------------------------------------------------------------------
106
}
// end namespace drce
107
}
// end namespace HCE
sources
utils
DRCE
src
DRCEStatVariablesConverter.cpp
Generated on Tue Jun 30 2015 19:42:12 for hce-node application by
1.8.1.2