Skip to content

Commit

Permalink
Rename EventPath and EventPathList (#11278)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google authored and pull[bot] committed Aug 22, 2023
1 parent 1f9f858 commit 5864180
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 250 deletions.
8 changes: 4 additions & 4 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ static_library("app") {
"MessageDef/EventFilters.cpp",
"MessageDef/EventList.cpp",
"MessageDef/EventList.h",
"MessageDef/EventPath.cpp",
"MessageDef/EventPath.h",
"MessageDef/EventPathList.cpp",
"MessageDef/EventPathList.h",
"MessageDef/EventPathIB.cpp",
"MessageDef/EventPathIB.h",
"MessageDef/EventPaths.cpp",
"MessageDef/EventPaths.h",
"MessageDef/InvokeCommand.cpp",
"MessageDef/InvokeCommand.h",
"MessageDef/ListBuilder.cpp",
Expand Down
8 changes: 4 additions & 4 deletions src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ CHIP_ERROR EventManagement::ConstructEvent(EventLoadOutContext * apContext, Even
TLVWriter checkpoint = apContext->mWriter;
TLV::TLVType dataContainerType;
EventDataElement::Builder eventDataElementBuilder;
EventPath::Builder eventPathBuilder;
EventPathIB::Builder eventPathBuilder;
uint64_t deltatime = 0;

VerifyOrExit(apContext->mCurrentEventNumber >= apContext->mStartingEventNumber,
Expand All @@ -313,7 +313,7 @@ CHIP_ERROR EventManagement::ConstructEvent(EventLoadOutContext * apContext, Even
VerifyOrExit(apOptions->mTimestamp.mType != Timestamp::Type::kInvalid, err = CHIP_ERROR_INVALID_ARGUMENT);

eventDataElementBuilder.Init(&(apContext->mWriter));
eventPathBuilder = eventDataElementBuilder.CreateEventPathBuilder();
eventPathBuilder = eventDataElementBuilder.CreateEventPath();
err = eventPathBuilder.GetError();
SuccessOrExit(err);

Expand All @@ -322,7 +322,7 @@ CHIP_ERROR EventManagement::ConstructEvent(EventLoadOutContext * apContext, Even
.EndpointId(apOptions->mpEventSchema->mEndpointId)
.ClusterId(apOptions->mpEventSchema->mClusterId)
.EventId(apOptions->mpEventSchema->mEventId)
.EndOfEventPath();
.EndOfEventPathIB();
err = eventPathBuilder.GetError();
SuccessOrExit(err);

Expand Down Expand Up @@ -751,7 +751,7 @@ CHIP_ERROR EventManagement::FetchEventParameters(const TLVReader & aReader, size

if (reader.GetTag() == TLV::ContextTag(EventDataElement::kCsTag_EventPath))
{
EventPath::Parser path;
EventPathIB::Parser path;
ReturnErrorOnFailure(path.Init(aReader));
ReturnErrorOnFailure(path.GetNodeId(&(envelope->mNodeId)));
ReturnErrorOnFailure(path.GetEndpointId(&(envelope->mEndpointId)));
Expand Down
6 changes: 3 additions & 3 deletions src/app/MessageDef/EventDataElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ CHIP_ERROR EventDataElement::Parser::CheckSchemaValidity() const

#if CHIP_DETAIL_LOGGING
{
EventPath::Parser path;
EventPathIB::Parser path;
err = path.Init(reader);
SuccessOrExit(err);

Expand Down Expand Up @@ -395,7 +395,7 @@ CHIP_ERROR EventDataElement::Parser::CheckSchemaValidity() const
}
#endif // CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK

CHIP_ERROR EventDataElement::Parser::GetEventPath(EventPath::Parser * const apEventPath)
CHIP_ERROR EventDataElement::Parser::GetEventPath(EventPathIB::Parser * const apEventPath)
{
CHIP_ERROR err = CHIP_NO_ERROR;
chip::TLV::TLVReader reader;
Expand Down Expand Up @@ -458,7 +458,7 @@ CHIP_ERROR EventDataElement::Builder::Init(chip::TLV::TLVWriter * const apWriter
return InitAnonymousStructure(apWriter);
}

EventPath::Builder & EventDataElement::Builder::CreateEventPathBuilder()
EventPathIB::Builder & EventDataElement::Builder::CreateEventPath()
{
// skip if error has already been set
if (mError == CHIP_NO_ERROR)
Expand Down
12 changes: 6 additions & 6 deletions src/app/MessageDef/EventDataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#pragma once

#include "Builder.h"
#include "EventPath.h"
#include "EventPathIB.h"

#include "Parser.h"

Expand Down Expand Up @@ -88,7 +88,7 @@ class Parser : public chip::app::Parser
* #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetEventPath(EventPath::Parser * const apEventPath);
CHIP_ERROR GetEventPath(EventPathIB::Parser * const apEventPath);

/**
* @brief Get a TLVReader for the Number. Next() must be called before accessing them.
Expand Down Expand Up @@ -184,11 +184,11 @@ class Builder : public chip::app::Builder
CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);

/**
* @brief Initialize a EventPath::Builder for writing into the TLV stream
* @brief Initialize a EventPathIB::Builder for writing into the TLV stream
*
* @return A reference to EventPath::Builder
* @return A reference to EventPathIB::Builder
*/
EventPath::Builder & CreateEventPathBuilder();
EventPathIB::Builder & CreateEventPath();

/**
* @brief Inject PriorityLevel into the TLV stream to indicate the priority level associated with
Expand Down Expand Up @@ -261,7 +261,7 @@ class Builder : public chip::app::Builder
EventDataElement::Builder & EndOfEventDataElement();

private:
EventPath::Builder mEventPathBuilder;
EventPathIB::Builder mEventPathBuilder;
};
}; // namespace EventDataElement
}; // namespace app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

#include "EventPath.h"
#include "EventPathIB.h"

#include "MessageDefHelper.h"

Expand All @@ -36,24 +36,8 @@ using namespace chip::TLV;

namespace chip {
namespace app {
CHIP_ERROR EventPath::Parser::Init(const chip::TLV::TLVReader & aReader)
{
CHIP_ERROR err = CHIP_NO_ERROR;

// make a copy of the reader here
mReader.Init(aReader);

VerifyOrExit(chip::TLV::kTLVType_List == mReader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);

err = mReader.EnterContainer(mOuterContainerType);

exit:

return err;
}

#if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK
CHIP_ERROR EventPath::Parser::CheckSchemaValidity() const
CHIP_ERROR EventPathIB::Parser::CheckSchemaValidity() const
{
CHIP_ERROR err = CHIP_NO_ERROR;
uint16_t TagPresenceMask = 0;
Expand Down Expand Up @@ -110,10 +94,10 @@ CHIP_ERROR EventPath::Parser::CheckSchemaValidity() const
}
#endif // CHIP_DETAIL_LOGGING
break;
case chip::app::EventPath::kCsTag_EventId:
case chip::app::EventPathIB::kCsTag_EventId:
// check if this tag has appeared before
VerifyOrExit(!(TagPresenceMask & (1 << chip::app::EventPath::kCsTag_EventId)), err = CHIP_ERROR_INVALID_TLV_TAG);
TagPresenceMask |= (1 << chip::app::EventPath::kCsTag_EventId);
VerifyOrExit(!(TagPresenceMask & (1 << chip::app::EventPathIB::kCsTag_EventId)), err = CHIP_ERROR_INVALID_TLV_TAG);
TagPresenceMask |= (1 << chip::app::EventPathIB::kCsTag_EventId);
VerifyOrExit(chip::TLV::kTLVType_UnsignedInteger == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);

#if CHIP_DETAIL_LOGGING
Expand Down Expand Up @@ -156,47 +140,27 @@ CHIP_ERROR EventPath::Parser::CheckSchemaValidity() const
}
#endif // CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK

CHIP_ERROR EventPath::Parser::GetNodeId(chip::NodeId * const apNodeId) const
CHIP_ERROR EventPathIB::Parser::GetNodeId(chip::NodeId * const apNodeId) const
{
return GetUnsignedInteger(kCsTag_NodeId, apNodeId);
}

CHIP_ERROR EventPath::Parser::GetEndpointId(chip::EndpointId * const apEndpointID) const
CHIP_ERROR EventPathIB::Parser::GetEndpointId(chip::EndpointId * const apEndpointID) const
{
return GetUnsignedInteger(kCsTag_EndpointId, apEndpointID);
}

CHIP_ERROR EventPath::Parser::GetClusterId(chip::ClusterId * const apClusterId) const
CHIP_ERROR EventPathIB::Parser::GetClusterId(chip::ClusterId * const apClusterId) const
{
return GetUnsignedInteger(kCsTag_ClusterId, apClusterId);
}

CHIP_ERROR EventPath::Parser::GetEventId(chip::EventId * const apEventId) const
CHIP_ERROR EventPathIB::Parser::GetEventId(chip::EventId * const apEventId) const
{
return GetUnsignedInteger(kCsTag_EventId, apEventId);
}

CHIP_ERROR EventPath::Builder::_Init(chip::TLV::TLVWriter * const apWriter, const Tag aTag)
{
mpWriter = apWriter;
mError = mpWriter->StartContainer(aTag, chip::TLV::kTLVType_List, mOuterContainerType);
SuccessOrExit(mError);

exit:
return mError;
}

CHIP_ERROR EventPath::Builder::Init(chip::TLV::TLVWriter * const apWriter)
{
return _Init(apWriter, chip::TLV::AnonymousTag);
}

CHIP_ERROR EventPath::Builder::Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse)
{
return _Init(apWriter, chip::TLV::ContextTag(aContextTagToUse));
}

EventPath::Builder & EventPath::Builder::NodeId(const uint64_t aNodeId)
EventPathIB::Builder & EventPathIB::Builder::NodeId(const uint64_t aNodeId)
{
// skip if error has already been set
if (mError == CHIP_NO_ERROR)
Expand All @@ -206,7 +170,7 @@ EventPath::Builder & EventPath::Builder::NodeId(const uint64_t aNodeId)
return *this;
}

EventPath::Builder & EventPath::Builder::EndpointId(const chip::EndpointId aEndpointId)
EventPathIB::Builder & EventPathIB::Builder::EndpointId(const chip::EndpointId aEndpointId)
{
// skip if error has already been set
if (mError == CHIP_NO_ERROR)
Expand All @@ -216,7 +180,7 @@ EventPath::Builder & EventPath::Builder::EndpointId(const chip::EndpointId aEndp
return *this;
}

EventPath::Builder & EventPath::Builder::ClusterId(const chip::ClusterId aClusterId)
EventPathIB::Builder & EventPathIB::Builder::ClusterId(const chip::ClusterId aClusterId)
{
// skip if error has already been set
if (mError == CHIP_NO_ERROR)
Expand All @@ -226,7 +190,7 @@ EventPath::Builder & EventPath::Builder::ClusterId(const chip::ClusterId aCluste
return *this;
}

EventPath::Builder & EventPath::Builder::EventId(const chip::EventId aEventId)
EventPathIB::Builder & EventPathIB::Builder::EventId(const chip::EventId aEventId)
{
// skip if error has already been set
if (mError == CHIP_NO_ERROR)
Expand All @@ -236,7 +200,7 @@ EventPath::Builder & EventPath::Builder::EventId(const chip::EventId aEventId)
return *this;
}

EventPath::Builder & EventPath::Builder::EndOfEventPath()
EventPathIB::Builder & EventPathIB::Builder::EndOfEventPathIB()
{
EndOfContainer();
return *this;
Expand Down
Loading

0 comments on commit 5864180

Please sign in to comment.