change location of resource container directory
[platform/upstream/iotivity.git] / service / resource-container / examples / DiscomfortIndexSensorBundle / src / inputSensors / THSensorApp / include / ThingResourceServer.h
1 //******************************************************************
2 //
3 // Copyright 2015 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 THINGRESOURCESERVER_H_
22 #define THINGRESOURCESERVER_H_
23
24 #include <functional>
25 #include <pthread.h>
26 #include "OCPlatform.h"
27 #include "OCApi.h"
28
29 #include <string>
30 #include <cstdlib>
31
32 #define COAP_IP                 "0.0.0.0"
33 #define COAP_PORT               0
34 #define COAP_MODE               OC::ModeType::Server
35 #define COAP_SRVTYPE            OC::ServiceType::InProc
36
37 #define RESOURCE_TYPE_NAME_TEMP          "oic.r.temperature"
38 #define RESOURCE_TYPE_NAME_HUMID          "oic.r.humidity"
39
40 // Forward declaring the entityHandler
41
42 class TemphumidResource
43 {
44     public:
45         /// Access this property from a TB client
46         int m_humid;
47         int m_temp;
48         std::string m_resourceUri;
49         std::vector<std::string> m_resourceTypes;
50         std::vector<std::string> m_resourceInterfaces;
51         OCResourceHandle m_resourceHandle;
52         OC::OCRepresentation m_resourceRep;
53         OC::ObservationIds m_interestedObservers;
54
55     public:
56         TemphumidResource() :
57             m_humid(0), m_temp(0), m_resourceHandle(0)
58         {
59             m_resourceUri = "/Thing_TempHumSensor";
60             m_resourceTypes.push_back(RESOURCE_TYPE_NAME_TEMP);
61             m_resourceTypes.push_back(RESOURCE_TYPE_NAME_HUMID);
62             m_resourceInterfaces.push_back(OC::DEFAULT_INTERFACE);
63
64             printf("Running thing as %s\n", m_resourceUri.c_str());
65             m_resourceRep.setUri(m_resourceUri);
66         }
67
68         ~TemphumidResource()
69         {
70         }
71
72         void registerResource();
73
74         OCResourceHandle getHandle();
75
76         void setResourceRepresentation(OC::OCRepresentation &rep);
77
78         OC::OCRepresentation getResourceRepresentation();
79 };
80
81 #endif /* THINGRESOURCESERVER_H_ */