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 #include "NotificationManager.h"
23 NotificationManager *NotificationManager::s_instance = NULL;
24 //OCPlatform *NotificationManager::s_nmOCPlatform = NULL;
25 PlatformConfig NotificationManager::s_cfg;
26 //(ServiceType::InProc, ModeType::Both, "134.134.161.33", 5683, QualityOfService::NonConfirmable);
28 NotificationManager::NotificationManager()
34 m_startHosting = NULL;
39 NotificationManager::~NotificationManager()
43 void NotificationManager::initialize()
49 setOnFoundHostingCandidate(NULL);
50 setStartHosting(NotificationManager::getInstance()->m_startHosting);
51 setFindHosting(NotificationManager::getInstance()->m_findHosting);
52 setAddExtraStr(NotificationManager::getInstance()->m_addExtraStr);
55 findHostingCandidate();
60 void NotificationManager::registerHostingEventListener()
62 // TODO : Initial HostingEventListener (v1.0)
65 void NotificationManager::findHostingCandidate()
69 ResourceManager::getInstance()->findNMResource("" , "coap://224.0.1.187/oc/core" , true);
76 NotificationManager *NotificationManager::getInstance()
80 s_instance = new NotificationManager();
86 int NotificationManager::setPrint(std::function< void(AttributeMap &inputAttMap) > func)
92 NotificationManager::getInstance()->m_print = func;
101 NotificationManager::getInstance()->m_print =
102 std::function< void(AttributeMap &inputAttMap) >(
103 std::bind(&ResourceManager::printAttributeMap ,
104 ResourceManager::getInstance() , std::placeholders::_1));
109 int NotificationManager::setOnFoundHostingCandidate(
110 std::function< void(std::shared_ptr< OCResource > resource) > func)
116 NotificationManager::getInstance()->m_onfound = func;
125 NotificationManager::getInstance()->m_onfound = std::function<
126 void(std::shared_ptr< OCResource > resource) >(
127 std::bind(&ResourceManager::onFoundReport , ResourceManager::getInstance() ,
128 std::placeholders::_1));
134 int NotificationManager::setOnObserve(std::function< void(AttributeMap &inputAttMap) > func)
140 NotificationManager::getInstance()->m_onObserve = func;
150 std::function< void(AttributeMap &inputAttMap) > NotificationManager::getPrint()
155 std::function< void(std::shared_ptr< OCResource > resource) > NotificationManager::getOnFoundHostingCandidate()
160 std::function< void(AttributeMap &inputAttMap) > NotificationManager::getOnObserve()
165 int NotificationManager::setStartHosting(
166 std::function< void(std::shared_ptr< OCResource > resource) > &func)
170 func = std::function< void(std::shared_ptr< OCResource > resource) >(
171 std::bind(&ResourceManager::startHosting , ResourceManager::getInstance() ,
172 std::placeholders::_1));
182 int NotificationManager::setFindHosting(std::function< void() > &func)
186 func = std::function< void() >(
187 std::bind(&NotificationManager::findHostingCandidate ,
188 NotificationManager::getInstance()));
198 int NotificationManager::setAddExtraStr(std::function< void(std::string) > &func)
202 func = std::function< void(std::string str) >(
203 std::bind(&ResourceManager::addExtraStr , ResourceManager::getInstance() ,
204 std::placeholders::_1));
214 std::function< void(std::shared_ptr< OCResource > resource) > NotificationManager::getStartHosting()
218 return m_startHosting;
226 std::function< void() > NotificationManager::getFindHosting()
230 return m_findHosting;
238 std::function< void(std::string) > NotificationManager::getAddExtraStr()
242 return m_addExtraStr;