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 
29 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION
30 
31 //FORWARD DECLARATION
32 typedef Vector<M2MObject *> M2MObjectList;
33 
34 
39 class M2MEndpoint : public M2MBase
40 {
41 
42 friend class M2MInterfaceFactory;
43 friend class M2MNsdlInterface;
44 friend class TestFactory;
45 friend class Test_M2MObject;
46 
47 protected :
48 
56  M2MEndpoint(const String &object_name,
57  char *path);
58 
59  // Prevents the use of default constructor.
60  M2MEndpoint();
61 
62  // Prevents the use of assignment operator.
63  M2MEndpoint& operator=( const M2MEndpoint& /*other*/ );
64 
65  // Prevents the use of copy constructor.
66  M2MEndpoint( const M2MEndpoint& /*other*/ );
67 
68  /*
69  * \brief Data has been changed and it needs to be updated to Device Management.
70  */
71  virtual void set_changed();
72 
73  /*
74  * \brief You can clear the flag the when the data has been updated into Device Management.
75  */
76  void clear_changed();
77 
78  /*
79  * \brief Returns current changed status.
80  */
81  bool get_changed() const;
82 
83 
84 public:
85 
89  virtual ~M2MEndpoint();
90 
96  M2MObject* create_object(const String &name);
97 
103  bool remove_object(const String &name);
104 
110  M2MObject* object(const String &name) const;
111 
116  const M2MObjectList& objects() const;
117 
122  uint16_t object_count() const;
123 
129 
134  virtual void set_observation_handler(M2MObservationHandler *handler);
135 
140  virtual void add_observation_level(M2MBase::Observation observation_level);
141 
146  virtual void remove_observation_level(M2MBase::Observation observation_level);
147 
156  virtual sn_coap_hdr_s* handle_get_request(nsdl_s *nsdl,
157  sn_coap_hdr_s *received_coap_header,
158  M2MObservationHandler *observation_handler = NULL);
159 
169  virtual sn_coap_hdr_s* handle_put_request(nsdl_s *nsdl,
170  sn_coap_hdr_s *received_coap_header,
171  M2MObservationHandler *observation_handler,
172  bool &execute_value_updated);
173 
183  virtual sn_coap_hdr_s* handle_post_request(nsdl_s *nsdl,
184  sn_coap_hdr_s *received_coap_header,
185  M2MObservationHandler *observation_handler,
186  bool &execute_value_updated,
187  sn_nsdl_addr_s *address = NULL);
188 
193  void set_context(void *ctx);
194 
200  void* get_context() const;
201 
205  virtual void set_deleted();
206 
211  virtual bool is_deleted();
212 
213  private:
214 
215  M2MObjectList _object_list; // owned
216  M2MObservationHandler *_observation_handler; // Not owned
217  void *_ctx; // user defined context
218  bool _changed; // True if modifications have been done to this endpoint since last registration update.
219  // False otherwise.
220  bool _deleted; // True if this M2MEndpoint is deleted, false otherwise.
221 
222 friend class Test_M2MEndpoint;
223 friend class Test_M2MInterfaceImpl;
224 friend class Test_M2MNsdlInterface;
225 friend class Test_M2MTLVSerializer;
226 friend class Test_M2MTLVDeserializer;
227 friend class Test_M2MDevice;
228 friend class Test_M2MBase;
229 friend class Test_M2MResource;
230 friend class Test_M2MSecurity;
231 friend class Test_M2MServer;
232 friend class Test_M2MResourceInstance;
233 };
234 
235 #endif // MBED_CLOUD_CLIENT_EDGE_EXTENSION
236 
237 #endif // M2M_ENDPOINT_H
Definition: m2mobject.h:35
Definition: m2mobservationhandler.h:30
virtual void set_changed()
The data has changed and it needs to be updated into Device Management. Current implementation mainta...
Definition: m2mbase.h:54
header M2MObject
Observation
Enum to define observation level.
Definition: m2mbase.h:74
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.
Header for M2MBase class.
header for m2m::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.
header for m2m::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.