LTKCPP-- LLRP Toolkit C Plus Plus Library
Public Member Functions | Public Attributes | List of all members
LLRP::CElement Class Referenceabstract

This is the base class for all parameter and message types. More...

#include <ltkcpp_base.h>

Inheritance diagram for LLRP::CElement:
LLRP::CMessage LLRP::CParameter

Public Member Functions

void addSubParameterToAllList (CParameter *pParameter)
 Add a subparameter to m_listAllSubParameters. Called by the accessor functions setXXX and addXXX. More...
 
void removeSubParameterFromAllList (CParameter *pParameter)
 Delete a subparameter from m_listAllSubParameters. Called by the accessor functions setXXX (to remove prior reference) clearXXX(). More...
 
void clearSubParameterList (tListOfParameters *pParameterList)
 Clear a list of subparameters. For each entry apply removeSubParameter(). More...
 
int walk (int(*pFunc)(const CElement *pElement, void *pArg), void *pArg, int iDepth, int nMaxDepth) const
 Recursive tree walk. The callback is invoked for each element.
 
EResultCode toXMLString (char *pBuffer, int nBuffer)
 A wrapper around LLRP::toXMLString() More...
 
virtual void decodeFields (CDecoderStream *pDecoderStream)=0
 Virtual function provided by each specific element type to decode fields (simple values). Leaves pDecoderStream at first subparameter. More...
 
virtual void assimilateSubParameters (CErrorDetails *pError)=0
 Assimilates the decoded sub-parameters into m_listAllSubParameters. More...
 
virtual void encode (CEncoderStream *pEncoderStream) const =0
 Encode fields and subparameters. More...
 

Public Attributes

const CTypeDescriptorm_pType
 The type descriptor desribing this element.
 
CElementm_pParent
 Element that encloses this one, NULL if this is top-level element.
 
tListOfParameters m_listAllSubParameters
 List of all sub elements.
 

Detailed Description

This is the base class for all parameter and message types.

CElement

During decode, all subparameters found are entered on m_listAllSubParameters. Then the element's assimilateSubParameters() member function is called to iterate through the list and attach the parameters to specific fields.

The m_listAllSubParameters is a secondary reference to all the subparameters. When the element is destructed all parameters referenced by m_listAllSubParameters are deleted. The C++ intrinsic destructors take care of deleting the list itself.

During destruct the specific fields are not processed. The fields that are lists are automatically desctructed. So are the fields that are array types (i.e. utf8v) are also automatically destructed. The fields that are simple pointers are simply ignored.

This works because every parameter referenced by specific fields is also referenced by m_listAllSubParameters.

Definition at line 968 of file ltkcpp_base.h.

Member Function Documentation

◆ addSubParameterToAllList()

void LLRP::CElement::addSubParameterToAllList ( CParameter pParameter)

Add a subparameter to m_listAllSubParameters. Called by the accessor functions setXXX and addXXX.

Parameters
[in]pParameterThe list of sub-parameteters to add
Returns
void

Definition at line 43 of file ltkcpp_element.cpp.

References m_listAllSubParameters.

◆ assimilateSubParameters()

virtual void LLRP::CElement::assimilateSubParameters ( CErrorDetails pError)
pure virtual

Assimilates the decoded sub-parameters into m_listAllSubParameters.

After fields are decoded, the CDecoder itself takes care of gathering the subparameters into m_listAllSubParameters. Once the end of the enclosing TLV (or message) is reached this assimilateSubParameters() function is called to create parameter refrences from the primary member variables.

Parameters
[out]pErrorError details for encoded stream

◆ clearSubParameterList()

void LLRP::CElement::clearSubParameterList ( tListOfParameters *  pParameterList)

Clear a list of subparameters. For each entry apply removeSubParameter().

Parameters
[in]pParameterListThe list of parameters to clear
Returns
void

Definition at line 64 of file ltkcpp_element.cpp.

References removeSubParameterFromAllList().

◆ decodeFields()

virtual void LLRP::CElement::decodeFields ( CDecoderStream pDecoderStream)
pure virtual

Virtual function provided by each specific element type to decode fields (simple values). Leaves pDecoderStream at first subparameter.

Parameters
[in]pDecoderStreamThe stream from which to decode fields
Returns
void

◆ encode()

virtual void LLRP::CElement::encode ( CEncoderStream pEncoderStream) const
pure virtual

Encode fields and subparameters.

Parameters
[in]pEncoderStreamStream to encode
Returns
void

◆ removeSubParameterFromAllList()

void LLRP::CElement::removeSubParameterFromAllList ( CParameter pParameter)

Delete a subparameter from m_listAllSubParameters. Called by the accessor functions setXXX (to remove prior reference) clearXXX().

Parameters
[in]*pParameterThe parameter to delete
Returns
void

Definition at line 54 of file ltkcpp_element.cpp.

References m_listAllSubParameters.

Referenced by clearSubParameterList().

◆ toXMLString()

EResultCode LLRP::CElement::toXMLString ( char *  pBuffer,
int  nBuffer 
)

A wrapper around LLRP::toXMLString()

Format an element as XML text.

Parameters
[in]pBufferPointer to the buffer to store the result
[in]nBuffersize of the result buffer
Returns
EResultCode Result code from the operation

Basic steps

  • Construct an XML encoder that fills a buffer
  • Encode the message through the XML encoder
  • Destruct the XML encoder
Parameters
[in]pElementPointer to message/parameter to format
Returns
EResultCode

Definition at line 1079 of file ltkcpp_xmltextencode.cpp.

Referenced by usage().


The documentation for this class was generated from the following files: