nl::Weave::Profiles::DataManagement_Current::TraitSchemaEngine

#include <src/lib/profiles/data-management/Current/TraitData.h>

架构引擎会获取与特定 trait 关联的架构信息,并提供用于解析和将其转换为 WDM 机制可用的形式的设施。

摘要

这包括从 PathHandle 转换为 WDM 路径(反之亦然)、用于解释/查询架构本身的方法,以及在给定句柄的情况下帮助向/从 TLV 读取/写出数据的方法。

架构本身以表格形式存储,充分描述,可用于对任何给定特征的 WDM 路径/数据进行常规解析/组合。这些表将是“code-gen”的最终输出(由于没有任何生成的代码,该术语本身有点误导性:P)

公共静态属性

kHandleTableOffset = 2
const uint32_t

公共属性

mSchema
const Schema

公共函数

FindLowestCommonAncestor(PropertyPathHandle aHandle1, PropertyPathHandle aHandle2, PropertyPathHandle *aHandle1BranchChild, PropertyPathHandle *aHandle2BranchChild) const
给定两个媒体资源句柄,计算这两个句柄的父级句柄中级别最低的句柄。
GetChildHandle(PropertyPathHandle aParentHandle, uint8_t aContextTag) const
GetDepth(PropertyPathHandle aHandle) const
int32_t
计算给定句柄在架构树中的深度。
GetDictionaryItemHandle(PropertyPathHandle aParentHandle, uint16_t aDictionaryKey) const
GetFirstChild(PropertyPathHandle aParentHandle) const
返回与特定父实体相关联的第一个子句柄。
GetHighestForwardVersion(SchemaVersion aVersion) const
SchemaVersion
如果已提供提供的数据架构版本,系统将返回最高向前兼容的架构版本。
GetLowestCompatibleVersion(SchemaVersion aVersion) const
SchemaVersion
在提供的数据架构版本的情况下,此方法将返回最低兼容的架构版本。
GetMap(PropertyPathHandle aHandle) const
const PropertyInfo *
返回指向描述特定路径句柄的 PropertyInfo 结构的指针。
GetMaxVersion() const
SchemaVersion
GetMinVersion() const
SchemaVersion
GetNextChild(PropertyPathHandle aParentId, PropertyPathHandle aChildHandle) const
给定现有子项的句柄,返回与特定父项关联的下一个子项句柄。
GetParent(PropertyPathHandle aHandle) const
返回给定子路径句柄的父句柄。
GetProfileId(void) const
uint32_t
返回关联特征的个人资料 ID。
GetRelativePathTags(const PropertyPathHandle aCandidateHandle, uint64_t *aTags, const uint32_t aTagsSize, uint32_t & aNumTags) const
将 PropertyPathHandle 转换为上下文标记数组。
GetTag(PropertyPathHandle aHandle) const
uint64_t
返回与路径句柄相关联的标记。
GetVersionIntersection(SchemaVersionRange & aVersion, SchemaVersionRange & aIntersection) const
bool
给定一个版本范围后,此函数会检查该范围与此架构引擎所依托的架构支持的范围之间是否存在兼容性交集。
IsDictionary(PropertyPathHandle aHandle) const
bool
如果句柄是字典(而不是在字典中,请参见下面的方法),则返回 true。
IsEphemeral(PropertyPathHandle aHandle) const
bool
IsInDictionary(PropertyPathHandle aHandle, PropertyPathHandle & aDictionaryItemHandle) const
bool
如果句柄位于字典(字典元素)内,则返回 true。
IsLeaf(PropertyPathHandle aPropertyHandle) const
bool
如果句柄引用架构树中的叶节点,则返回 true。
IsNullable(PropertyPathHandle aHandle) const
bool
IsOptional(PropertyPathHandle aHandle) const
bool
IsParent(PropertyPathHandle aChildHandle, PropertyPathHandle aParentHandle) const
bool
检查给定句柄是否为另一个句柄的子项。
MapHandleToPath(PropertyPathHandle aHandle, nl::Weave::TLV::TLVWriter & aPathWriter) const
将路径句柄转换为 TLV 路径。
MapPathToHandle(nl::Weave::TLV::TLVReader & aPathReader, PropertyPathHandle & aHandle) const
假设读取器位于 WDM 路径元素的根位置,请读出相关标记,并提供等效的路径句柄。
MapPathToHandle(const char *aPathString, PropertyPathHandle & aHandle) const
给定 WDM 路径的字符串表示形式,读出相关标记并提供等效的路径句柄。
MatchesProfileId(uint32_t aProfileId) const
bool
如果传入的 profileId 与架构中存储的 profileId 匹配,则返回 true。
RetrieveData(PropertyPathHandle aHandle, uint64_t aTagToWrite, nl::Weave::TLV::TLVWriter & aWriter, IGetDataDelegate *aDelegate, IDirtyPathCut *apDirtyPathCut) const
给定路径句柄和相应数据元素上的写入器位置,从来源检索叶子数据,并以符合架构的方式将其写入写入器指向的缓冲区。
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
给定路径句柄和位于相应数据元素上的读取器,每当遇到叶数据项时,通过调用 SetLeafData 调用来处理读取器指向的数据缓冲区,并将其存储到接收器中。

