Friendly LWM2M client
wpp::Object Class Referenceabstract

The Object class implements manipulation with Instance interface class and its inheritors. More...

#include <Object.h>

+ Inheritance diagram for wpp::Object:
+ Collaboration diagram for wpp::Object:

Public Member Functions

 Object (lwm2m_context_t &context)
 
 Object (lwm2m_context_t &context, const ObjectInfo &info)
 Constructs an Object instance. More...
 
virtual ~Object ()
 Destroys the Object instance. More...
 
OBJ_ID getObjectID () const
 Gets the object ID. More...
 
const ObjectInfogetObjectInfo () const
 Gets the object information. More...
 
lwm2m_object_t & getLwm2mObject ()
 Gets the lwm2m_object_t object. More...
 
lwm2m_context_t & getContext ()
 Return context that can be used by derived class. More...
 
WppClientgetClient ()
 Helpfull methods to get client instances. More...
 
WppRegistrygetRegistry ()
 Helpfull methods to get registry instances. More...
 
virtual InstancecreateInstance (ID_T instanceID=ID_T_MAX_VAL)=0
 Creates an instance of the object. More...
 
bool remove (ID_T instanceID)
 Removes an instance of the object. More...
 
void clear ()
 Clears the object. More...
 
Instanceinstance (ID_T instanceID=ID_T_MAX_VAL)
 Gets an instance of the object. More...
 
const std::vector< Instance * > & instances ()
 Gets all instances of the object. More...
 
size_t instanceCnt ()
 Gets the number of instances of the object. More...
 
bool isExist (ID_T instanceID)
 Checks if an instance exists. More...
 
- Public Member Functions inherited from wpp::ObjSubject
void opSubscribe (ObjOpObserver *observer)
 Subscribes an observer to receive notifications about object operations. More...
 
void opUnsubscribe (ObjOpObserver *observer)
 Unsubscribes an observer from receiving notifications about object operations. More...
 

Protected Member Functions

std::vector< Instance * >::iterator getInstIter (ID_T instanceID)
 Gets the iterator to the instance. More...
 
ID_T getFirstAvailableInstanceID ()
 Gets the first available instance ID. More...
 
- Protected Member Functions inherited from wpp::ObjSubject
void operationNotify (Object &obj, ID_T instanceId, ItemOp::TYPE type)
 Notifies observers about object operations. More...
 

Static Protected Member Functions

static uint8_t serverRead_clb (lwm2m_context_t *contextP, lwm2m_server_t *server, ID_T instanceId, int *numDataP, lwm2m_data_t **dataArrayP, lwm2m_object_t *objectP)
 The read callback function for the Lwm2m core. More...
 
static uint8_t serverWrite_clb (lwm2m_context_t *contextP, lwm2m_server_t *server, ID_T instanceId, int numData, lwm2m_data_t *dataArray, lwm2m_object_t *objectP, lwm2m_write_type_t writeType)
 The write callback function for the Lwm2m core. More...
 
static uint8_t serverExecute_clb (lwm2m_context_t *contextP, lwm2m_server_t *server, ID_T instanceId, ID_T resId, uint8_t *buffer, int length, lwm2m_object_t *objectP)
 The execute callback function for the Lwm2m core. More...
 
static uint8_t serverDiscover_clb (lwm2m_context_t *contextP, lwm2m_server_t *server, ID_T instanceId, int *numDataP, lwm2m_data_t **dataArrayP, lwm2m_object_t *objectP)
 The discover callback function for the Lwm2m core. More...
 
static uint8_t serverCreate_clb (lwm2m_context_t *contextP, lwm2m_server_t *server, ID_T instanceId, int numData, lwm2m_data_t *dataArray, lwm2m_object_t *objectP)
 The create callback function for the Lwm2m core. More...
 
static uint8_t serverDelete_clb (lwm2m_context_t *contextP, lwm2m_server_t *server, ID_T instanceId, lwm2m_object_t *objectP)
 The delete callback function for the Lwm2m core. More...
 

Protected Attributes

std::vector< Instance * > _instances
 
lwm2m_context_t & _context
 
lwm2m_object_t _lwm2m_object
 
ObjectInfo _objInfo
 

Detailed Description

The Object class implements manipulation with Instance interface class and its inheritors.

