Merge "[systeminfo] Prevent possible crash when failure initialization" into tizen
[platform/core/api/webapi-plugins.git] / src / ml / ml_pipeline_manager.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 #ifndef ML_ML_PIPELINE_MANAGER_H_
18 #define ML_ML_PIPELINE_MANAGER_H_
19
20 #include "common/extension.h"
21 #include "common/picojson.h"
22 #include "common/platform_result.h"
23
24 #include "ml_pipeline.h"
25 #include "ml_tensors_info_manager.h"
26
27 using common::PlatformResult;
28
29 namespace extension {
30 namespace ml {
31
32 class PipelineManager {
33  public:
34   PipelineManager(common::Instance* instance_ptr, TensorsInfoManager* tim);
35
36   ~PipelineManager();
37
38   PipelineManager() = delete;
39   PipelineManager(const PipelineManager&) = delete;
40   PipelineManager& operator=(const PipelineManager&) = delete;
41
42   // PipelineManager::createPipeline() begin
43   PlatformResult CreatePipeline(int id, const std::string& definition,
44                                 const std::string& state_change_listener_name);
45   // PipelineManager::createPipeline() end
46
47   // Pipeline::state begin
48   PlatformResult GetPipelineState(int id, std::string* out);
49   // Pipeline::state end
50
51   // Pipeline::start() begin
52   PlatformResult Start(int id);
53   // Pipeline::start() end
54
55   // Pipeline::stop() begin
56   PlatformResult Stop(int id);
57   // Pipeline::stop() end
58
59   // Pipeline::dispose() begin
60   PlatformResult DisposePipeline(int id);
61   // Pipeline::dispose() end
62
63   // Pipeline::getNodeInfo() begin
64   PlatformResult GetNodeInfo(int id, std::string& name);
65   // Pipeline::getNodeInfo() end
66
67   // Pipeline::getSource() begin
68   PlatformResult GetSource(int pipeline_id, const std::string& name);
69   // Pipeline::getSource() end
70
71   // Pipeline::getSwitch() begin
72   PlatformResult GetSwitch(const std::string& name, int pipeline_id, std::string* type);
73   // Pipeline::getSwitch() end
74
75   // Pipeline::getValve() begin
76   PlatformResult GetValve(const std::string& name, int pipeline_id);
77   // Pipeline::getValve() end
78
79   // Pipeline::registerSinkCallback() begin
80
81   // Pipeline::registerSinkCallback() end
82
83   // Pipeline::unregisterSinkCallback() begin
84
85   // Pipeline::unregisterSinkCallback() end
86
87   // Pipeline::registerCustomFilter() begin
88
89   // Pipeline::registerCustomFilter() end
90
91   // Pipeline::unregisterCustomFilter() begin
92
93   // Pipeline::unregisterCustomFilter() end
94
95   // NodeInfo::getProperty() begin
96   PlatformResult getProperty(int id, const std::string& node_name, const std::string& name,
97                              const std::string& type, picojson::object* property);
98   // NodeInfo::getProperty() end
99
100   // NodeInfo::setProperty() begin
101   PlatformResult setProperty(int id, const std::string& node_name, const std::string& name,
102                              const std::string& type, const picojson::value& property);
103   // NodeInfo::setProperty() end
104
105   // Source::inputTensorsInfo begin
106   PlatformResult getInputTensorsInfo(int id, const std::string& name, int* res_id);
107   // Source::inputTensorsInfo end
108
109   // Source::inputData() begin
110
111   // Source::inputData() end
112
113   // Switch::getPadList() begin
114   PlatformResult SwitchGetPadList(int pipeline_id, const std::string& switch_name,
115                                   picojson::array* out);
116   // Switch::getPadList() end
117
118   // Switch::select() begin
119   PlatformResult SwitchSelect(int pipeline_id, const std::string& switch_name,
120                               const std::string& pad_name);
121   // Switch::select() end
122
123   // Valve::setOpen() begin
124   PlatformResult ValveSetOpen(int pipeline_id, const std::string& valve_name, bool open);
125   // Valve::setOpen() end
126
127   // Valve::isOpen() begin
128   PlatformResult ValveIsOpen(int pipeline_id, const std::string& valve_name, bool* open);
129   // Valve::isOpen() end
130  private:
131   common::Instance* instance_ptr_;
132   TensorsInfoManager* tensors_info_manager_;
133   std::map<int, std::unique_ptr<Pipeline>> pipelines_;
134 };
135
136 }  // namespace ml
137 }  // namespace extension
138
139 #endif  // ML_ML_PIPELINE_MANAGER_H_