Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / resource-container / src / BundleInfoInternal.cpp
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 #include "BundleInfoInternal.h"
22
23 namespace OIC
24 {
25     namespace Service
26     {
27
28         BundleInfoInternal::BundleInfoInternal()
29         {
30             m_activator = nullptr;
31             m_deactivator = nullptr;
32             m_resourceCreator = nullptr;
33             m_resourceDestroyer = nullptr;
34             m_bundleHandle = nullptr;
35             m_so_bundle = nullptr;
36
37             m_loaded = false;
38             m_activated = false;
39             m_java_bundle = false;
40             m_id = 0;
41         }
42
43         BundleInfoInternal::~BundleInfoInternal()
44         {
45             m_activator = nullptr;
46             m_deactivator = nullptr;
47             m_resourceCreator = nullptr;
48             m_resourceDestroyer = nullptr;
49             m_bundleHandle = nullptr;
50         }
51
52         void BundleInfoInternal::setID(const std::string &id)
53         {
54             m_ID = id;
55         }
56
57         const std::string &BundleInfoInternal::getID()
58         {
59             return m_ID;
60         }
61
62         void BundleInfoInternal::setPath( const std::string &path)
63         {
64             m_path = path;
65         }
66         const std::string &BundleInfoInternal::getPath()
67         {
68             return m_path;
69         }
70
71         void BundleInfoInternal::setVersion( const std::string &version)
72         {
73             m_version = version;
74         }
75
76         const std::string &BundleInfoInternal::getVersion()
77         {
78             return m_version;
79         }
80
81         void BundleInfoInternal::setLoaded(bool loaded)
82         {
83             m_loaded = loaded;
84         }
85
86         bool BundleInfoInternal::isLoaded()
87         {
88             return m_loaded;
89         }
90
91         void BundleInfoInternal::setActivated(bool activated)
92         {
93             m_activated = activated;
94         }
95
96         bool BundleInfoInternal::isActivated()
97         {
98             return m_activated;
99         }
100
101         void BundleInfoInternal::setBundleActivator(activator_t *activator)
102         {
103             m_activator = activator;
104         }
105
106         activator_t *BundleInfoInternal::getBundleActivator()
107         {
108             return m_activator;
109         }
110
111         void BundleInfoInternal::setBundleDeactivator(deactivator_t *deactivator)
112         {
113             m_deactivator = deactivator;
114         }
115
116         deactivator_t *BundleInfoInternal::getBundleDeactivator()
117         {
118             return m_deactivator;
119         }
120
121         void BundleInfoInternal::setResourceCreator(resourceCreator_t *resourceCreator)
122         {
123             m_resourceCreator = resourceCreator;
124         }
125
126         resourceCreator_t *BundleInfoInternal::getResourceCreator()
127         {
128             return m_resourceCreator;
129         }
130
131         void BundleInfoInternal::setResourceDestroyer(resourceDestroyer_t *resourceDestroyer)
132         {
133             m_resourceDestroyer = resourceDestroyer;
134         }
135
136         resourceDestroyer_t *BundleInfoInternal::getResourceDestroyer()
137         {
138             return m_resourceDestroyer;
139         }
140
141         void BundleInfoInternal::setBundleHandle(void *handle)
142         {
143             m_bundleHandle = handle;
144         }
145
146         void *BundleInfoInternal::getBundleHandle()
147         {
148             return m_bundleHandle;
149         }
150
151         void BundleInfoInternal::setJavaBundle(bool javaBundle)
152         {
153             m_java_bundle = javaBundle;
154         }
155
156         bool BundleInfoInternal::getJavaBundle()
157         {
158             return m_java_bundle;
159         }
160
161         void BundleInfoInternal::setSoBundle(bool soBundle)
162         {
163             m_so_bundle = soBundle;
164         }
165
166         bool BundleInfoInternal::getSoBundle()
167         {
168             return m_so_bundle;
169         }
170
171         void BundleInfoInternal::setActivatorName( const std::string &activatorName)
172         {
173             m_activator_name = activatorName;
174         }
175
176         const std::string &BundleInfoInternal::getActivatorName()
177         {
178             return m_activator_name;
179         }
180
181         void BundleInfoInternal::setLibraryPath( const std::string &libpath)
182         {
183             m_library_path = libpath;
184         }
185
186         const std::string &BundleInfoInternal::getLibraryPath()
187         {
188             return m_library_path;
189         }
190
191 #if (JAVA_SUPPORT)
192         void BundleInfoInternal::setJavaBundleActivatorMethod(jmethodID javaBundleActivator)
193         {
194             m_java_activator = javaBundleActivator;
195         }
196
197         jmethodID BundleInfoInternal::getJavaBundleActivatorMethod()
198         {
199             return m_java_activator;
200         }
201
202         void BundleInfoInternal::setJavaBundleDeactivatorMethod(jmethodID javaBundleActivator)
203         {
204             m_java_deactivator = javaBundleActivator;
205         }
206
207         jmethodID BundleInfoInternal::getJavaBundleDeactivatorMethod()
208         {
209             return m_java_deactivator;
210         }
211
212         void BundleInfoInternal::setJavaBundleActivatorObject(jobject activator_object)
213         {
214             m_java_activator_object = activator_object;
215         }
216
217         jobject BundleInfoInternal::getJavaBundleActivatorObject()
218         {
219             return m_java_activator_object;
220         }
221 #endif
222
223         void BundleInfoInternal::setBundleInfo(shared_ptr<RCSBundleInfo> bundleInfo)
224         {
225             shared_ptr<BundleInfoInternal> source =
226                                 std::static_pointer_cast<BundleInfoInternal>(bundleInfo);
227
228             m_ID = source->getID();
229             m_path = source->getPath();
230             m_version = source->getVersion();
231             m_loaded = source->isLoaded();
232             m_activated = source->isActivated();
233             m_java_bundle = source->getJavaBundle();
234             m_activator = source->getBundleActivator();
235             m_bundleHandle = source->getBundleHandle();
236             m_activator_name = source->getActivatorName();
237         }
238     }
239 }