Mistake on this page? Email us
m2mserver.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_SERVER_H
17 #define M2M_SERVER_H
18 
19 #include "mbed-client/m2mobject.h"
20 
21 // FORWARD DECLARATION
22 class M2MResource;
23 
31 class M2MServer : public M2MObject
32 {
33 
34 friend class M2MInterfaceFactory;
35 friend class M2MNsdlInterface;
36 friend class M2MInterfaceImpl;
37 
38 public:
39 
44  typedef enum {
45  ShortServerID,
46  Lifetime,
47  DefaultMinPeriod,
48  DefaultMaxPeriod,
49  Disable,
50  DisableTimeout,
51  NotificationStorage,
52  Binding,
53  RegistrationUpdate
55 
56 private:
57 
61  M2MServer();
62 
63 
64  // Prevents the use of assignment operator.
65  M2MServer& operator=( const M2MServer& /*other*/ );
66 
67  // Prevents the use of copy constructor
68  M2MServer( const M2MServer& /*other*/ );
69 
70 public:
71 
75  virtual ~M2MServer();
76 
85  M2MResource* create_resource(ServerResource resource, uint32_t value);
86 
93  M2MResource* create_resource(ServerResource resource);
94 
101  bool delete_resource(ServerResource rescource);
102 
106  void delete_resources();
107 
115  bool set_resource_value(ServerResource resource,
116  const String &value);
117 
126  bool set_resource_value(ServerResource resource,
127  uint32_t value);
134  String resource_value_string(ServerResource resource) const;
135 
143  uint32_t resource_value_int(ServerResource resource) const;
144 
150  bool is_resource_present(ServerResource resource)const;
151 
156  uint16_t total_resource_count()const;
157 
158 private:
159 
160  M2MResource* get_resource(ServerResource res) const;
161 
162 
163 private:
164 
165  M2MObjectInstance* _server_instance;
166 
167  friend class Test_M2MServer;
168  friend class Test_M2MNsdlInterface;
169 };
170 
171 #endif // M2M_SERVER_H
Definition: m2mobject.h:35
Definition: m2mserver.h:31
M2MResource * create_resource(ServerResource resource, uint32_t value)
Creates a new resource for a given resource enum.
uint16_t total_resource_count() const
Returns the total number of resources for the server object.
header M2MObject
Definition: m2mobjectinstance.h:42
void delete_resources()
Deletes all optional resources.
bool delete_resource(ServerResource rescource)
Deletes the resource with the given resource enum. Mandatory resources cannot be deleted.
String resource_value_string(ServerResource resource) const
Returns the value of the given resource enum, in string format.
uint32_t resource_value_int(ServerResource resource) const
Returns the value of a given resource name, in integer format.
bool set_resource_value(ServerResource resource, const String &value)
Sets the value of a given resource enum.
ServerResource
Am enum defining all resources associated with a Server Object in the LWM2M framework.
Definition: m2mserver.h:44
bool is_resource_present(ServerResource resource) const
Returns whether the resource instance with the given resource enum exists or not. ...
Definition: m2mresource.h:38
Definition: m2minterfacefactory.h:36
virtual ~M2MServer()
Destructor.