公共静态属性

kHandleTableOffset

const uint32_t kHandleTableOffset = 2

公共属性

mSchema

const Schema mSchema

公共函数

FindLowestCommonAncestor

PropertyPathHandle FindLowestCommonAncestor(
 
PropertyPathHandle aHandle1,
 
PropertyPathHandle aHandle2,
 
PropertyPathHandle *aHandle1BranchChild,
 
PropertyPathHandle *aHandle2BranchChild
) const

给定两个媒体资源句柄,计算这两个句柄的父级句柄中级别最低的句柄。

此外,返回包含这两个句柄中每一个的两个子分支(即使它们相同)。

详细信息
返回值
PropertyPathHandle
最小父级的句柄。

GetChildHandle

PropertyPathHandle GetChildHandle(
 
PropertyPathHandle aParentHandle,
  uint8_t aContextTag
) const

GetDepth

int32_t GetDepth(
 
PropertyPathHandle aHandle
) const

计算给定句柄在架构树中的深度。

详细信息
返回值
int32_t
树中的深度

GetDictionaryItemHandle

PropertyPathHandle GetDictionaryItemHandle(
 
PropertyPathHandle aParentHandle,
  uint16_t aDictionaryKey
) const

GetFirstChild

PropertyPathHandle GetFirstChild(
 
PropertyPathHandle aParentHandle
) const

返回与特定父项关联的第一个子项句柄。

详细信息
返回值
PropertyPathHandle
第一个子项的句柄。

GetHighestForwardVersion

SchemaVersion GetHighestForwardVersion(
 
SchemaVersion aVersion
) const

如果已提供提供的数据架构版本,系统将返回最高向前兼容的架构版本。

GetLowestCompatibleVersion

SchemaVersion GetLowestCompatibleVersion(
 
SchemaVersion aVersion
) const

在提供的数据架构版本的情况下,此方法将返回最低兼容的架构版本。

GetMap

const PropertyInfo * GetMap(
 
PropertyPathHandle aHandle
) const

返回一个指向描述特定路径句柄的 PropertyInfo 结构的指针。

详细信息
返回值
PropertyInfo*

GetMaxVersion

SchemaVersion GetMaxVersion() const 

GetMinVersion

SchemaVersion GetMinVersion() const 

GetNextChild

PropertyPathHandle GetNextChild(
 
PropertyPathHandle aParentId,
 
PropertyPathHandle aChildHandle
) const

如果为现有子项指定句柄,则返回与特定父项关联的下一个子句柄。

详细信息
返回值
PropertyPathHandle
下一个子项的句柄。

GetParent

PropertyPathHandle GetParent(
 
PropertyPathHandle aHandle
) const

返回给定子路径句柄的父句柄。

如果父句柄也是字典元素,则句柄中的字典键会保留。

详细信息
返回值
PropertyPathHandle
父级的句柄。

GetProfileId

uint32_t GetProfileId(
 
void
) const

返回关联特征的个人资料 ID。

详细信息
返回值
Trait
配置文件 ID

GetRelativePathTags

WEAVE_ERROR GetRelativePathTags(
 
const PropertyPathHandle aCandidateHandle,
  uint64_t
*aTags,
 
const uint32_t aTagsSize,
  uint32_t
& aNumTags
) const

将 PropertyPathHandle 转换为上下文标记数组。

详细信息
参数
[in] aCandidateHandle
要转换的 PropertyPathHandle。
[in] aTags
指向输出数组的指针。
[in] aTagsSize
aTags 数组的大小(以元素数为单位)。
[out] aNumTags
写入 aTags 的标记数量
返回值
如果成功,则为 WEAVE_NO_ERROR;如果 aTags 太小而无法存储完整路径,则为 WEAVE_ERROR_NO_MEMORY。

GetTag

uint64_t GetTag(
 
PropertyPathHandle aHandle
) const

