7b67875aa4466868ad8cf7fa3fdb967ae4fc6197
[platform/upstream/iotivity.git] / service / notification-manager / NotificationManager / include / VirtualRepresentation.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 VIRTUALREPRESENTATION_H_
22 #define VIRTUALREPRESENTATION_H_
23
24 #include <functional>
25 #include <condition_variable>
26
27 #include "OCPlatform.h"
28 #include "OCApi.h"
29 #include "NotificationManager.h"
30
31 #define SUCCESS_RESPONSE 0
32
33 using namespace OC;
34 using namespace OCPlatform;
35 using namespace std;
36
37 class ResourceManager;
38
39 class VirtualRepresentation
40 {
41
42 private:
43     std::string m_virtualUri;
44     std::string m_originHostIP;
45     std::string m_resourceTypeName;
46     std::string m_resourceInterface;
47     uint8_t m_resourceProperty;
48
49     OCResourceHandle m_resourceHandle;
50
51     static AttributeMap s_attributeMap;
52     static std::mutex s_mutexAttributeMap;
53     static std::condition_variable s_conditionAttributeMap;
54     static bool m_isReadyAttributeMap;
55
56     int getRepresentation(OCRepresentation& oc);
57
58 public:
59
60     std::string getUri();
61     std::string getHostIP();
62     std::string getResourceTypeName();
63     std::string getResourceInterface();
64     uint8_t getResourceProperty();
65     OCResourceHandle getResourceHandle();
66
67     int setUri(std::string uri);
68     int setHostIP(std::string ip);
69     int setResourceTypeName(std::string typeName);
70     int setResourceInterface(std::string interface);
71     int setResourceProperty(uint8_t property);
72     int setResourceHandle(OCResourceHandle & handle);
73
74 public:
75     VirtualRepresentation();
76     virtual ~VirtualRepresentation();
77
78     std::string addVirtualTag(std::string uri);
79
80     OCEntityHandlerResult entityHandler(const std::shared_ptr<OCResourceRequest> request ,
81                 const std::shared_ptr<OCResourceResponse> response);
82     void onObserve(const HeaderOptions &headerOption, const OCRepresentation &rep ,
83             const int eCode , const int sequenceNumber);
84
85 };
86
87 #endif /* VIRTUALREPRESENTATION_H_ */