iotivity 0.9.0
[platform/upstream/iotivity.git] / service / notification-manager / NotificationManager / include / HostingHandler.h
1 /*
2  * HostingHandler.h
3  *
4  *  Created on: 2014. 10. 15.
5  *      Author: jyong2
6  */
7
8 #ifndef HOSTINGHANDLER_H_
9 #define HOSTINGHANDLER_H_
10
11 #include "NotificationManager.h"
12
13 class HostingHandler
14 {
15 public:
16
17         static void initialize();
18         static void initialize(HostingConfig cfg);
19         static HostingHandler *getInstance();
20
21         void setHostingConfig(HostingConfig cfg);
22
23         void changeHostingMode(HostingMode hostingMode, AutomaticMethod autoMethod = AutomaticMethod::None);
24         void changeAutomaticHostingMethod(AutomaticMethod autoMethod);
25         void changeNotifiyMethod(NotifyMethod notifyMethod);
26         void changeNotifyFrequencyType(NotifyFrequency notifyFrequency);
27
28 private:
29
30         HostingHandler();
31         ~HostingHandler();
32
33         static HostingHandler *s_instance;
34         static mutex s_mutexForCreation;
35
36         HostingConfig hostingCfg;
37
38         static std::function< void(bool isHosting) > s_findHostingCandidate;
39         static std::function< void(std::string) > s_addExtraStr;
40         static std::function< void(std::shared_ptr< OCResource > resource) > s_startHosting;
41         static std::function< void(OCResourceHandle resourceHandle) > s_notify;
42
43         void startFindHost();
44         void onObserve(AttributeMap &AttMap, OCResourceHandle resourceHandle);
45         void onFoundCandidate(std::shared_ptr< OCResource > resource);
46
47         void runAutomaticHosting(AutomaticMethod autoMethod);
48         void stopAutomaticHosting();
49
50         void notifyFrequence(OCResourceHandle resourceHandle);
51
52 };
53
54 #endif /* HOSTINGHANDLER_H_ */