返回与路径句柄相关联的标记。

如果它是字典元素,则此函数会返回 ProfileTag。否则,它会返回上下文标记。

详细信息
返回值
uint64_t

GetVersionIntersection

bool GetVersionIntersection(
 
SchemaVersionRange & aVersion,
 
SchemaVersionRange & aIntersection
) const

给定一个版本范围后,此函数会检查该范围与此架构引擎所依托的架构支持的范围之间是否存在兼容性交集。

如果存在交集,该函数将返回 true 并更新传入的 aIntersection 参数,以反映该交集测试的结果。

IsDictionary

bool IsDictionary(
 
PropertyPathHandle aHandle
) const

如果句柄是字典(而非位于字典中 - 请参阅下文中的方法),则返回 true。

详细信息
返回值
bool

IsEphemeral

bool IsEphemeral(
 
PropertyPathHandle aHandle
) const

IsInDictionary

bool IsInDictionary(
 
PropertyPathHandle aHandle,
 
PropertyPathHandle & aDictionaryItemHandle
) const

如果句柄位于字典(字典元素),则返回 true。

用户传入的句柄 (aDictionaryItemHandle) 会更新为指向字典中的顶部字典元素句柄。

详细信息
返回值
bool

IsLeaf

bool IsLeaf(
 
PropertyPathHandle aPropertyHandle
) const

如果句柄引用架构树中的叶节点,则返回 true。

详细信息
返回值
bool

IsNullable

bool IsNullable(
 
PropertyPathHandle aHandle
) const

IsOptional

bool IsOptional(
 
PropertyPathHandle aHandle
) const

IsParent

bool IsParent(
 
PropertyPathHandle aChildHandle,
 
PropertyPathHandle aParentHandle
) const

检查给定句柄是否为另一个句柄的子项。

这可以是间接父级。

详细信息
返回值
bool

MapHandleToPath

WEAVE_ERROR MapHandleToPath(
 
PropertyPathHandle aHandle,
 
nl::Weave::TLV::TLVWriter & aPathWriter
) const

将路径句柄转换为 TLV 路径。

详细信息
返回值
WEAVE_NO_ERROR
成功时。
other
无法将句柄转换为 TLV 路径

MapPathToHandle

WEAVE_ERROR MapPathToHandle(
 
nl::Weave::TLV::TLVReader & aPathReader,
 
PropertyPathHandle & aHandle
) const

假设读取器位于 WDM 路径元素的根位置,请读出相关标记,并提供等效的路径句柄。

详细信息
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_TLV_TAG_NOT_FOUND
如果由于路径格式错误/指定错误而找不到匹配的句柄。

MapPathToHandle

WEAVE_ERROR MapPathToHandle(
 
const char *aPathString,
 
PropertyPathHandle & aHandle
) const

给定 WDM 路径的字符串表示形式,读出相关标记并提供等效的路径句柄。

WDM 路径使用以下规则表示为字符串:

  • 标记之间以 / 分隔
  • 路径必须以 / 开头,且结尾不得包含斜杠
  • WDM 路径中的数字标记必须使用标准 C 库进行编码,以便将整数编码为字符串,即十进制编码(默认)不得包含前导 0,十六进制编码必须以 0x 开头,八进制编码必须包含前导 0

详细信息
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_TLV_TAG_NOT_FOUND
如果找不到匹配的句柄。
WEAVE_ERROR_INVALID_ARGUMENT
如果路径字符串格式有误

MatchesProfileId

bool MatchesProfileId(
  uint32_t aProfileId
) const

如果传入的 profileId 与架构中存储的 profileId 匹配,则返回 true。

详细信息
返回值
bool

RetrieveData

WEAVE_ERROR RetrieveData(
 
PropertyPathHandle aHandle,
  uint64_t aTagToWrite
,
 
nl::Weave::TLV::TLVWriter & aWriter,
 
IGetDataDelegate *aDelegate,
 
IDirtyPathCut *apDirtyPathCut
) const

给定路径句柄和相应数据元素上的写入器位置,从来源检索叶子数据,并以符合架构的方式将其写入写入器指向的缓冲区。

详细信息
返回值
WEAVE_NO_ERROR
成功时。
other
写出数据时遇到错误。

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

给定路径句柄和位于相应数据元素上的读取器,每当遇到叶数据项时,通过调用 SetLeafData 调用来处理读取器指向的数据缓冲区,并将其存储到接收器中。

详细信息
返回值
WEAVE_NO_ERROR
成功时。
other
在解析/处理数据时遇到错误。