summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/encode/XCpuUsageImp.cpp
blob: d55c8a0616fb1ac4d1c81e7b61a814f1bbf4a83a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "XCpuUsageImp.h"

XCpuUsageImp::XCpuUsageImp(const XString& cpuIdentifier,
    XNumber percentUsage):
        cpuIdentifier_(cpuIdentifier),
        percentUsage_(percentUsage)
{

}

void XCpuUsageImp::setPercentUsage(XNumber percentUsage)
{
    comVals_["percentUsage"] = percentUsage;
}
            
void XCpuUsageImp::setCpuUsageInterrupt(XNumber cpuUsageInterrupt)
{
    comVals_["cpuUsageInterrupt"] = cpuUsageInterrupt;
}
            
void XCpuUsageImp::setCpuWait(XNumber cpuWait)
{
    comVals_["cpuWait"] = cpuWait;
}
            
void XCpuUsageImp::setCpuCapacityContention(XNumber cpuCapacityContention)
{
    comVals_["cpuCapacityContention"] = cpuCapacityContention;
}
            
void XCpuUsageImp::setCpuUsageNice(XNumber cpuUsageNice)
{
    comVals_["cpuUsageNice"] = cpuUsageNice;
}
            
void XCpuUsageImp::setCpuDemandMhz(XNumber cpuDemandMhz)
{
    comVals_["cpuDemandMhz"] = cpuDemandMhz;
}
            
void XCpuUsageImp::setCpuUsageSoftIrq(XNumber cpuUsageSoftIrq)
{
    comVals_["cpuUsageSoftIrq"] = cpuUsageSoftIrq;
}
            
void XCpuUsageImp::setCpuLatencyAvg(XNumber cpuLatencyAvg)
{
    comVals_["cpuLatencyAvg"] = cpuLatencyAvg;
}
            
void XCpuUsageImp::setCpuUsageSteal(XNumber cpuUsageSteal)
{
    comVals_["cpuUsageSteal"] = cpuUsageSteal;
}
            
void XCpuUsageImp::setCpuDemandPct(XNumber cpuDemandPct)
{
    comVals_["cpuDemandPct"] = cpuDemandPct;
}
            
void XCpuUsageImp::setCpuDemandAvg(XNumber cpuDemandAvg)
{
    comVals_["cpuDemandAvg"] = cpuDemandAvg;
}
            
void XCpuUsageImp::setCpuIdle(XNumber cpuIdle)
{
    comVals_["cpuIdle"] = cpuIdle;
}
            
void XCpuUsageImp::setCpuSwapWaitTime(XNumber cpuSwapWaitTime)
{
    comVals_["cpuSwapWaitTime"] = cpuSwapWaitTime;
}
            
void XCpuUsageImp::setCpuUsageSystem(XNumber cpuUsageSystem)
{
    comVals_["cpuUsageSystem"] = cpuUsageSystem;
}
            
void XCpuUsageImp::setCpuOverheadAvg(XNumber cpuOverheadAvg)
{
    comVals_["cpuOverheadAvg"] = cpuOverheadAvg;
}
            
void XCpuUsageImp::setCpuUsageUser(XNumber cpuUsageUser)
{
    comVals_["cpuUsageUser"] = cpuUsageUser;
}
            
void XCpuUsageImp::setCpuIdentifier(const XString& cpuIdentifier)
{
    comVals_["cpuIdentifier"] = cpuIdentifier;
}

json XCpuUsageImp::toJson()
{
    try
    {
        json field = {
            {"percentUsage", percentUsage_},
            {"cpuIdentifier", cpuIdentifier_}
        };

        //optional val
        
        field = mergeCommonValues(field, comVals_);

        return field;
    }
    catch (json::exception& e)
    {
        SPDLOG_ERROR("Fail to build XCpuUsage to json object:{}.", e.what());
        return json();
    }
}