nl:: Weave:: Profiles:: DataManagement_Current:: ResourceIdentifier
#include <src/lib/profiles/data-management/Current/ResourceIdentifier.h>
A structure encapsulating the ID of a resource.
Summary
The ResourceIdentifier may be either a generalized 64-bit object ID of a particular type or a UUID. When encoded externally, the following representations are supported:
an unsigned 64-bit integer corresponding to the generalized object of type DEVICE with the ID specified in the representation
a generalized representation encoded as a byte string of 10 octets. The first two octets encode the resource type as a 16-bit, little endian integer, with the remaining 8 bytes encoding a little endian 64-bit resource ID.
ResourceIdentifiers also embody the conventions present throughout the WDM code: an empty ResourceIdentifier corresponds to the node ID of the DEVICE, and constructors are provided for the most common usecases.
Constructors and Destructors |
|
---|---|
ResourceIdentifier()
Construct a ResourceIdentifier corresponding to an unspecified ResourceID.
|
|
ResourceIdentifier(const uint64_t & aNodeId)
Construct a ResourceIdentifier of type DEVICE based on a given aNodeId.
|
|
ResourceIdentifier(uint16_t aResourceType, const uint64_t & aResourceId)
Construct the ResourceIdentifier of the specified type with the given ID.
|
|
ResourceIdentifier(uint16_t aResourceType, const uint8_t *aResourceId, size_t aResourceIdLen)
Construct the ResourceIdentifier of the specified type with the given ID.
|
Public types |
|
---|---|
@125{
|
enum |
@126
|
enum Defines a special value for NodeId that refers to 'self'. |
@127
|
enum |
Public attributes |
|
---|---|
ResourceId
|
uint64_t
|
ResourceIdBytes[8]
|
uint8_t
|
Public functions |
|
---|---|
FromString(const char *inBuffer, size_t inBufferLen)
|
Parse a canonical string representation of a resource into a resource object.
|
FromString(const char *inBuffer, size_t inBufferLen, const uint64_t & aSelfNodeId)
|
Parse a canonical string representation of a resource into a resource object.
|
FromTLV(nl::Weave::TLV::TLVReader & aReader)
|
Deserialize a ResourceIdentifier from a TLV representaion into this object.
|
FromTLV(nl::Weave::TLV::TLVReader & aReader, const uint64_t & aSelfNodeId)
|
Deserialize a ResourceIdentifier from a TLV representaion into this object.
|
GetResourceId() const
|
uint64_t
An accessor function for fetching the ResourceId.
|
GetResourceType() const
|
uint16_t
An accessor function for fetching the ResourceType.
|
ResourceTypeAsString(void) const
|
const char *
Produce a string representation of the ResourceType.
|
ToString(char *buffer, size_t bufferLen)
|
Convert the ResourceIdentifier into a printable string.
|
ToTLV(nl::Weave::TLV::TLVWriter & aWriter) const
|
Serialize the resource to a TLV representation using a context Path::ResourceID tag.
|
ToTLV(nl::Weave::TLV::TLVWriter & aWriter, const uint64_t & aTag) const
|
Serialize the resource to a TLV representation using a given tag.
|
Public static functions |
|
---|---|
ResourceTypeAsString(uint16_t aResourceType)
|
const char *
Produce a string representation of a resource type.
|
Friend classes |
|
---|---|
operator==
|
friend bool
|
Public types
@125
@125
Properties | |
---|---|
RESOURCE_TYPE_RESERVED
|
A reserved resource type. The enum is chosen such that it does not conflict with the enum values from the Schema::Weave:::Common::ResourceType enums. At the moment, two ResourceId values are possible for the RESERVED resource type: a kNodeIdNotSpecified corresponds to an unitialized ResourceIdentifier, and SELF_NODE_ID corresponds to a resource that will remap onto SELF from any other representation. |
@126
@126
Defines a special value for NodeId that refers to 'self'.
In certain WDM interactions, having a value of self for resource allows for compressing out that information as it is redundant to the source node id of the device expressed in the Weave. message itself
@127
@127
Public attributes
ResourceId
uint64_t ResourceId
ResourceIdBytes
uint8_t ResourceIdBytes[8]
Public functions
FromString
WEAVE_ERROR FromString( const char *inBuffer, size_t inBufferLen )
Parse a canonical string representation of a resource into a resource object.
Converts the canonical string representation of a resource into a resource object. Note that only a subset of resources can be represented as a string, in particular, the reference implementation in Weave will only parse resources of canonical types as expressed in the ResourceTypeEnum.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
FromString
WEAVE_ERROR FromString( const char *inBuffer, size_t inBufferLen, const uint64_t & aSelfNodeId )
Parse a canonical string representation of a resource into a resource object.
Converts the canonical string representation of a resource into a resource object. Note that only a subset of resources can be represented as a string, in particular, the reference implementation in Weave will only parse resources of canonical types as expressed in the ResourceTypeEnum.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
FromTLV
WEAVE_ERROR FromTLV( nl::Weave::TLV::TLVReader & aReader )
Deserialize a ResourceIdentifier from a TLV representaion into this object.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
WEAVE_NO_ERROR on success. Errors from TLVReader if the ResourceIdentifier cannot be properly read.
|
FromTLV
WEAVE_ERROR FromTLV( nl::Weave::TLV::TLVReader & aReader, const uint64_t & aSelfNodeId )
Deserialize a ResourceIdentifier from a TLV representaion into this object.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
WEAVE_NO_ERROR on success. Errors from TLVReader if the ResourceIdentifier cannot be properly read.
|
GetResourceId
uint64_t GetResourceId() const
An accessor function for fetching the ResourceId.
GetResourceType
uint16_t GetResourceType() const
An accessor function for fetching the ResourceType.
ResourceIdentifier
ResourceIdentifier()
Construct a ResourceIdentifier corresponding to an unspecified ResourceID.
The unspecified resource ID is a tuple consisting of an RESERVED resource type with an kNodeIdNotSpeficied resource.
ResourceIdentifier
ResourceIdentifier( const uint64_t & aNodeId )
Construct a ResourceIdentifier of type DEVICE based on a given aNodeId.
Details | |||
---|---|---|---|
Parameters |
|
ResourceIdentifier
ResourceIdentifier( uint16_t aResourceType, const uint64_t & aResourceId )
Construct the ResourceIdentifier of the specified type with the given ID.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
ResourceIdentifier
ResourceIdentifier( uint16_t aResourceType, const uint8_t *aResourceId, size_t aResourceIdLen )
Construct the ResourceIdentifier of the specified type with the given ID.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
ResourceTypeAsString
const char * ResourceTypeAsString( void ) const
Produce a string representation of the ResourceType.
The resources types converted are those enumerated in ResourceTypeEnum.h and the 0 (corresponding to the RESOURCE_TYPE_RESERVED)
ToString
WEAVE_ERROR ToString( char *buffer, size_t bufferLen )
Convert the ResourceIdentifier into a printable string.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
ToTLV
WEAVE_ERROR ToTLV( nl::Weave::TLV::TLVWriter & aWriter ) const
Serialize the resource to a TLV representation using a context Path::ResourceID tag.
Details | |||
---|---|---|---|
Parameters |
|
ToTLV
WEAVE_ERROR ToTLV( nl::Weave::TLV::TLVWriter & aWriter, const uint64_t & aTag ) const
Serialize the resource to a TLV representation using a given tag.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Public static functions
ResourceTypeAsString
const char * ResourceTypeAsString( uint16_t aResourceType )
Produce a string representation of a resource type.
The resources types converted are those enumerated in ResourceTypeEnum.h and the 0 (corresponding to the RESOURCE_TYPE_RESERVED)
Details | |||
---|---|---|---|
Parameters |
|
Friend classes
operator==
friend bool operator==(const ResourceIdentifier &lhs, const ResourceIdentifier &rhs)