services: use const std::string &key 31/313131/1
authorInki Dae <inki.dae@samsung.com>
Wed, 19 Jun 2024 07:43:18 +0000 (16:43 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 19 Jun 2024 07:45:56 +0000 (16:45 +0900)
Just code cleanup by using const std::string &key intead of just std::string
key as an paramter of setXXX function in ServiceConfigParser class.

Change-Id: I02bf6a9ff60673f0621ea683870c983ab37a5c0f
Signed-off-by: Inki Dae <inki.dae@samsung.com>
services/common/include/ServiceConfigParser.h
services/common/include/ServiceFactory.h
services/common/src/ServiceConfigParser.cpp

index 3586dc05415439e7268632c85efbf87622132404..83d2cc10bd3a117d26e162aa8cf3084c8a0a0e6d 100644 (file)
@@ -44,12 +44,12 @@ private:
        bool isKeyValid(std::map<std::string, bool> &valid_keys, const std::string &key);
        void parse(std::map<std::string, bool> &valid_keys, std::string option);
        void update();
-       void setServiceName(std::string key);
-       void setInputFeedType(std::string key);
-       void setCameraDeviceId(std::string key);
-       void setFps(std::string key);
-       void setAsyncMode(std::string key);
-       void setInputFormat(std::string key);
+       void setServiceName(const std::string &key);
+       void setInputFeedType(const std::string &key);
+       void setCameraDeviceId(const std::string &key);
+       void setFps(const std::string &key);
+       void setAsyncMode(const std::string &key);
+       void setInputFormat(const std::string &key);
 
 public:
        ServiceConfigParser() = default;
index 81f60c1fe5fd95027c0be840d0e1b6d0ca7a0200..8ab2b6a7839ab87680e1fa4fc17b079a78ca6433 100644 (file)
@@ -31,7 +31,7 @@ namespace services
 class ServiceFactory
 {
 public:
-       using createFunc = IService *(*)();
+       using createFunc = IService *(*) ();
 
        static ServiceFactory &instance()
        {
index aa794a0b6c083ab166428b797a7b147e105a8dae..6119ef5e311b16c9ea4b15edf8e504b96c56db1b 100644 (file)
@@ -52,12 +52,12 @@ bool ServiceConfigParser::isKeyValid(map<string, bool> &valid_keys, const string
        return true;
 }
 
-void ServiceConfigParser::setServiceName(string key)
+void ServiceConfigParser::setServiceName(const string &key)
 {
        _service_name = key;
 }
 
-void ServiceConfigParser::setInputFeedType(std::string key)
+void ServiceConfigParser::setInputFeedType(const std::string &key)
 {
        static map<string, InputFeedType> valid_services = {
                { "CAMERA", InputFeedType::CAMERA },
@@ -71,12 +71,12 @@ void ServiceConfigParser::setInputFeedType(std::string key)
        _input_feed_type = it->second;
 }
 
-void ServiceConfigParser::setCameraDeviceId(std::string key)
+void ServiceConfigParser::setCameraDeviceId(const std::string &key)
 {
        _camera_config.device_id = std::stoi(key);
 }
 
-void ServiceConfigParser::setFps(std::string key)
+void ServiceConfigParser::setFps(const std::string &key)
 {
        int fps = std::stoi(key);
        if (fps < 1 || fps > 60)
@@ -85,7 +85,7 @@ void ServiceConfigParser::setFps(std::string key)
        _fps = fps;
 }
 
-void ServiceConfigParser::setAsyncMode(std::string key)
+void ServiceConfigParser::setAsyncMode(const std::string &key)
 {
        int async_mode = std::stoi(key);
        if (async_mode != 0 && async_mode != 1)
@@ -94,7 +94,7 @@ void ServiceConfigParser::setAsyncMode(std::string key)
        _async_mode = async_mode;
 }
 
-void ServiceConfigParser::setInputFormat(string key)
+void ServiceConfigParser::setInputFormat(const string &key)
 {
        static map<string, ImagePixelFormat> valid_services = { { "YUV420", ImagePixelFormat::YUV420 },
                                                                                                                        { "RGB888", ImagePixelFormat::RGB888 } };
@@ -184,7 +184,7 @@ void ServiceConfigParser::parseInput(std::string option)
 
 void ServiceConfigParser::update()
 {
-       using setParamCallback = void (ServiceConfigParser::*)(std::string);
+       using setParamCallback = void (ServiceConfigParser::*)(const std::string &);
 
        auto setParam = [this](const std::string &key, setParamCallback cb) -> void {
                auto it = _params.find(key);