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 
37 public:
38 
43  typedef enum {
44  ShortServerID,
45  Lifetime,
46  DefaultMinPeriod,
47  DefaultMaxPeriod,
48  Disable,
49  DisableTimeout,
50  NotificationStorage,
51  Binding,
52  RegistrationUpdate
54 
55 private:
56 
60  M2MServer();
61 
62 
63  // Prevents the use of assignment operator.
64  M2MServer& operator=( const M2MServer& /*other*/ );
65 
66  // Prevents the use of copy constructor
67  M2MServer( const M2MServer& /*other*/ );
68 
69 public:
70 
74  virtual ~M2MServer();
75 
84  M2MResource* create_resource(ServerResource resource, uint32_t value);
85 
92  M2MResource* create_resource(ServerResource resource);
93 
100  bool delete_resource(ServerResource rescource);
101 
109  bool set_resource_value(ServerResource resource,
110  const String &value);
111 
120  bool set_resource_value(ServerResource resource,
121  uint32_t value);
128  String resource_value_string(ServerResource resource) const;
129 
137  uint32_t resource_value_int(ServerResource resource) const;
138 
144  bool is_resource_present(ServerResource resource)const;
145 
150  uint16_t total_resource_count()const;
151 
152 private:
153 
154  M2MResource* get_resource(ServerResource res) const;
155 
156 
157 private:
158 
159  M2MObjectInstance* _server_instance;
160 
161  friend class Test_M2MServer;
162  friend class Test_M2MNsdlInterface;
163 };
164 
165 #endif // M2M_SERVER_H
The base class for Client Objects.
Definition: m2mobject.h:39
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.
M2MObject. This class is the base class for the mbed Client Objects.
Definition: m2mobjectinstance.h:36
Definition: m2mstring.h:33
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:43
bool is_resource_present(ServerResource resource) const
Returns whether the resource instance with the given resource enum exists or not. ...
The base class for Client Resources.
Definition: m2mresource.h:40
Definition: m2minterfacefactory.h:36
virtual ~M2MServer()
Destructor.