iotivity 0.9.0
[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 #include <condition_variable>
33
34 #include "OICPlatformConfig.h"
35 #include "HostingConfig.h"
36 #include "ResourceManager.h"
37 #include "RegistrationManager.h"
38 #include "VirtualRepresentation.h"
39 #include "HostingHandler.h"
40 #include "HostingInterface.h"
41
42 #include <sys/ioctl.h>
43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <unistd.h>
46 #include <netinet/in.h>
47 #include <arpa/inet.h>
48 #include <net/if.h>
49
50 #define IN
51 #define OUT
52
53 using namespace OC;
54 using namespace OCPlatform;
55
56 const std::string VIRTURL_TAG = "/virtual";
57
58 class NotificationManager
59 {
60
61 private:
62
63     NotificationManager();
64     NotificationManager(HostingConfig cfg);
65     ~NotificationManager();
66
67     static NotificationManager *s_instance;
68     static mutex s_mutexForCreation;
69
70     int getNetInfo(IN int& sck, IN struct ifreq* item, OUT std::string& ip_addres);
71     bool scanAndGetNetworkInterface(OUT std::string& ip_addres);
72
73 public:
74
75     static void initialize();
76     static void initialize(HostingConfig cfg);
77     static NotificationManager *getInstance();
78
79     void registerHostingEventListener();
80
81 };
82
83 #endif /* NOTIFICATIONMANAGER_H_ */