Trace Parser: fix map forwarding 48/164148/4
authorAlexander Aksenov <a.aksenov@samsung.com>
Fri, 15 Dec 2017 14:52:20 +0000 (17:52 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Mon, 18 Dec 2017 11:56:33 +0000 (14:56 +0300)
Change-Id: I1d80d3668f26a651d656eb75560bed133885a884
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
src/cli/trace_parser/exe/main.cpp
src/cli/trace_parser/include/parser.h
src/cli/trace_parser/lib/parser.cpp

index e331e55..bc8f61b 100644 (file)
@@ -66,7 +66,7 @@ static void parse_loop(const Parser &parser, std::iostream &ios)
 static Parser get_parser(const SessionData &sd, std::iostream &out)
 {
     auto dw = get_data_writer(sd.get_type(), out);
-    ParserOptions opt(sd.get_version(), sd.get_cpu_num(), sd.get_devs_num(), dw, sd.get_api_map());
+    ParserOptions opt(sd.get_version(), sd.get_cpu_num(), sd.get_devs_num(), dw, std::move(sd.get_api_map()));
 
     return Parser(opt);
 }
index 1beea08..0361c5d 100644 (file)
@@ -71,15 +71,15 @@ private:
 //! Structure used to initialize Parser.
 struct ParserOptions
 {
-    const std::string version;             //!< Trace's protocol version
-    const int cpu_num;                     //!< Number of traget CPUs
-    const int devs_num;                    //!< Number of target energy devices
-    std::shared_ptr<DataWriter> writer;    //!< Writer pointer
-    std::map<int, std::string> &api_map;   //!< Reference to API map list
+    const std::string version;                  //!< Trace's protocol version
+    const int cpu_num;                          //!< Number of traget CPUs
+    const int devs_num;                         //!< Number of target energy devices
+    std::shared_ptr<DataWriter> writer;         //!< Writer pointer
+    const std::map<int, std::string> &api_map;  //!< Reference to API map list
 
     //! Initialized with structure members
     ParserOptions(const std::string &version, const int cpu_num, const int devs_num,
-                  std::shared_ptr<DataWriter> writer, std::map<int, std::string> api_map) :
+                  std::shared_ptr<DataWriter> writer, const std::map<int, std::string> &api_map) :
         version(version),
         cpu_num(cpu_num),
         devs_num(devs_num),
index 0753e43..548609f 100644 (file)
@@ -46,16 +46,16 @@ Parser::Parser(const ParserOptions &init_data)
     const int cpu_num = init_data.cpu_num;
     const int devs_num = init_data.devs_num;
     std::shared_ptr<DataWriter> dw = init_data.writer;
-    std::map<int, std::string> &api_map = init_data.api_map;
+    const std::map<int, std::string> &api_map = init_data.api_map;
 
     if (!init_data.version.compare(v30))
-        protocol_ = std::make_unique<Protocol30>(dw, cpu_num, devs_num, api_map);
+        protocol_ = std::make_unique<Protocol30>(dw, cpu_num, devs_num, std::move(api_map));
     else if (!init_data.version.compare(v40))
-        protocol_ = std::make_unique<Protocol40>(dw, cpu_num, devs_num, api_map);
+        protocol_ = std::make_unique<Protocol40>(dw, cpu_num, devs_num, std::move(api_map));
     else if (!init_data.version.compare(v41))
-        protocol_ = std::make_unique<Protocol41>(dw, cpu_num, devs_num, api_map);
+        protocol_ = std::make_unique<Protocol41>(dw, cpu_num, devs_num, std::move(api_map));
     else if (!init_data.version.compare(v42))
-        protocol_ = std::make_unique<Protocol42>(dw, cpu_num, devs_num, api_map);
+        protocol_ = std::make_unique<Protocol42>(dw, cpu_num, devs_num, std::move(api_map));
     else
         throw std::logic_error((boost::format("Wrong protocol version <%1%>. \
                                                Suppotred versions are <%2%>, \