summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/encode/XMachineCheckExceptionImp.cpp
blob: 05d0e41527a7d040debc553fa865d7491e87785e (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
#include "XMachineCheckExceptionImp.h"

XMachineCheckExceptionImp::XMachineCheckExceptionImp(const XString& vmIdentifier):
        vmIdentifier_(vmIdentifier)
{

}

void XMachineCheckExceptionImp::setCorrectedMemoryErrors(XNumber correctedMemoryErrors)
{
    comVals_["correctedMemoryErrors"] = correctedMemoryErrors;
}
            
void XMachineCheckExceptionImp::setUncorrectedMemoryErrors(XNumber uncorrectedMemoryErrors)
{
    comVals_["uncorrectedMemoryErrors"] = uncorrectedMemoryErrors;
}
            
void XMachineCheckExceptionImp::setUncorrectedMemoryErrorsIn1Hr(XNumber uncorrectedMemoryErrorsIn1Hr)
{
    comVals_["uncorrectedMemoryErrorsIn1Hr"] = uncorrectedMemoryErrorsIn1Hr;
}
            
void XMachineCheckExceptionImp::setCorrectedMemoryErrorsIn1Hr(XNumber correctedMemoryErrorsIn1Hr)
{
    comVals_["correctedMemoryErrorsIn1Hr"] = correctedMemoryErrorsIn1Hr;
}
            
void XMachineCheckExceptionImp::setVmIdentifier(const XString& vmIdentifier)
{
    comVals_["vmIdentifier"] = vmIdentifier;
}

json XMachineCheckExceptionImp::toJson()
{
    try
    {
        json field = {
            {"vmIdentifier", vmIdentifier_}
        };

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

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