The main target of this class is to encapsulate operations like instance create and delete, binding instance callbacks to the core interface, to avoid multiple definitions of this mechanism in instance implementation classes.

Definition at line 32 of file Object.h.

Constructor & Destructor Documentation

◆ Object() [1/2]

wpp::Object::Object ( lwm2m_context_t &  context)

Default constructor.

Definition at line 6 of file Object.cpp.

◆ Object() [2/2]

wpp::Object::Object ( lwm2m_context_t &  context,
const ObjectInfo info 
)

Constructs an Object instance.

Parameters
contextThe lwm2m_context_t object.
infoThe ObjectInfo object.

Definition at line 8 of file Object.cpp.

+ Here is the call graph for this function:

◆ ~Object()

wpp::Object::~Object ( )
virtual

Destroys the Object instance.

Definition at line 32 of file Object.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void wpp::Object::clear ( )

Clears the object.

Definition at line 61 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createInstance()

virtual Instance* wpp::Object::createInstance ( ID_T  instanceID = ID_T_MAX_VAL)
pure virtual

Creates an instance of the object.

Parameters
instanceIDThe instance ID.
Returns
A pointer to the created Instance object.

Implemented in wpp::ObjectImpl< T >.

+ Here is the caller graph for this function:

◆ getClient()

WppClient & wpp::Object::getClient ( )

Helpfull methods to get client instances.

Definition at line 53 of file Object.cpp.

+ Here is the call graph for this function:

◆ getContext()

lwm2m_context_t & wpp::Object::getContext ( )

Return context that can be used by derived class.

Definition at line 49 of file Object.cpp.

+ Here is the caller graph for this function:

◆ getFirstAvailableInstanceID()

ID_T wpp::Object::getFirstAvailableInstanceID ( )
protected

Gets the first available instance ID.

Returns
The first available instance ID.

Definition at line 125 of file Object.cpp.

+ Here is the call graph for this function:

◆ getInstIter()

std::vector< Instance * >::iterator wpp::Object::getInstIter ( ID_T  instanceID)
protected

Gets the iterator to the instance.

Parameters
instanceIDThe instance ID.
Returns
The iterator to the instance.

Definition at line 120 of file Object.cpp.

+ Here is the caller graph for this function:

◆ getLwm2mObject()

lwm2m_object_t & wpp::Object::getLwm2mObject ( )

Gets the lwm2m_object_t object.

Returns
The lwm2m_object_t object.

Definition at line 41 of file Object.cpp.

◆ getObjectID()

OBJ_ID wpp::Object::getObjectID ( ) const

Gets the object ID.

Returns
The object ID.

Definition at line 37 of file Object.cpp.

+ Here is the caller graph for this function:

◆ getObjectInfo()

const ObjectInfo & wpp::Object::getObjectInfo ( ) const

Gets the object information.

Returns
The ObjectInfo object.

Definition at line 45 of file Object.cpp.

◆ getRegistry()

WppRegistry & wpp::Object::getRegistry ( )

Helpfull methods to get registry instances.

Definition at line 57 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instance()

Instance * wpp::Object::instance ( ID_T  instanceID = ID_T_MAX_VAL)

Gets an instance of the object.

Parameters
instanceIDThe instance ID. If not provided, the first available instance is returned.
Returns
A pointer to the Instance object or NULL.

Definition at line 102 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceCnt()

size_t wpp::Object::instanceCnt ( )

Gets the number of instances of the object.

Returns
The number of instances.

Definition at line 112 of file Object.cpp.

◆ instances()

const std::vector< Instance * > & wpp::Object::instances ( )

Gets all instances of the object.

Returns
A vector of pointers to the Instance objects.

Definition at line 108 of file Object.cpp.

◆ isExist()

bool wpp::Object::isExist ( ID_T  instanceID)

Checks if an instance exists.

Parameters
instanceIDThe instance ID.
Returns
True if the instance exists, false otherwise.

Definition at line 116 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

bool wpp::Object::remove ( ID_T  instanceID)

Removes an instance of the object.

Parameters
instanceIDThe instance ID.
Returns
True if the instance was successfully removed, false otherwise.

Definition at line 82 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverCreate_clb()

uint8_t wpp::Object::serverCreate_clb ( lwm2m_context_t *  contextP,
lwm2m_server_t *  server,
ID_T  instanceId,
int  numData,
lwm2m_data_t *  dataArray,
lwm2m_object_t *  objectP 
)
staticprotected

