1 //******************************************************************
3 // Copyright 2014 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 /// @file ThingsManager.cpp
24 #include "ThingsManager.h"
25 #include "GroupManager.h"
26 #include "GroupSynchronization.h"
27 #include "ThingsConfiguration.h"
28 #include "ThingsDiagnostics.h"
35 GroupManager *g_groupManager;
36 GroupSynchronization *g_groupSync = NULL;
37 ThingsConfiguration *g_thingsConf = NULL;
38 ThingsDiagnostics *g_thingsDiag = NULL;
40 ThingsManager::ThingsManager(void)
42 g_groupManager = new GroupManager();
43 g_groupSync = GroupSynchronization::getInstance();
44 g_thingsConf = ThingsConfiguration::getInstance();
45 g_thingsDiag = ThingsDiagnostics::getInstance();
46 g_thingsConf->setGroupManager(g_groupManager);
47 g_thingsDiag->setGroupManager(g_groupManager);
53 ThingsManager::~ThingsManager(void)
55 delete g_groupManager;
56 g_groupSync->deleteInstance();
57 g_thingsConf->deleteInstance();
58 g_thingsDiag->deleteInstance();
63 OCStackResult ThingsManager::findCandidateResources(std::vector< std::string > resourceTypes,
64 std::function< void(std::vector< std::shared_ptr< OCResource > >) > callback, int waitsec)
66 OCStackResult result = g_groupManager->findCandidateResources(resourceTypes,callback,waitsec);
71 OCStackResult ThingsManager::subscribeCollectionPresence(std::shared_ptr< OCResource > resource, std::function< void(std::string, OCStackResult) > callback)
73 OCStackResult result = g_groupManager->subscribeCollectionPresence(resource,callback);
78 OCStackResult ThingsManager::findGroup (std::vector<std::string> collectionResourceTypes, FindCallback resourceHandler)
80 OCStackResult result = g_groupSync->findGroup(collectionResourceTypes, resourceHandler);
85 OCStackResult ThingsManager::createGroup (std::string collectionResourceType)
87 OCStackResult result = g_groupSync->createGroup(collectionResourceType);
92 OCStackResult ThingsManager::joinGroup (std::string collectionResourceType, OCResourceHandle resourceHandle)
94 OCStackResult result = g_groupSync->joinGroup(collectionResourceType, resourceHandle);
99 OCStackResult ThingsManager::joinGroup (const std::shared_ptr<OCResource> resource, OCResourceHandle resourceHandle)
101 OCStackResult result = g_groupSync->joinGroup(resource, resourceHandle);
106 OCStackResult ThingsManager::leaveGroup (std::string collectionResourceType, OCResourceHandle resourceHandle)
108 OCStackResult result = g_groupSync->leaveGroup(collectionResourceType, resourceHandle);
113 void ThingsManager::deleteGroup (std::string collectionResourceType)
115 g_groupSync->deleteGroup(collectionResourceType);
118 std::map<std::string, OCResourceHandle> ThingsManager::getGroupList ()
120 return g_groupSync->getGroupList();
123 OCStackResult ThingsManager::updateConfigurations(std::shared_ptr< OCResource > resource, std::map<ConfigurationName, ConfigurationValue> configurations, ConfigurationCallback callback)
125 return g_thingsConf->updateConfigurations(resource, configurations, callback);
127 OCStackResult ThingsManager::getConfigurations(std::shared_ptr< OCResource > resource, std::vector<ConfigurationName> configurations, ConfigurationCallback callback)
129 return g_thingsConf->getConfigurations( resource, configurations, callback);
131 std::string ThingsManager::getListOfSupportedConfigurationUnits()
133 return g_thingsConf->getListOfSupportedConfigurationUnits();
136 OCStackResult ThingsManager::doBootstrap(ConfigurationCallback callback)
138 return g_thingsConf->doBootstrap(callback);
142 OCStackResult ThingsManager::reboot(std::shared_ptr< OCResource > resource, ConfigurationCallback callback)
144 return g_thingsDiag->reboot( resource, callback);
146 OCStackResult ThingsManager::factoryReset(std::shared_ptr< OCResource > resource, ConfigurationCallback callback)
148 return g_thingsDiag->factoryReset( resource, callback);
153 std::string ThingsManager::getStringFromActionSet(const ActionSet *newActionSet)
155 return g_groupManager->getStringFromActionSet(newActionSet);
157 ActionSet* ThingsManager::getActionSetfromString(std::string desc)
159 return g_groupManager->getActionSetfromString(desc);
161 OCStackResult ThingsManager::addActionSet(std::shared_ptr< OCResource > resource, const ActionSet* newActionSet, PutCallback cb)
163 return g_groupManager->addActionSet(resource, newActionSet, cb);
165 OCStackResult ThingsManager::executeActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName, PostCallback cb)
167 return g_groupManager->executeActionSet(resource, actionsetName, cb);
169 OCStackResult ThingsManager::getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName, GetCallback cb)
171 return g_groupManager->getActionSet(resource, actionsetName, cb);
173 OCStackResult ThingsManager::deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName, PostCallback cb)
175 return g_groupManager->deleteActionSet(resource, actionsetName, cb);