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

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

架构引擎接受与特定特征相关联的架构信息,并提供相应机制来解析这些信息并将其转换为可供 WDM 机器使用的格式。

摘要

这包括从 PathHandles 转换为 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 与架构中存储的 ID 匹配,则返回 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 调用。

nl::Weave::Profiles::DataManagement_Current::TraitSchemaEngine::IGetDataDelegate
nl::Weave::Profiles::DataManagement_Current::TraitSchemaEngine::ISetDataDelegate

结构体

nl::Weave::Profiles::DataManagement_Current::TraitSchemaEngine::PropertyInfo
nl::Weave::Profiles::DataManagement_Current::TraitSchemaEngine::架构

包含架构信息的主架构结构。

公共静态属性

kHandleTableOffset

const uint32_t kHandleTableOffset = 2

公共属性

mSchema

const Schema mSchema

公共函数

查找最低相似度

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

给定两个属性句柄,计算作为这两个句柄的父级的最低句柄。

此外,还要返回包含两个句柄(即使相同)的两个子分支。

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

GetChildHandle

PropertyPathHandle GetChildHandle(
  PropertyPathHandle aParentHandle,
  uint8_t aContextTag
) const 

获取深度

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 

根据提供的数据架构版本,这将返回最高向前兼容的架构版本。

GetLowestCompatible 版本

SchemaVersion GetLowestCompatibleVersion(
  SchemaVersion aVersion
) const 

根据提供的数据架构版本,这将返回最低兼容的架构版本。

获取地图

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
写入 aTag 的代码数量
返回值
WEAVE_NO_ERROR(如果成功);WEAVE_ERROR_NO_MEMORY(如果 aTag 号太小而无法存储完整路径)。

GetTag

uint64_t GetTag(
  PropertyPathHandle aHandle
) const 

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

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

详细信息
返回值
uint64_t

GetVersionIntersection

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

根据版本范围,此函数会检查其与支持此架构引擎的架构所支持的兼容性交集是否存在交叉。

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

字典

bool IsDictionary(
  PropertyPathHandle aHandle
) const 

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

详细信息
返回值
bool

临时

bool IsEphemeral(
  PropertyPathHandle aHandle
) const 

IsInDictionary

bool IsInDictionary(
  PropertyPathHandle aHandle,
  PropertyPathHandle & aDictionaryItemHandle
) const 

如果相应句柄在字典(字典元素)之内,则返回 true。

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

详细信息
返回值
bool

绿叶

bool IsLeaf(
  PropertyPathHandle aPropertyHandle
) const 

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

详细信息
返回值
bool

是否可为 null

bool IsNullable(
  PropertyPathHandle aHandle
) const 

可选

bool IsOptional(
  PropertyPathHandle aHandle
) const 

父级

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

Details
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_TLV_TAG_NOT_FOUND
如果找不到匹配的句柄。
WEAVE_ERROR_INVALID_ARGUMENT
如果路径字符串格式不正确

匹配个人资料 ID

bool MatchesProfileId(
  uint32_t aProfileId
) const 

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

详细信息
返回值
bool

检索数据

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 

存储数据

WEAVE_ERROR StoreData(
  PropertyPathHandle aHandle,
  nl::Weave::TLV::TLVReader & aReader,
  ISetDataDelegate *aDelegate,
  IPathFilter *aPathFilter
) const 

在给定数据元素上具有路径句柄和读取器之后,只要遇到叶数据项,系统就会处理读取器指向的数据缓冲区并将其存储在接收器中,方法是调用 SetLeafData 调用。

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