Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / resourceContainer / src / BundleResource.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 "BundleResource.h"
22 #include "Configuration.h"
23 #include <list>
24 #include <string.h>
25
26 namespace OIC
27 {
28     namespace Service
29     {
30         BundleResource::BundleResource()
31         {
32             m_pNotiReceiver = nullptr;
33         }
34
35         BundleResource::~BundleResource()
36         {
37             m_pNotiReceiver = nullptr;
38         }
39
40         void BundleResource::registerObserver(NotificationReceiver *pNotiReceiver)
41         {
42             m_pNotiReceiver = pNotiReceiver;
43         }
44
45         std::list< string > BundleResource::getAttributeNames()
46         {
47             std::list< string > ret;
48             for (RCSResourceAttributes::iterator it = m_resourceAttributes.begin();
49                  it != m_resourceAttributes.end(); ++it)
50             {
51                 ret.push_back(it->key());
52             }
53             return ret;
54         }
55
56         RCSResourceAttributes &BundleResource::getAttributes()
57         {
58             return m_resourceAttributes;
59         }
60
61         void BundleResource::setAttribute(std::string key, RCSResourceAttributes::Value &&value)
62         {
63             m_resourceAttributes[key] = value;
64         }
65
66         RCSResourceAttributes::Value BundleResource::getAttribute(const std::string &key)
67         {
68             cout << "Bundle resource get attribute " << m_resourceAttributes.at(key).toString() << "|" << endl;
69             return m_resourceAttributes.at(key);
70         }
71
72     }
73 }