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

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

結構定義引擎會接收與特定特徵相關的結構定義資訊,並提供相關設施,以便剖析資料並轉譯為 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
如果 in 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 呼叫,藉此處理讀取器指向的資料緩衝區,並儲存至接收器。

類別

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::Schema

存放結構定義資訊的主要結構定義結構。

公開靜態屬性

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
aTag 陣列的大小,以元素數量為單位。
[out] aNumTags
寫入 aTag 的標記數量
傳回
成功時會傳回 WEAVE_NO_ERROR;如果 aTag 太小,無法儲存完整路徑,則為 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 

如果 in 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
剖析/處理資料時發生錯誤。