Skip to content

Commit

Permalink
Use StartUp to init
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Dec 4, 2024
1 parent 2ed8dfb commit 96b12a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1836,8 +1836,6 @@ DataModel::Provider * InteractionModelEngine::SetDataModelProvider(DataModel::Pr
mDataModelProvider = model;
if (mDataModelProvider != nullptr)
{
mDataModelProvider->Init();

DataModel::InteractionModelContext context;

context.eventsGenerator = &EventManagement::GetInstance();
Expand Down
19 changes: 12 additions & 7 deletions src/app/codegen-data-model-provider/CodegenDataModelProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app/CommandHandlerInterface.h>
#include <app/ConcreteCommandPath.h>
#include <app/data-model-provider/ActionReturnStatus.h>
#include <app/data-model-provider/Context.h>
#include <app/util/DataModelHandler.h>
#include <app/util/af-types.h>

Expand Down Expand Up @@ -126,13 +127,6 @@ class CodegenDataModelProvider : public DataModel::Provider
};

public:
void Init() override
{
// Call the Ember-specific InitDataModelHandler
InitDataModelHandler();
ChipLogProgress(AppServer, "CodegenDataModelHandler initialized.");
}

/// clears out internal caching. Especially useful in unit tests,
/// where path caching does not really apply (the same path may result in different outcomes)
void Reset()
Expand All @@ -143,6 +137,17 @@ class CodegenDataModelProvider : public DataModel::Provider
}

/// Generic model implementations
CHIP_ERROR Startup(DataModel::InteractionModelContext context) override
{
// Call the base class's Startup method to ensure base initialization
ReturnErrorOnFailure(DataModel::Provider::Startup(context));

// Call the Ember-specific InitDataModelHandler
InitDataModelHandler();

return CHIP_NO_ERROR;
}

CHIP_ERROR Shutdown() override
{
Reset();
Expand Down
2 changes: 0 additions & 2 deletions src/app/data-model-provider/Provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class Provider : public ProviderMetadataTree
public:
virtual ~Provider() = default;

virtual void Init() = 0;

// `context` pointers will be guaranteed valid until Shutdown is called()
virtual CHIP_ERROR Startup(InteractionModelContext context)
{
Expand Down

0 comments on commit 96b12a6

Please sign in to comment.