IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BundleResource.h
Go to the documentation of this file.
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 BUNDLERESOURCE_H_
22 #define BUNDLERESOURCE_H_
23 
24 #include <list>
25 #include <string>
26 #include <map>
27 #include <vector>
28 #include <memory>
29 #include <mutex>
30 
31 
32 #include "NotificationReceiver.h"
33 #include "RCSResourceAttributes.h"
34 #include "RCSRequest.h"
35 
36 namespace OIC
37 {
38  namespace Service
39  {
40 
48  {
49  public:
50  typedef std::shared_ptr< BundleResource > Ptr;
51 
56 
60  virtual ~BundleResource();
61 
67  std::list<std::string> getAttributeNames();
68 
74  virtual void initAttributes() = 0;
75 
85  void registerObserver(NotificationReceiver* pNotiReceiver);
86 
93 
101  void setAttributes(const RCSResourceAttributes &attrs);
102 
103  void setAttributes(const RCSResourceAttributes &attrs, bool notify);
104 
112  RCSResourceAttributes::Value getAttribute(const std::string &key);
113 
125  void setAttribute(const std::string &key, RCSResourceAttributes::Value &&value,
126  bool notify);
127 
139  void setAttribute(const std::string &key, RCSResourceAttributes::Value &value,
140  bool notify);
141 
151  void setAttribute(const std::string &key, RCSResourceAttributes::Value &&value);
152 
162  void setAttribute(const std::string &key, RCSResourceAttributes::Value &value);
163 
177  std::map< std::string, std::string > &queryParams) = 0;
178 
196  virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
197  const std::map< std::string, std::string > &queryParams) = 0;
198  private:
199 
200  void sendNotification(NotificationReceiver *notficiationRecevier, std::string uri);
201 
202  public:
203  std::string m_bundleId;
205  std::map< std::string,
206  std::vector< std::map< std::string, std::string > > > m_mapResourceProperty;
207 
208  private:
209  NotificationReceiver* m_pNotiReceiver;
210  RCSResourceAttributes m_resourceAttributes;
211  std::mutex m_resourceAttributes_mutex;
212  };
213  }
214 }
215 
216 #endif
virtual void initAttributes()=0
Initialize attributes of the resource.
std::string m_uri
Definition: BundleResource.h:204
void setAttributes(const RCSResourceAttributes &attrs)
Set attributes of the resource.
std::shared_ptr< BundleResource > Ptr
Definition: BundleResource.h:50
This class represents Notification Receiver to get notification from bundle resources if there's any ...
Definition: NotificationReceiver.h:37
This class represents Basic bundle resource template to be registered in the container and make resou...
Definition: BundleResource.h:47
virtual ~BundleResource()
Virtual destructor for BundleResource.
const RCSResourceAttributes getAttributes()
Return all attributes of the resource.
std::string m_bundleId
Definition: BundleResource.h:203
This file contains the declaration of classes and its members related to RCSResourceAttributes.
This file contains the declaration of classes and its members related to RCSRequest.
std::string m_name
Definition: BundleResource.h:204
std::list< std::string > getAttributeNames()
Return the list of attribute names of the resource.
Value holds a value among various types at a time.
Definition: RCSResourceAttributes.h:432
virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs, const std::map< std::string, std::string > &queryParams)=0
This function should be implemented by the according bundle resource and execute the according busine...
virtual RCSResourceAttributes handleGetAttributesRequest(const std::map< std::string, std::string > &queryParams)=0
This function should be implemented by the according bundle resource and execute the according busine...
RCSResourceAttributes::Value getAttribute(const std::string &key)
Return the value of an attribute.
This represents the attributes for a resource.
Definition: RCSResourceAttributes.h:195
std::string m_interface
Definition: BundleResource.h:204
std::map< std::string, std::vector< std::map< std::string, std::string > > > m_mapResourceProperty
Definition: BundleResource.h:206
void setAttribute(const std::string &key, RCSResourceAttributes::Value &&value, bool notify)
Sets the value of an attribute.
std::string m_resourceType
Definition: BundleResource.h:204
void registerObserver(NotificationReceiver *pNotiReceiver)
Register notification receiver(resource container) to notify for the changes of attributes.
BundleResource()
Constructor for BundleResource.
std::string m_address
Definition: BundleResource.h:204