Mistake on this page? Email us
m2mobject.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef M2M_OBJECT_H
17 #define M2M_OBJECT_H
18 
19 #include "mbed-client/m2mvector.h"
20 #include "mbed-client/m2mbase.h"
22 
23 //FORWARD DECLARATION
25 
26 class M2MEndpoint;
27 
39 class M2MObject : public M2MBase
40 {
41 
42 friend class M2MInterfaceFactory;
43 friend class M2MEndpoint;
44 friend class TestFactory;
45 
46 protected :
47 
55  M2MObject(const String &object_name,
56  char *path,
57  bool external_blockwise_store = false);
58 
59  // Prevents the use of default constructor.
60  M2MObject();
61 
62  // Prevents the use of assignment operator.
63  M2MObject& operator=( const M2MObject& /*other*/ );
64 
65  // Prevents the use of copy constructor.
66  M2MObject( const M2MObject& /*other*/ );
67 
72  M2MObject(const M2MBase::lwm2m_parameters_s* static_res);
73 
74 public:
75 
79  virtual ~M2MObject();
80 
87 
94 
100  bool remove_object_instance(uint16_t instance_id = 0);
101 
107  M2MObjectInstance* object_instance(uint16_t instance_id = 0) const;
108 
113  const M2MObjectInstanceList& instances() const;
114 
119  uint16_t instance_count() const;
120 
126 
131  virtual void set_observation_handler(M2MObservationHandler *handler);
132 
138 
143  virtual void remove_observation_level(M2MBase::Observation observation_level);
144 
153  virtual sn_coap_hdr_s* handle_get_request(nsdl_s *nsdl,
154  sn_coap_hdr_s *received_coap_header,
155  M2MObservationHandler *observation_handler = NULL);
156 
166  virtual sn_coap_hdr_s* handle_put_request(nsdl_s *nsdl,
167  sn_coap_hdr_s *received_coap_header,
168  M2MObservationHandler *observation_handler,
169  bool &execute_value_updated);
170 
180  virtual sn_coap_hdr_s* handle_post_request(nsdl_s *nsdl,
181  sn_coap_hdr_s *received_coap_header,
182  M2MObservationHandler *observation_handler,
183  bool &execute_value_updated,
184  sn_nsdl_addr_s *address = NULL);
185 
186  void notification_update(uint16_t obj_instance_id);
187 
188 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION
189  void set_endpoint(M2MEndpoint *endpoint);
190 
191  M2MEndpoint* get_endpoint() const;
192 #endif
193 
194 protected :
198  virtual M2MBase *get_parent() const;
199 
200 private:
201 
202  M2MObjectInstanceList _instance_list; // owned
203 
204  M2MObservationHandler *_observation_handler; // Not owned
205 
206 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION
207  M2MEndpoint *_endpoint; // Parent endpoint
208 #endif
209 
210 friend class Test_M2MObject;
211 friend class Test_M2MEndpoint;
212 friend class Test_M2MInterfaceImpl;
213 friend class Test_M2MInterfaceFactory;
214 friend class Test_M2MNsdlInterface;
215 friend class Test_M2MTLVSerializer;
216 friend class Test_M2MTLVDeserializer;
217 friend class Test_M2MDevice;
218 friend class Test_M2MFirmware;
219 friend class Test_M2MBase;
220 friend class Test_M2MObjectInstance;
221 friend class Test_M2MResource;
222 friend class Test_M2MSecurity;
223 friend class Test_M2MServer;
224 friend class Test_M2MResourceInstance;
225 };
226 
227 #endif // M2M_OBJECT_H
The base class for Client Objects.
Definition: m2mobject.h:39
Definition: m2mobservationhandler.h:31
virtual M2MBase * get_parent() const
Returns the owner object. Can return NULL if the object has no parent.
The base class based on which all LwM2M object models can be created.
Definition: m2mbase.h:63
virtual void set_observation_handler(M2MObservationHandler *handler)
Sets the observation handler.
virtual ~M2MObject()
Destructor.
Observation
Enum to define observation level.
Definition: m2mbase.h:83
virtual void add_observation_level(M2MBase::Observation observation_level)
Adds the observation level for the object.
M2MObjectInstance. This class is the instance class for mbed Client Objects. All defined LWM2M object...
Definition: m2mobjectinstance.h:36
LwM2M parameters.
Definition: m2mbase.h:210
const M2MObjectInstanceList & instances() const
Returns a list of object instances.
Definition: m2mstring.h:33
M2MBase. This class is the base class based on which all LwM2M object models can be created...
virtual sn_coap_hdr_s * handle_put_request(nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler, bool &execute_value_updated)
Handles PUT request for the registered objects.
A simple C++ Vector class, used as replacement for std::vector.
virtual M2MObservationHandler * observation_handler() const
Returns the Observation Handler object.
virtual sn_coap_hdr_s * handle_get_request(nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler=NULL)
Handles GET request for the registered objects.
M2MObjectInstance * create_object_instance(uint16_t instance_id=0)
Creates a new object instance for a given mbed Client Interface object. With this, the client can respond to server's GET methods with the provided value.
M2MBase::Observation observation_level() const
Returns the observation level of the object.
Definition: m2minterfacefactory.h:36
uint16_t instance_id() const
Returns the object's instance ID.
bool remove_object_instance(uint16_t instance_id=0)
Removes the object instance resource with the given instance id.
void execute_value_updated(const String &name)
Calls the function that is set in the "set_value_updated_function".
M2MObjectInstance * object_instance(uint16_t instance_id=0) const
Returns the object instance with the the given instance ID.
virtual void remove_observation_level(M2MBase::Observation observation_level)
Removes the observation level from the object.
uint16_t instance_count() const
Returns the total number of object instances-.
virtual sn_coap_hdr_s * handle_post_request(nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler, bool &execute_value_updated, sn_nsdl_addr_s *address=NULL)
Handles GET request for the registered objects.