The create callback function for the Lwm2m core.

Parameters
contextPThe lwm2m_context_t object.
serverContains valid pointer when request retrieved from server or NULL if request initiated by core.
instanceIdThe instance ID.
numDataThe number of data.
dataArrayThe data array.
objectPThe lwm2m_object_t object.
Returns
The result of the create operation.

Definition at line 163 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverDelete_clb()

uint8_t wpp::Object::serverDelete_clb ( lwm2m_context_t *  contextP,
lwm2m_server_t *  server,
ID_T  instanceId,
lwm2m_object_t *  objectP 
)
staticprotected

The delete callback function for the Lwm2m core.

Parameters
contextPThe lwm2m_context_t object.
serverContains valid pointer when request retrieved from server or NULL if request initiated by core.
instanceIdThe instance ID.
objectPThe lwm2m_object_t object.
Returns
The result of the delete operation.

Definition at line 179 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverDiscover_clb()

uint8_t wpp::Object::serverDiscover_clb ( lwm2m_context_t *  contextP,
lwm2m_server_t *  server,
ID_T  instanceId,
int *  numDataP,
lwm2m_data_t **  dataArrayP,
lwm2m_object_t *  objectP 
)
staticprotected

The discover callback function for the Lwm2m core.

Parameters
contextPThe lwm2m_context_t object.
serverContains valid pointer when request retrieved from server or NULL if request initiated by core.
instanceIdThe instance ID.
numDataPThe number of data.
dataArrayPThe data array.
objectPThe lwm2m_object_t object.
Returns
The result of the discover operation.

Definition at line 156 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverExecute_clb()

uint8_t wpp::Object::serverExecute_clb ( lwm2m_context_t *  contextP,
lwm2m_server_t *  server,
ID_T  instanceId,
ID_T  resId,
uint8_t *  buffer,
int  length,
lwm2m_object_t *  objectP 
)
staticprotected

The execute callback function for the Lwm2m core.

Parameters
contextPThe lwm2m_context_t object.
serverContains valid pointer when request retrieved from server or NULL if request initiated by core.
instanceIdThe instance ID.
resIdThe resource ID.
bufferThe buffer.
lengthThe length.
objectPThe lwm2m_object_t object.
Returns
The result of the execute operation.

Definition at line 149 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverRead_clb()

uint8_t wpp::Object::serverRead_clb ( lwm2m_context_t *  contextP,
lwm2m_server_t *  server,
ID_T  instanceId,
int *  numDataP,
lwm2m_data_t **  dataArrayP,
lwm2m_object_t *  objectP 
)
staticprotected

The read callback function for the Lwm2m core.

Parameters
contextPThe lwm2m_context_t object.
serverContains valid pointer when request retrieved from server or NULL if request initiated by core.
instanceIdThe instance ID.
numDataPThe number of data.
dataArrayPThe data array.
objectPThe lwm2m_object_t object.
Returns
The result of the read operation.

Definition at line 135 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverWrite_clb()

uint8_t wpp::Object::serverWrite_clb ( lwm2m_context_t *  contextP,
lwm2m_server_t *  server,
ID_T  instanceId,
int  numData,
lwm2m_data_t *  dataArray,
lwm2m_object_t *  objectP,
lwm2m_write_type_t  writeType 
)
staticprotected

The write callback function for the Lwm2m core.

Parameters
contextPThe lwm2m_context_t object.
serverContains valid pointer when request retrieved from server or NULL if request initiated by core.
instanceIdThe instance ID.
numDataThe number of data.
dataArrayThe data array.
objectPThe lwm2m_object_t object.
writeTypeThe write type.
Returns
The result of the write operation.

Definition at line 142 of file Object.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _context

lwm2m_context_t& wpp::Object::_context
protected

Definition at line 247 of file Object.h.

◆ _instances

std::vector<Instance*> wpp::Object::_instances
protected

Definition at line 246 of file Object.h.

◆ _lwm2m_object

lwm2m_object_t wpp::Object::_lwm2m_object
protected

Definition at line 248 of file Object.h.

◆ _objInfo

ObjectInfo wpp::Object::_objInfo
protected

Definition at line 249 of file Object.h.