1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef SOFTSENSORRESOURCE_H_
22 #define SOFTSENSORRESOURCE_H_
24 #include "BundleResource.h"
32 * @class SoftSensorResource
33 * @brief This class represents bundle resource for Soft Sensor
34 * to be registered in the container and make resource server
37 class SoftSensorResource: public BundleResource
41 * Constructor for SoftSensorResource
46 * Virtual destructor for SoftSensorResource
48 virtual ~SoftSensorResource();
51 * Initialize input and output attributes for the resource
55 virtual void initAttributes();
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.
65 * @return Value of all attributes
67 virtual RCSResourceAttributes handleGetAttributesRequest() = 0;
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.
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.
78 * The implementor of the function can decide weather to notify OIC clients
79 * about the changed state or not.
81 * @param attrs Attributes to set
85 virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs) = 0;
88 * SoftSensor logic. Has to be provided by the soft sensor developer.
89 * This function will be executed if an input attribute is updated.
93 virtual void executeLogic() = 0;
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.
101 * @param attributeName Attribute key of input data
103 * @param values Vector of input data value
107 virtual void onUpdatedInputResource(const std::string attributeName,
108 std::vector<RCSResourceAttributes::Value> values) = 0;
112 std::list<std::string> m_inputList;