c420c27afff368453b40bfbd369778af92ccc5f5
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / resourceContainer / bundle-api / include / ProtocolBridgeResource.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 PROTOCOLBRIDGERESOURCE_H_
22 #define PROTOCOLBRIDGERESOURCE_H_
23
24 #include "BundleResource.h"
25 #include <map>
26 #include <string>
27
28 namespace OIC
29 {
30     namespace Service
31     {
32
33         /**
34         * @class    ProtocolBridgeResource
35         * @brief    This class represents bundle resource template for Protocol Bridge
36         *               to be registered in the container and make resource server
37         *
38         */
39         class ProtocolBridgeResource: public BundleResource
40         {
41             public:
42
43                 /**
44                 * Constructor for ProtocolBridgeResource
45                 */
46                 ProtocolBridgeResource();
47
48                 /**
49                 * Virtual destructor for ProtocolBridgeResource
50                 */
51                 virtual ~ProtocolBridgeResource();
52
53                 /**
54                 * Initialize attributes of the resource
55                 *
56                 * @return void
57                 */
58                 virtual void initAttributes() = 0;
59
60                 /**
61                 * This function should be implemented by the according bundle resource
62                 * and execute the according business logic (e.g., light switch or sensor resource)
63                 * to retrieve a sensor value. If a new sensor value is retrieved, the
64                 * setAttribute data should be called to update the value.
65                 * The implementor of the function can decide weather to notify OIC clients
66                 * about the changed state or not.
67                 *
68                 * @param key Name of attribute to get
69                 *
70                 *
71                 * @return Value of all attributes
72                 */
73                 virtual RCSResourceAttributes &handleGetAttributesRequest() = 0;
74
75                 /**
76                 * This function should be implemented by the according bundle resource
77                 * and execute the according business logic (e.g., light switch or sensor resource)
78                 * and write either on soft sensor values or external bridged devices.
79                 *
80                 * The call of this method could for example trigger a HTTP PUT request on
81                 * an external APIs. This method is responsible to update the resource internal
82                 * data and call the setAttribute method.
83                 *
84                 * The implementor of the function can decide weather to notify OIC clients
85                 * about the changed state or not.
86                 *
87                 * @param key Name of attribute to set
88                 *
89                 * @param attrs Attributes to set
90                 *
91                 * @return void
92                 */
93                 virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs) = 0;
94         };
95     }
96 }
97
98 #endif