Mistake on this page? Email us
m2mendpoint.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_ENDPOINT_H
17 #define M2M_ENDPOINT_H
18 
19 #include "mbed-client/m2mvector.h"
20 #include "mbed-client/m2mbase.h"
21 #include "mbed-client/m2mobject.h"
22 #include "mbed-client/m2mstring.h"
23 
31 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION
32 
33 //FORWARD DECLARATION
35 
36 
37 class M2MEndpoint : public M2MBase
38 {
39 
40 friend class M2MInterfaceFactory;
41 friend class M2MNsdlInterface;
42 friend class TestFactory;
43 friend class Test_M2MObject;
44 
45 protected :
46 
54  M2MEndpoint(const String &object_name,
55  char *path);
56 
57  // Prevents the use of default constructor.
58  M2MEndpoint();
59 
60  // Prevents the use of assignment operator.
61  M2MEndpoint& operator=( const M2MEndpoint& /*other*/ );
62 
63  // Prevents the use of copy constructor.
64  M2MEndpoint( const M2MEndpoint& /*other*/ );
65 
66  /*
67  * \brief Data has been changed and it needs to be updated to Device Management.
68  */
69  virtual void set_changed();
70 
71  /*
72  * \brief You can clear the flag the when the data has been updated into Device Management.
73  */
74  void clear_changed();
75 
76  /*
77  * \brief Returns current changed status.
78  */
79  bool get_changed() const;
80 
81 
82 public:
83 
87  virtual ~M2MEndpoint();
88 
94  M2MObject* create_object(const String &name);
95 
101  bool remove_object(const String &name);
102 
108  M2MObject* object(const String &name) const;
109 
114  const M2MObjectList& objects() const;
115 
120  uint16_t object_count() const;
121 
127 
132  virtual void set_observation_handler(M2MObservationHandler *handler);
133 
138  virtual void add_observation_level(M2MBase::Observation observation_level);
139 
144  virtual void remove_observation_level(M2MBase::Observation observation_level);
145 
154  virtual sn_coap_hdr_s* handle_get_request(nsdl_s *nsdl,
155  sn_coap_hdr_s *received_coap_header,
156  M2MObservationHandler *observation_handler = NULL);
157 
167  virtual sn_coap_hdr_s* handle_put_request(nsdl_s *nsdl,
168  sn_coap_hdr_s *received_coap_header,
169  M2MObservationHandler *observation_handler,
170  bool &execute_value_updated);
171 
181  virtual sn_coap_hdr_s* handle_post_request(nsdl_s *nsdl,
182  sn_coap_hdr_s *received_coap_header,
183  M2MObservationHandler *observation_handler,
184  bool &execute_value_updated,
185  sn_nsdl_addr_s *address = NULL);
186 
191  void set_context(void *ctx);
192 
198  void* get_context() const;
199 
203  virtual void set_deleted();
204 
209  virtual bool is_deleted();
210 
211  private:
212 
213  M2MObjectList _object_list; // owned
214  M2MObservationHandler *_observation_handler; // Not owned
215  void *_ctx; // user defined context
216  bool _changed; // True if modifications have been done to this endpoint since last registration update.
217  // False otherwise.
218  bool _deleted; // True if this M2MEndpoint is deleted, false otherwise.
219 
220 friend class Test_M2MEndpoint;
221 friend class Test_M2MInterfaceImpl;
222 friend class Test_M2MNsdlInterface;
223 friend class Test_M2MTLVSerializer;
224 friend class Test_M2MTLVDeserializer;
225 friend class Test_M2MDevice;
226 friend class Test_M2MFirmware;
227 friend class Test_M2MBase;
228 friend class Test_M2MResource;
229 friend class Test_M2MSecurity;
230 friend class Test_M2MServer;
231 friend class Test_M2MResourceInstance;
232 };
233 
234 #endif // MBED_CLOUD_CLIENT_EDGE_EXTENSION
235 
236 #endif // M2M_ENDPOINT_H
The base class for Client Objects.
Definition: m2mobject.h:39
Definition: m2mobservationhandler.h:31
virtual void set_changed()
The data has changed and it needs to be updated into Device Management. Current implementation mainta...
The base class based on which all LwM2M object models can be created.
Definition: m2mbase.h:63
M2MObject. This class is the base class for the mbed Client Objects.
Observation
Enum to define observation level.
Definition: m2mbase.h:83
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.
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.
virtual void set_observation_handler(M2MObservationHandler *handler)=0
Sets the observation handler.
Definition: m2mstring.h:33
M2MBase. This class is the base class based on which all LwM2M object models can be created...
A simple C++ Vector class, used as replacement for std::vector.
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.
Definition: m2mvector.h:30
A simple C++ string class, used as replacement for std::string.
virtual void remove_observation_level(M2MBase::Observation observation_level)
Removes the observation level for the object.
virtual void add_observation_level(M2MBase::Observation observation_level)
Adds the observation level for the object.
Definition: m2minterfacefactory.h:36
virtual M2MObservationHandler * observation_handler() const =0
Returns the Observation Handler object.