nl:: Weave:: Profiles:: DataManagement_Current:: TraitSchemaEngine
#include <src/lib/profiles/data-management/Current/TraitData.h>
The schema engine takes schema information associated with a particular trait and provides facilities to parse and translate that into a form usable by the WDM machinery.
Summary
This includes converting from PathHandles to WDM paths (and vice versa), methods to interpret/query the schema itself and methods to help read/write out data to/from TLV given a handle.
The schema itself is stored in tabular form, sufficiently described to allow for generic parsing/composition of WDM paths/data for any given trait. These tables are what will be the eventual output of 'code-gen' (The term itself being somewhat misleading given the absence of any generated code :P)
Public static attributes |
|
---|---|
kHandleTableOffset = 2
|
const uint32_t
|
Public attributes |
|
---|---|
mSchema
|
const Schema
|
Public functions |
|
---|---|
FindLowestCommonAncestor(PropertyPathHandle aHandle1, PropertyPathHandle aHandle2, PropertyPathHandle *aHandle1BranchChild, PropertyPathHandle *aHandle2BranchChild) const
|
Given two property handles, calculate the lowest handle that serves as a parent to both of these handles.
|
GetChildHandle(PropertyPathHandle aParentHandle, uint8_t aContextTag) const
|
|
GetDepth(PropertyPathHandle aHandle) const
|
int32_t
Calculate the depth in the schema tree for a given handle.
|
GetDictionaryItemHandle(PropertyPathHandle aParentHandle, uint16_t aDictionaryKey) const
|
|
GetFirstChild(PropertyPathHandle aParentHandle) const
|
Returns the first child handle associated with a particular parent.
|
GetHighestForwardVersion(SchemaVersion aVersion) const
|
SchemaVersion
Given a provided data schema version, this will return the highest forward compatible schema version.
|
GetLowestCompatibleVersion(SchemaVersion aVersion) const
|
SchemaVersion
Given a provided data schema version, this will return the minimum compatible schema version.
|
GetMap(PropertyPathHandle aHandle) const
|
const PropertyInfo *
Returns a pointer to the PropertyInfo structure describing a particular path handle.
|
GetMaxVersion() const
|
SchemaVersion
|
GetMinVersion() const
|
SchemaVersion
|
GetNextChild(PropertyPathHandle aParentId, PropertyPathHandle aChildHandle) const
|
Given a handle to an existing child, returns the next child handle associated with a particular parent.
|
GetParent(PropertyPathHandle aHandle) const
|
Returns the parent handle of a given child path handle.
|
GetProfileId(void) const
|
uint32_t
Returns the profile id of the associated trait.
|
GetRelativePathTags(const PropertyPathHandle aCandidateHandle, uint64_t *aTags, const uint32_t aTagsSize, uint32_t & aNumTags) const
|
Converts a PropertyPathHandle to an array of context tags.
|
GetTag(PropertyPathHandle aHandle) const
|
uint64_t
Returns the tag associated with a path handle.
|
GetVersionIntersection(SchemaVersionRange & aVersion, SchemaVersionRange & aIntersection) const
|
bool
Given a version range, this function checks to see if there is a compatibility intersection between that and what is supported by schema that is backing this schema engine.
|
IsDictionary(PropertyPathHandle aHandle) const
|
bool
Returns true if the handle is a dictionary (and not in a dictionary - see method below).
|
IsEphemeral(PropertyPathHandle aHandle) const
|
bool
|
IsInDictionary(PropertyPathHandle aHandle, PropertyPathHandle & aDictionaryItemHandle) const
|
bool
Returns true if the handle is inside a dictionary (a dictionary element).
|
IsLeaf(PropertyPathHandle aPropertyHandle) const
|
bool
Returns true if the handle refers to a leaf node in the schema tree.
|
IsNullable(PropertyPathHandle aHandle) const
|
bool
|
IsOptional(PropertyPathHandle aHandle) const
|
bool
|
IsParent(PropertyPathHandle aChildHandle, PropertyPathHandle aParentHandle) const
|
bool
Checks if a given handle is a child of another handle.
|
MapHandleToPath(PropertyPathHandle aHandle, nl::Weave::TLV::TLVWriter & aPathWriter) const
|
Convert the path handle to a TLV path.
|
MapPathToHandle(nl::Weave::TLV::TLVReader & aPathReader, PropertyPathHandle & aHandle) const
|
Given a reader positioned at the root of a WDM path element, read out the relevant tags and provide the equivalent path handle.
|
MapPathToHandle(const char *aPathString, PropertyPathHandle & aHandle) const
|
Given the a string representation of a WDM path read out the relevant tags and provide the equivalent path handle.
|
MatchesProfileId(uint32_t aProfileId) const
|
bool
Returns true if the passed in profileId matches that stored in the schema.
|
RetrieveData(PropertyPathHandle aHandle, uint64_t aTagToWrite, nl::Weave::TLV::TLVWriter & aWriter, IGetDataDelegate *aDelegate, IDirtyPathCut *apDirtyPathCut) const
|
Given a path handle and a writer position on the corresponding data element, retrieve leaf data from the source and write it into the buffer pointed to by the writer in a schema compliant manner.
|
RetrieveUpdatableDictionaryData(PropertyPathHandle aHandle, uint64_t aTagToWrite, nl::Weave::TLV::TLVWriter & aWriter, IGetDataDelegate *aDelegate, PropertyPathHandle & aPropertyPathHandleOfDictItemToStartFrom) const
|
|
StoreData(PropertyPathHandle aHandle, nl::Weave::TLV::TLVReader & aReader, ISetDataDelegate *aDelegate, IPathFilter *aPathFilter) const
|
Given a path handle and a reader positioned on the corresponding data element, process the data buffer pointed to by the reader and store it into the sink by invoking the SetLeafData call whenever a leaf data item is encountered.
|
Classes |
|
---|---|
nl:: |
|
nl:: |
Structs |
|
---|---|
nl:: |
|
nl:: |
The main schema structure that houses the schema information. |
Public static attributes
kHandleTableOffset
const uint32_t kHandleTableOffset = 2
Public attributes
mSchema
const Schema mSchema
Public functions
FindLowestCommonAncestor
PropertyPathHandle FindLowestCommonAncestor( PropertyPathHandle aHandle1, PropertyPathHandle aHandle2, PropertyPathHandle *aHandle1BranchChild, PropertyPathHandle *aHandle2BranchChild ) const
Given two property handles, calculate the lowest handle that serves as a parent to both of these handles.
Additionally, return the two child branches that contain each of the two handles (even if they are the same).
Details | |||
---|---|---|---|
Return Values |
|
GetChildHandle
PropertyPathHandle GetChildHandle( PropertyPathHandle aParentHandle, uint8_t aContextTag ) const
GetDepth
int32_t GetDepth( PropertyPathHandle aHandle ) const
Calculate the depth in the schema tree for a given handle.
Details | |||
---|---|---|---|
Return Values |
|
GetDictionaryItemHandle
PropertyPathHandle GetDictionaryItemHandle( PropertyPathHandle aParentHandle, uint16_t aDictionaryKey ) const
GetFirstChild
PropertyPathHandle GetFirstChild( PropertyPathHandle aParentHandle ) const
Returns the first child handle associated with a particular parent.
Details | |||
---|---|---|---|
Return Values |
|
GetHighestForwardVersion
SchemaVersion GetHighestForwardVersion( SchemaVersion aVersion ) const
Given a provided data schema version, this will return the highest forward compatible schema version.
GetLowestCompatibleVersion
SchemaVersion GetLowestCompatibleVersion( SchemaVersion aVersion ) const
Given a provided data schema version, this will return the minimum compatible schema version.
GetMap
const PropertyInfo * GetMap( PropertyPathHandle aHandle ) const
Returns a pointer to the PropertyInfo structure describing a particular path handle.
Details | |||
---|---|---|---|
Return Values |
|
GetMaxVersion
SchemaVersion GetMaxVersion() const
GetMinVersion
SchemaVersion GetMinVersion() const
GetNextChild
PropertyPathHandle GetNextChild( PropertyPathHandle aParentId, PropertyPathHandle aChildHandle ) const
Given a handle to an existing child, returns the next child handle associated with a particular parent.
Details | |||
---|---|---|---|
Return Values |
|
GetParent
PropertyPathHandle GetParent( PropertyPathHandle aHandle ) const
Returns the parent handle of a given child path handle.
Dictionary keys in the handle are preserved in the case where the parent handle is also a dictionary element.
Details | |||
---|---|---|---|
Return Values |
|
GetProfileId
uint32_t GetProfileId( void ) const
Returns the profile id of the associated trait.
Details | |||
---|---|---|---|
Return Values |
|
GetRelativePathTags
WEAVE_ERROR GetRelativePathTags( const PropertyPathHandle aCandidateHandle, uint64_t *aTags, const uint32_t aTagsSize, uint32_t & aNumTags ) const
Converts a PropertyPathHandle to an array of context tags.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Returns |
WEAVE_NO_ERROR in case of success; WEAVE_ERROR_NO_MEMORY if aTags is too small to store the full path.
|
GetTag
uint64_t GetTag( PropertyPathHandle aHandle ) const
Returns the tag associated with a path handle.
If it's a dictionary element, this function returns the ProfileTag. Otherwise, it returns context tags.
Details | |||
---|---|---|---|
Return Values |
|
GetVersionIntersection
bool GetVersionIntersection( SchemaVersionRange & aVersion, SchemaVersionRange & aIntersection ) const
Given a version range, this function checks to see if there is a compatibility intersection between that and what is supported by schema that is backing this schema engine.
If there is an intersection, the function will return true and update the aIntersection argument passed in to reflect that results of that intersection test.
IsDictionary
bool IsDictionary( PropertyPathHandle aHandle ) const
Returns true if the handle is a dictionary (and not in a dictionary - see method below).
Details | |||
---|---|---|---|
Return Values |
|
IsEphemeral
bool IsEphemeral( PropertyPathHandle aHandle ) const
IsInDictionary
bool IsInDictionary( PropertyPathHandle aHandle, PropertyPathHandle & aDictionaryItemHandle ) const
Returns true if the handle is inside a dictionary (a dictionary element).
A user passed in handle (aDictionaryItemHandle) is updated to point to the top-most dictionary element handle within the dictionary.
Details | |||
---|---|---|---|
Return Values |
|
IsLeaf
bool IsLeaf( PropertyPathHandle aPropertyHandle ) const
Returns true if the handle refers to a leaf node in the schema tree.
Details | |||
---|---|---|---|
Return Values |
|
IsNullable
bool IsNullable( PropertyPathHandle aHandle ) const
IsOptional
bool IsOptional( PropertyPathHandle aHandle ) const
IsParent
bool IsParent( PropertyPathHandle aChildHandle, PropertyPathHandle aParentHandle ) const
Checks if a given handle is a child of another handle.
This can be an in-direct parent.
Details | |||
---|---|---|---|
Return Values |
|
MapHandleToPath
WEAVE_ERROR MapHandleToPath( PropertyPathHandle aHandle, nl::Weave::TLV::TLVWriter & aPathWriter ) const
MapPathToHandle
WEAVE_ERROR MapPathToHandle( nl::Weave::TLV::TLVReader & aPathReader, PropertyPathHandle & aHandle ) const
Given a reader positioned at the root of a WDM path element, read out the relevant tags and provide the equivalent path handle.
Details | |||||
---|---|---|---|---|---|
Return Values |
|
MapPathToHandle
WEAVE_ERROR MapPathToHandle( const char *aPathString, PropertyPathHandle & aHandle ) const
Given the a string representation of a WDM path read out the relevant tags and provide the equivalent path handle.
The WDM path is represented as a string using the following rules:
- tags are separated with
/
- the path MUST begin with a leading
/
and MUST NOT contain a trailing slash - numerical tags in the WDM path MUST be encoded using the standard C library for integer to string encoding, i.e. decimal encoding (default) MUST NOT contain a leading 0, a hexadecimal encoding MUST begin with
0x
, and octal encoding MUST contain a leading0
.
Details | |||||||
---|---|---|---|---|---|---|---|
Return Values |
|
MatchesProfileId
bool MatchesProfileId( uint32_t aProfileId ) const
Returns true if the passed in profileId matches that stored in the schema.
Details | |||
---|---|---|---|
Return Values |
|
RetrieveData
WEAVE_ERROR RetrieveData( PropertyPathHandle aHandle, uint64_t aTagToWrite, nl::Weave::TLV::TLVWriter & aWriter, IGetDataDelegate *aDelegate, IDirtyPathCut *apDirtyPathCut ) const
Given a path handle and a writer position on the corresponding data element, retrieve leaf data from the source and write it into the buffer pointed to by the writer in a schema compliant manner.
Details | |||||
---|---|---|---|---|---|
Return Values |
|
RetrieveUpdatableDictionaryData
WEAVE_ERROR RetrieveUpdatableDictionaryData( PropertyPathHandle aHandle, uint64_t aTagToWrite, nl::Weave::TLV::TLVWriter & aWriter, IGetDataDelegate *aDelegate, PropertyPathHandle & aPropertyPathHandleOfDictItemToStartFrom ) const
StoreData
WEAVE_ERROR StoreData( PropertyPathHandle aHandle, nl::Weave::TLV::TLVReader & aReader, ISetDataDelegate *aDelegate, IPathFilter *aPathFilter ) const
Given a path handle and a reader positioned on the corresponding data element, process the data buffer pointed to by the reader and store it into the sink by invoking the SetLeafData call whenever a leaf data item is encountered.
Details | |||||
---|---|---|---|---|---|
Return Values |
|