summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp
diff options
context:
space:
mode:
authorYatian XU <yatian.xu@nokia-sbell.com>2019-09-10 13:50:31 +0800
committerYatian XU <yatian.xu@nokia-sbell.com>2019-09-10 13:50:31 +0800
commitbe6db99ca9b99a3b72b71a8fb1f5fcd9fc8aaf8f (patch)
tree6bbb90f07e03f4b90886391e859884898604ae05 /veslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp
parent6c27d22ac7af3d1379a5448eef5894083bcae9ec (diff)
Contribute C++ implement of VES spec 7.0.1 to ONAP/vnfsdk:
Part3: encode library Issue-ID: VNFSDK-466 Signed-off-by: Yatian XU <yatian.xu@nokia-sbell.com> Change-Id: I2bf21e61e9027385ec9b604206ba81a3acea99c5
Diffstat (limited to 'veslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp')
-rwxr-xr-xveslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/veslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp b/veslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp
new file mode 100755
index 0000000..6610d2f
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/lib/encode/XBatchImp.cpp
@@ -0,0 +1,45 @@
+#include "XBatchImp.h"
+
+std::string XBatchImp::toString()
+{
+ try
+ {
+ auto js = toJson();
+ return js.dump();
+ }
+ catch (json::exception& e)
+ {
+ SPDLOG_ERROR("Fail to dump XIpmiNic to json string:{}.", e.what());
+ return "";
+ }
+}
+
+void XBatchImp::addEvent(shared_ptr<XSerialable> event)
+{
+ events_.push_back(event);
+}
+
+nlohmann::json vagt::encode::XBatchImp::toJson()
+{
+ try
+ {
+ json field = json::array();
+
+ for (auto event : events_)
+ {
+ if (event)
+ {
+ field.push_back( dynamic_pointer_cast<XJsonable>(event)->toJson()["event"]);
+ }
+ }
+
+ json jsEvent;
+ jsEvent["eventList"] = field;
+ return jsEvent;
+ }
+ catch (json::exception& e)
+ {
+ SPDLOG_ERROR("Fail to build XBatch to json object:{}.", e.what());
+ return json();
+ }
+}