Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / resource-container / bundle-api / include / SoftSensorResource.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 SOFTSENSORRESOURCE_H_
22 #define SOFTSENSORRESOURCE_H_
23
24 #include "BundleResource.h"
25
26 namespace OIC
27 {
28     namespace Service
29     {
30
31         /**
32         * @class    SoftSensorResource
33         * @brief    This class represents bundle resource for Soft Sensor
34         *               to be registered in the container and make resource server
35         *
36         */
37         class SoftSensorResource: public BundleResource
38         {
39             public:
40                 /**
41                 * Constructor for SoftSensorResource
42                 */
43                 SoftSensorResource();
44
45                 /**
46                 * Virtual destructor for SoftSensorResource
47                 */
48                 virtual ~SoftSensorResource();
49
50                 /**
51                 * Initialize input and output attributes for the resource
52                 *
53                 * @return void
54                 */
55                 virtual void initAttributes();
56
57                 /**
58                 * This function should be implemented by the according bundle resource
59                 * and execute the according business logic (e.g., light switch or sensor resource)
60                 * to retrieve a sensor value. If a new sensor value is retrieved, the
61                 * setAttribute data should be called to update the value.
62                 * The implementor of the function can decide weather to notify OIC clients
63                 * about the changed state or not.
64                 *
65                 * @return Value of all attributes
66                 */
67                 virtual RCSResourceAttributes handleGetAttributesRequest() = 0;
68
69                 /**
70                 * This function should be implemented by the according bundle resource
71                 * and execute the according business logic (e.g., light switch or sensor resource)
72                 * and write either on soft sensor values or external bridged devices.
73                 *
74                 * The call of this method could for example trigger a HTTP PUT request on
75                 * an external APIs. This method is responsible to update the resource internal
76                 * data and call the setAttribute method.
77                 *
78                 * The implementor of the function can decide weather to notify OIC clients
79                 * about the changed state or not.
80                 *
81                 * @param attrs Attributes to set
82                 *
83                 * @return void
84                 */
85                 virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs) = 0;
86
87                 /**
88                 * SoftSensor logic. Has to be provided by the soft sensor developer.
89                 * This function will be executed if an input attribute is updated.
90                 *
91                 * @return void
92                 */
93                 virtual void executeLogic() = 0;
94
95                 /**
96                 * Callback from the client module in the container.
97                 * This function will be called if input data from remote resources are updated.
98                 * SoftSensor resource can get a vector of input data from multiple input resources
99                 *    which have attributeName that softsensor needs to execute its logic.
100                 *
101                 * @param attributeName Attribute key of input data
102                 *
103                 * @param values Vector of input data value
104                 *
105                 * @return void
106                 */
107                 virtual void onUpdatedInputResource(const std::string attributeName,
108                                                     std::vector<RCSResourceAttributes::Value> values) = 0;
109
110
111             public:
112                 std::list<std::string> m_inputList;
113         };
114     }
115 }
116
117 #endif