3ac4db34f73e2ef3123d11069651de5c77a05d53
[platform/upstream/iotivity.git] / service / notification-manager / NotificationManager / include / NotificationManager.h
1 //******************************************************************
2 //
3 // Copyright 2014 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef NOTIFICATIONMANAGER_H_
22 #define NOTIFICATIONMANAGER_H_
23
24 #include <iostream>
25 #include <functional>
26 #include <pthread.h>
27 #include <cstdint>
28 #include <memory>
29 #include <string>
30 #include <vector>
31 #include <list>
32
33 #include "OCApi.h"
34 #include "OCPlatform.h"
35 #include "OCResource.h"
36 #include "OCResourceRequest.h"
37 #include "OCResourceResponse.h"
38 #include "ocstack.h"
39
40 #include "ResourceManager.h"
41 #include "RegistrationManager.h"
42 #include "VirtualRepresentation.h"
43
44 #define ISFORDEMO 1
45
46 using namespace OC;
47 using namespace OCPlatform;
48
49 const std::string VIRTURL_TAG = "/virtual";
50
51 class NotificationManager
52 {
53
54 private:
55
56     static NotificationManager *s_instance;
57 //    static OCPlatform *s_nmOCPlatform;
58
59     static PlatformConfig s_cfg;
60
61     std::function< void(AttributeMap &inputAttMap) > m_print;
62     std::function< void(std::shared_ptr< OCResource > resource) > m_onfound;
63     std::function< void(AttributeMap &inputAttMap) > m_onObserve;
64
65     std::function< void(std::shared_ptr< OCResource > resource) > m_startHosting;
66     std::function< void() > m_findHosting;
67     std::function< void(std::string) > m_addExtraStr;
68
69 public:
70
71     NotificationManager();
72     ~NotificationManager();
73
74     static NotificationManager *getInstance();
75
76     void initialize();
77     void findHostingCandidate();
78     void registerHostingEventListener();
79
80     int setPrint(std::function< void(AttributeMap &inputAttMap) > func);
81     int setOnFoundHostingCandidate(
82             std::function< void(std::shared_ptr< OCResource > resource) > func);
83     int setOnObserve(std::function< void(AttributeMap &inputAttMap) > func);
84
85     std::function< void(AttributeMap &inputAttMap) > getPrint();
86     std::function< void(std::shared_ptr< OCResource > resource) > getOnFoundHostingCandidate();
87     std::function< void(AttributeMap &inputAttMap) > getOnObserve();
88
89     int setStartHosting(std::function< void(std::shared_ptr< OCResource > resource) > &func);
90     int setFindHosting(std::function< void() > &func);
91     int setAddExtraStr(std::function< void(std::string) > &func);
92
93     std::function< void(std::shared_ptr< OCResource > resource) > getStartHosting();
94     std::function< void() > getFindHosting();
95     std::function< void(std::string) > getAddExtraStr();
96
97 };
98
99 #endif /* NOTIFICATIONMANAGER_H_ */