Imported Upstream version 1.0.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                 * 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                 * @return Value of all attributes
69                 */
70                 virtual RCSResourceAttributes &handleGetAttributesRequest() = 0;
71
72                 /**
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.
76                 *
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.
80                 *
81                 * The implementor of the function can decide weather to notify OIC clients
82                 * about the changed state or not.
83                 *
84                 * @param attrs Attributes to set
85                 *
86                 * @return void
87                 */
88                 virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs) = 0;
89         };
90     }
91 }
92
93 #endif