5c713fb4a467bf807a77292a86f827e816ef5b2a
[platform/upstream/iotivity.git] / service / resource-container / bundle-api / include / ResourceContainerBundleAPI.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 /**
22 * @file
23 *
24 * This file contains the resource container Bundle APIs provided
25 *     to the resource bundle developers.
26 */
27
28 #ifndef RESOURCECONTAINERBUNDLEAPI_H_
29 #define RESOURCECONTAINERBUNDLEAPI_H_
30
31 #include "Configuration.h"
32 #include "NotificationReceiver.h"
33 #include "BundleResource.h"
34
35 using namespace OIC::Service;
36
37 namespace OIC
38 {
39     namespace Service
40     {
41
42         /**
43         * @class   ResourceContainerBundleAPI
44         * @brief   This class provides APIs for retrieving bundle and resource configuration
45         *              and registering/unregistering resources.
46         *
47         */
48         class ResourceContainerBundleAPI: public NotificationReceiver
49         {
50             public:
51                 /**
52                 * Register bundle resource in the container
53                 *   and register resource server for bundle resource
54                 *
55                 * @param resource bundle resource to register
56                 *
57                 * @return int
58                 *       0        in case of an success
59                 *       -EEXIST  when the resource already exists and was not registered
60                 *       -EINVAL  when it was not possible to create such a resource
61                 */
62                 virtual int registerResource(BundleResource::Ptr resource) = 0;
63
64                 /**
65                 * Unregister bundle resource from the container
66                 *   and unregister resource server
67                 *
68                 * @param resource Bundle resource to unregister
69                 *
70                 * @return void
71                 */
72                 virtual void unregisterResource(BundleResource::Ptr resource) = 0;
73
74                 /**
75                 * Get Configuration data of certain bundle
76                 *
77                 * @param [in] bundleId Bundle id to get configuration data
78                 *
79                 * @param [out] configOutput Returned configuration data of bundle
80                 *
81                 * @return void
82                 */
83                 virtual void getBundleConfiguration(const std::string &bundleId, configInfo *configOutput) = 0;
84
85                 /**
86                 * Get the list of Configuration data of resources that certain bundle has
87                 *
88                 * @param [in] bundleId Bundle id to get configuration data
89                 *
90                 * @param [out] configOutput Returned vector of resource configuration data
91                 *
92                 * @return void
93                 */
94                 virtual void getResourceConfiguration(const std::string &bundleId,
95                                                       std::vector< resourceInfo > *configOutput) = 0;
96
97                 /**
98                 * API for getting an instance of ResourceContainerBundleAPI
99                 *
100                 * @return ResourceContainerBundleAPI * Return the object pointer of ResourceContainerBundleAPI
101                 */
102                 static ResourceContainerBundleAPI *getInstance();
103
104             protected:
105                 ResourceContainerBundleAPI();
106                 virtual ~ResourceContainerBundleAPI();
107
108                 ResourceContainerBundleAPI(const ResourceContainerBundleAPI &) = delete;
109                 ResourceContainerBundleAPI(ResourceContainerBundleAPI &&) = delete;
110                 ResourceContainerBundleAPI &operator=(const ResourceContainerBundleAPI &) const = delete;
111                 ResourceContainerBundleAPI &operator=(ResourceContainerBundleAPI &&) const = delete;
112         };
113     }
114 }
115
116 #endif