change location of resource container directory
[platform/upstream/iotivity.git] / service / resource-container / examples / DiscomfortIndexSensorBundle / src / inputSensors / THSensorApp1 / include / ThingResourceServer1.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
41 class TemphumidResource
42 {
43     public:
44         /// Access this property from a TB client
45         int m_humid;
46         int m_temp;
47         std::string m_resourceUri;
48         std::vector<std::string> m_resourceTypes;
49         std::vector<std::string> m_resourceInterfaces;
50         OCResourceHandle m_resourceHandle;
51         OC::OCRepresentation m_resourceRep;
52         OC::ObservationIds m_interestedObservers;
53
54     public:
55         TemphumidResource() :
56             m_humid(0), m_temp(0), m_resourceHandle(0)
57         {
58             m_resourceUri = "/Thing_TempHumSensor1";
59             m_resourceTypes.push_back(RESOURCE_TYPE_NAME_TEMP);
60             m_resourceTypes.push_back(RESOURCE_TYPE_NAME_HUMID);
61             m_resourceInterfaces.push_back(OC::DEFAULT_INTERFACE);
62
63             printf("Running thing as %s\n", m_resourceUri.c_str());
64             m_resourceRep.setUri(m_resourceUri);
65         }
66
67         ~TemphumidResource()
68         {
69         }
70
71         void registerResource();
72
73         OCResourceHandle getHandle();
74
75         void setResourceRepresentation(OC::OCRepresentation &rep);
76
77         OC::OCRepresentation getResourceRepresentation();
78 };
79
80 #endif /* THINGRESOURCESERVER_H_ */