1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "simulator_manager.h"
22 #include "resource_manager.h"
23 #include "simulator_client.h"
27 SimulatorManager *SimulatorManager::getInstance()
29 static SimulatorManager s_instance;
33 SimulatorManager::SimulatorManager()
35 OC::PlatformConfig conf
37 OC::ServiceType::InProc,
39 "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces
40 0, // Uses randomly available port
41 OC::QualityOfService::LowQos
44 OC::OCPlatform::Configure(conf);
47 SimulatorResourceServerPtr SimulatorManager::createResource(const std::string &configPath,
48 SimulatorResourceServer::ResourceModelChangedCB callback)
50 return ResourceManager::getInstance()->createResource(configPath, callback);
53 std::vector<SimulatorResourceServerPtr> SimulatorManager::createResource(
54 const std::string &configPath,
55 const int count, SimulatorResourceServer::ResourceModelChangedCB callback)
57 return ResourceManager::getInstance()->createResource(configPath, count, callback);
60 std::vector<SimulatorResourceServerPtr> SimulatorManager::getResources(
61 const std::string &resourceType)
63 return ResourceManager::getInstance()->getResources(resourceType);
66 SimulatorResult SimulatorManager::deleteResource(SimulatorResourceServerPtr &resource)
68 return ResourceManager::getInstance()->deleteResource(resource);
71 SimulatorResult SimulatorManager::deleteResources(const std::string &resourceType)
73 return ResourceManager::getInstance()->deleteResources(resourceType);
76 SimulatorResult SimulatorManager::findResource(const std::string &resourceType,
77 ResourceFindCallback callback)
79 return SimulatorClient::getInstance()->findResource(resourceType, callback);
82 std::vector<SimulatorRemoteResourcePtr> SimulatorManager::getFoundResources(
83 const std::string resourceType)
85 return SimulatorClient::getInstance()->getFoundResources(resourceType);
88 void SimulatorManager::setLogger(std::shared_ptr<ILogger> logger)
90 simLogger().setCustomTarget(logger);
93 bool SimulatorManager::setDefaultConsoleLogger()
95 return simLogger().setDefaultConsoleTarget();
98 bool SimulatorManager::setDefaultFileLogger(std::string &path)
100 return simLogger().setDefaultFileTarget(path);