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 * @param key Name of attribute to get
68 * @return Value of all attributes
70 virtual RCSResourceAttributes &handleGetAttributesRequest() = 0;
73 * This function should be implemented by the according bundle resource
74 * and execute the according business logic (e.g., light switch or sensor resource)
75 * and write either on soft sensor values or external bridged devices.
77 * The call of this method could for example trigger a HTTP PUT request on
78 * an external APIs. This method is responsible to update the resource internal
79 * data and call the setAttribute method.
81 * The implementor of the function can decide weather to notify OIC clients
82 * about the changed state or not.
84 * @param key Name of attribute to set
86 * @param attrs Attributes to set
90 virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs) = 0;
93 * SoftSensor logic. Has to be provided by the soft sensor developer.
94 * This function will be executed if an input attribute is updated.
98 virtual void executeLogic() = 0;
101 * Callback from the client module in the container.
102 * This function will be called if input data from remote resources are updated.
103 * SoftSensor resource can get a vector of input data from multiple input resources
104 * which have attributeName that softsensor needs to execute its logic.
106 * @param attributeName Attribute key of input data
108 * @param values Vector of input data value
112 virtual void onUpdatedInputResource(const std::string attributeName,
113 std::vector<RCSResourceAttributes::Value> values) = 0;
117 std::list<std::string> m_inputList;