• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ModelManager.h"
17 
18 #include "Interrupter.h"
19 #include "PreviewerEngineLog.h"
20 
21 using namespace std;
22 
23 vector<ModelConfig> ModelManager::configList = { // NOLINT
24     {"liteWearable", "***", "***", "***", "***", 2},
25     {"smartVision", "***", "***", "***", "***", 2},
26 };
27 
28 string ModelManager::currentDevice;
29 
GetCurrentModel()30 string ModelManager::GetCurrentModel()
31 {
32     return currentDevice;
33 }
34 
GetAllModelName()35 string ModelManager::GetAllModelName()
36 {
37     string allNames;
38     for (ModelConfig const& config : configList) {
39         allNames += string(config.modelName);
40         allNames += " ";
41     }
42     return allNames;
43 }
44 
SetCurrentDevice(const string & value)45 void ModelManager::SetCurrentDevice(const string& value)
46 {
47     currentDevice = value;
48     ILOG("Start Simulator: %s", GetConfig().modelName.c_str());
49 }
50 
51 /*
52  * Get the model configuration based on the model name.
53  */
GetConfig(string device)54 const ModelConfig& ModelManager::GetConfig(string device)
55 {
56     for (ModelConfig const& config : configList) {
57         if (config.deviceType == device) {
58             return config;
59         }
60     }
61     FLOG("ModelManager::GetConfig current device model not exists. device : %s", currentDevice.c_str());
62     Interrupter::Interrupt();
63     return *configList.begin();
64 }
65 
GetConfig()66 const ModelConfig& ModelManager::GetConfig()
67 {
68     return GetConfig(currentDevice);
69 }
70