nnc: implement PluginSession class (#248)
authorVitaliy Cherepanov/AI Tools Lab/Engineer/삼성전자 <v.cherepanov@samsung.com>
Mon, 28 May 2018 12:30:49 +0000 (15:30 +0300)
committerSergey Vostokov/AI Tools Lab/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Mon, 28 May 2018 12:30:49 +0000 (15:30 +0300)
nnc: implement PluginSession class

This class will be used for nnc and plugins communication

Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
contrib/nnc/include/module/plugin/PluginSession.h [new file with mode: 0644]
contrib/nnc/src/module/plugin/PluginSession.cpp [new file with mode: 0644]

diff --git a/contrib/nnc/include/module/plugin/PluginSession.h b/contrib/nnc/include/module/plugin/PluginSession.h
new file mode 100644 (file)
index 0000000..b6d2a28
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __PLUGIN_SESSION_H__
+#define __PLUGIN_SESSION_H__
+
+#include <string>
+#include "AbstractSession.h"
+#include "PluginParam.h"
+#include "PluginData.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace config
+{
+
+class PluginSession : public AbstractSession
+{
+public:
+  PluginSession();
+
+  void addInfo(const std::string &name, const std::string &value) override;
+  void registerParam(const PluginParam &param) override;
+
+  const DataList &getInfo() const;
+  const std::string &getInfo(const std::string &name) const;
+  const std::map<std::string, PluginParam> &getSupportedParams() const;
+
+private:
+  DataList _info;
+  std::map<std::string, PluginParam> _supported_params_map;
+};
+
+std::ostream &operator<<(std::ostream &os, const PluginSession &op);
+
+} // namespace config
+} // namespace contrib
+} // namespace nncc
+
+#endif /*__PLUGIN_SESSION_H__ */
diff --git a/contrib/nnc/src/module/plugin/PluginSession.cpp b/contrib/nnc/src/module/plugin/PluginSession.cpp
new file mode 100644 (file)
index 0000000..e04d423
--- /dev/null
@@ -0,0 +1,49 @@
+#include <string>
+#include "PluginParam.h"
+#include "module/plugin/PluginSession.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace config
+{
+
+PluginSession::PluginSession() : _info("info") {}
+
+void PluginSession::addInfo(const std::string &name, const std::string &value)
+{
+  _info.createElement(name, value);
+}
+
+const std::string &PluginSession::getInfo(const std::string &name) const
+{
+  return _info.getElement(name).getValue();
+}
+
+const DataList &PluginSession::getInfo() const
+{
+  return _info;
+}
+
+void PluginSession::registerParam(const PluginParam &param)
+{
+  _supported_params_map.emplace(param.getName(), param);
+}
+
+const std::map<std::string, PluginParam> &PluginSession::getSupportedParams() const { return _supported_params_map; }
+
+std::ostream &operator<<(std::ostream &os, const PluginSession &session)
+{
+  os << session.getInfo();
+  os << "supported params:" << std::endl;
+  for (auto &el : session.getSupportedParams())
+  {
+    os << el.second << std::endl;
+  }
+  return os;
+}
+
+} // namespace config
+} // namespace core
+} // namespace nncc