Google is committed to advancing racial equity for Black communities. See how.

nl::Weave::Profiles::DataManagement_Legacy::ProfileDatabase

This is an abstract class.

#include <src/lib/profiles/data-management/Legacy/ProfileDatabase.h>

The abstract ProfileDatabase auxiliary class.

Summary

WDM separates the protocol implementation from the data management implementation and, at least in principle, leaves most of the latter to the application developer. All of the interesting calls in WDM and all of the abstract methods that the profile developer is required to implement take TLV-encoded path lists or data lists. This puts a burden on profile developers and, in practice, will cause a lot of code duplication as developer after developer writes the same code for packing and unpacking TLV and so on. To ease things a bit we provide a kind of "data management toolkit".

This auxiliary class provides support for storing and retrieving data provided that the necessary concrete ProfileData sub-classes have been supplied and added to the LookupProfileData() method below.

Public functions

LookupDataFromProfileDescriptor(nl::Weave::TLV::TLVReader & aDescReader, ProfileData **aProfileData)
Find a ProfileData object in the database.
LookupProfileData(nl::Weave::TLV::TLVReader & aPathReader, ProfileData **aProfileData)
Find a ProfileData object in the database.
LookupProfileData(uint32_t aProfileId, nl::Weave::TLV::TLVReader *aInstanceIdRdr, ProfileData **aResult)=0
virtual WEAVE_ERROR
Look up a ProfileData object.
Retrieve(ReferencedTLVData & aPathList, ReferencedTLVData & aDataList)
Retrieve a data list given a path list.
Retrieve(ReferencedTLVData & aPathList, nl::Weave::TLV::TLVWriter & aWriter)
Write out a data list given a path list.
Store(ReferencedTLVData & aDataList)
Store a data list.

Protected functions

StoreInternal(nl::Weave::TLV::TLVReader & aPathReader, uint64_t aVersion, nl::Weave::TLV::TLVReader & aDataReader)

Classes

nl::Weave::Profiles::DataManagement_Legacy::ProfileDatabase::ProfileData

The abstract ProfileData auxiliary inner class.

Public functions

LookupDataFromProfileDescriptor

WEAVE_ERROR LookupDataFromProfileDescriptor(
  nl::Weave::TLV::TLVReader & aDescReader,
  ProfileData **aProfileData
)

Find a ProfileData object in the database.

This utility method is used to find ProfileData objects in a particular ProfileDatabase. It depends largely on lookup methods provided by the implementer of the concrete ProfileDatabase subclass.

Details
Parameters
[in] aDescReader
A reference to a TLV reader positioned at a WDM path - i.e. a TLV path that has, as its first element, a profile description.
[out] aProfileData
A pointer, intended to return a pointer to the ProfileData object of interest.
Returns
WEAVE_NO_ERROR on success, otherwise return a WEAVE_ERROR indicating a failure to look up a matching ProfileData object.

LookupProfileData

WEAVE_ERROR LookupProfileData(
  nl::Weave::TLV::TLVReader & aPathReader,
  ProfileData **aProfileData
)

Find a ProfileData object in the database.

This utility method is used to find ProfileData objects in a particular ProfileDatabase. It depends largely on lookup methods provided by the implementer of the concrete ProfileDatabase subclass.

Details
Parameters
[in] aPathReader
A reference to a TLV reader positioned at a WDM path - i.e. a TLV path that has, as its first element, a profile description.
[out] aProfileData
A pointer, intended to return a pointer to the ProfileData object of interest.
Returns
WEAVE_NO_ERROR on success, otherwise return a WEAVE_ERROR indicating a failure to look up a matching ProfileData object.

LookupProfileData

virtual WEAVE_ERROR LookupProfileData(
  uint32_t aProfileId,
  nl::Weave::TLV::TLVReader *aInstanceIdRdr,
  ProfileData **aResult
)=0

Look up a ProfileData object.

Look up a specific ProfileData object given a profile ID and an (optional) instance ID< provided as a TLV reader.

Details
Parameters
[in] aProfileId
The 32-bit profile number of the profile of interest.
[in] aInstanceIdRdr
A pointer to a TLV reader positioned at the instance identifier data. If not instance identifier was provided then this shall be NULL.
[out] aResult
A pointer, intended to return a pointer to the ProfileData object of interest.
Returns
WEAVE_NO_ERROR On success. Otherwise return a WEAVE_ERROR reflecting an inability to find a ProfileData object.

Retrieve

WEAVE_ERROR Retrieve(
  ReferencedTLVData & aPathList,
  ReferencedTLVData & aDataList
)

Retrieve a data list given a path list.

Given a list of paths, retrieve a data list containing data list elements for each path in the path list the data that is the terminal of that path.

Details
Parameters
[in] aPathList
A reference to a ReferencedTLVData object containing a TLV-encoded list of paths representing data to retrieve. This parameter is kept constant throughout the execution of this function.
[out] aDataList
A reference to a ReferencedTLVData object in which to write the retrieved results. Data length is adjusted only after successful execution of this function.
Returns
WEAVE_NO_ERROR On success. Otherwise return a WEAVE_ERROR indicating a failure to retrieve the data list of interest.

Retrieve

WEAVE_ERROR Retrieve(
  ReferencedTLVData & aPathList,
  nl::Weave::TLV::TLVWriter & aWriter
)

Write out a data list given a path list.

Given a list of paths and a TLV writer, write out a data list containing data list elements for each path in the path list and the data that is the terminal of that path.

Details
Parameters
[in] aPathList
A reference to a ReferencedTLVData object containing a list of TLV paths representing data to retrieve. This parameter is kept constant throughout the execution of this function.
[in] aWriter
A reference to the TLV writer to use in writing out the retrieved path list. Internal state for the writer could be unrecoverable in case of an error.
Returns
WEAVE_NO_ERROR On success. Otherwise return a WEAVE_ERROR indicating a failure to retrieve the data or write out the data list of interest.

Store

WEAVE_ERROR Store(
  ReferencedTLVData & aDataList
)

Store a data list.

Given a TLV-encoded data list, this method goes through the process of parsing that list and calling the concrete methods provided by ProfileDatabase subclass implementers to put the referenced data where it belongs.

Details
Parameters
[in] aDataList
A reference to a ReferencedTLVData object containing the data of interest in TLV-encoded form.
Returns
WEAVE_NO_ERROR On success. Otherwise return a WEAVE_ERROR indicating a failure to store the data of interest.

Protected functions

StoreInternal

WEAVE_ERROR StoreInternal(
  nl::Weave::TLV::TLVReader & aPathReader,
  uint64_t aVersion,
  nl::Weave::TLV::TLVReader & aDataReader
)