Imported Upstream version 1.2.0
[platform/upstream/iotivity.git] / service / resource-container / 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                 };
50
51                 /**
52                 * Virtual destructor for ProtocolBridgeResource
53                 */
54                 virtual ~ProtocolBridgeResource()
55                 {
56
57                 };
58
59                 /**
60                 * Initialize attributes of the resource
61                 *
62                 * @return void
63                 */
64                 virtual void initAttributes() = 0;
65
66                 /**
67                 * This function should be implemented by the according bundle resource
68                 * and execute the according business logic (e.g., light switch or sensor resource)
69                 * to retrieve a sensor value. If a new sensor value is retrieved, the
70                 * setAttribute data should be called to update the value.
71                 * The implementor of the function can decide weather to notify OIC clients
72                 * about the changed state or not.
73                 *
74                 * @param queryParams Request parameters
75                 *
76                 * @return Value of all attributes
77                 */
78                 virtual RCSResourceAttributes handleGetAttributesRequest(const
79                         std::map< std::string, std::string > &queryParams) = 0;
80
81                 /**
82                 * This function should be implemented by the according bundle resource
83                 * and execute the according business logic (e.g., light switch or sensor resource)
84                 * and write either on soft sensor values or external bridged devices.
85                 *
86                 * The call of this method could for example trigger a HTTP PUT request on
87                 * an external APIs. This method is responsible to update the resource internal
88                 * data and call the setAttribute method.
89                 *
90                 * The implementor of the function can decide weather to notify OIC clients
91                 * about the changed state or not.
92                 *
93                 * @param attrs Attributes to set
94                 * @param queryParams Request parameters
95                 *
96                 * @return void
97                 */
98                 virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
99                                                         const std::map< std::string, std::string > &queryParams) = 0;
100         };
101     }
102 }
103
104 #endif