1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "SampleBundle.h"
22 #include "DiscomfortIndexSensorResource.h"
28 SampleBundle::SampleBundle()
32 SampleBundle::~SampleBundle()
36 void SampleBundle::activateBundle(ResourceContainerBundleAPI *resourceContainer,
39 std::cout << "SampleBundle::activateBundle called" << std::endl;
41 m_pResourceContainer = resourceContainer;
42 m_bundleId = bundleId;
44 vector<Configuration::resourceInfo> resourceConfig;
46 resourceContainer->getResourceConfiguration(m_bundleId, &resourceConfig);
48 for (vector<Configuration::resourceInfo>::iterator itor = resourceConfig.begin();
49 itor != resourceConfig.end(); itor++)
51 createResource(*itor);
55 void SampleBundle::deactivateBundle()
57 std::cout << "SampleBundle::deactivateBundle called" << std::endl;
59 for (std::vector<BundleResource *>::iterator itor = m_vecResources.begin();
60 itor != m_vecResources.end(); itor++)
62 destroyResource(*itor);
66 // TODO : has to be updated for setting the info
67 void SampleBundle::createResource(Configuration::resourceInfo resourceInfo)
69 std::cout << "SampleBundle::createResource called" << std::endl;
71 DiscomfortIndexSensorResource *newResource = new DiscomfortIndexSensorResource();
72 newResource->setResourceInfo(resourceInfo);
74 m_pResourceContainer->registerResource(newResource);
76 m_vecResources.push_back(newResource);
79 void SampleBundle::destroyResource(BundleResource *resource)
81 std::cout << "SampleBundle::destroyResource called" << std::endl;
83 std::vector <BundleResource *>::iterator itor;
85 itor = std::find(m_vecResources.begin(), m_vecResources.end(), resource);
87 if (itor != m_vecResources.end())
88 m_vecResources.erase(itor);
93 m_pResourceContainer->unregisterResource(resource);
96 extern "C" void externalActivateBundle(ResourceContainerBundleAPI *resourceContainer,
99 bundle = new SampleBundle();
100 bundle->activateBundle(resourceContainer, bundleId);
103 extern "C" void externalDeactivateBundle()
107 bundle->deactivateBundle();