Update to OICSensorboard example
[platform/upstream/iotivity.git] / examples / OICSensorBoard / client.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation.
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 CLIENT_H_
22 #define CLIENT_H_
23
24 #include <string>
25 #include <iostream>
26 #include <memory>
27 #include "ocstack.h"
28 #include "OCApi.h"
29 #include "OCPlatform.h"
30 #include "OCResource.h"
31
32 using namespace std;
33 using namespace OC;
34
35 class LED
36 {
37     shared_ptr<OCResource> m_resourceHandle;
38     OCRepresentation m_ledRepresentation;
39     GetCallback m_GETCallback;
40     PutCallback m_PUTCallback;
41     void onGet(const HeaderOptions&, const OCRepresentation&, int);
42     void onPut(const HeaderOptions&, const OCRepresentation&, int);
43 public:
44     void get();
45     void put(int);
46     LED(shared_ptr<OCResource> Resource);
47     virtual ~LED();
48 };
49
50 class TemperatureSensor
51 {
52     shared_ptr<OCResource> m_resourceHandle;
53     OCRepresentation m_temperatureRepresentation;
54     GetCallback m_GETCallback;
55     ObserveCallback m_OBSERVECallback;
56     bool m_isObserved;
57     void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, int eCode,
58                    int sequenceNumber);
59     void onGet(const HeaderOptions&, const OCRepresentation&, int);
60 public:
61     void get();
62     void startObserve();
63     void stopObserve();
64     TemperatureSensor(shared_ptr<OCResource> Resource);
65     virtual ~TemperatureSensor();
66 };
67
68 class AmbientLight
69 {
70     shared_ptr<OCResource> m_resourceHandle;
71     OCRepresentation m_ledRepresentation;
72     GetCallback m_GETCallback;
73     ObserveCallback m_OBSERVECallback;
74     bool m_isObserved;
75     void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, int eCode,
76                    int sequenceNumber);
77     void onGet(const HeaderOptions&, const OCRepresentation&, int);
78 public:
79     void get();
80     void startObserve();
81     void stopObserve();
82     AmbientLight(shared_ptr<OCResource> Resource);
83     virtual ~AmbientLight();
84 };
85
86 class IoTClient
87 {
88     shared_ptr<TemperatureSensor> m_temperatureSensor;
89     shared_ptr<AmbientLight> m_ambientLightSensor;
90     shared_ptr<LED> m_platformLED;
91     shared_ptr<PlatformConfig> m_platformConfig;
92     FindCallback m_resourceDiscoveryCallback;
93     void initializePlatform();
94     void discoveredResource(shared_ptr<OCResource>);
95 public:
96     shared_ptr<TemperatureSensor> getTemperatureSensor();
97     shared_ptr<AmbientLight> getAmbientLightSensor();
98     shared_ptr<LED> getPlatformLED();
99     void findResource();
100     IoTClient();
101     virtual ~IoTClient();
102     static void DisplayMenu();
103 };
104
105 #endif /* CLIENT_H_ */