Skip to content

Commit 13ab2ad

Browse files
committed
Decouple use of IMEngine Singleton in EventManagement
1 parent e313d01 commit 13ab2ad

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/app/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ static_library("app") {
432432
"CommandResponseSender.cpp",
433433
"EventLogging.h",
434434
"EventManagement.cpp",
435-
"EventManagement.h",
436435
"FailSafeContext.cpp",
437436
"FailSafeContext.h",
438437
"GenericEventManagementTestEventTriggerHandler.cpp",
@@ -448,7 +447,8 @@ static_library("app") {
448447
# Name with _ so that linter does not recognize it
449448
# "CommandResponseSender._h"
450449
# "ReadHandler._h",
451-
# "WriteHandler._h"
450+
# "WriteHandler._h",
451+
# "EventManagement._h"
452452
]
453453

454454
public_deps = [

src/app/EventManagement.h

+18-2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ struct LogStorageResources
191191
PriorityLevel::Invalid; // Log priority level associated with the resources provided in this structure.
192192
};
193193

194+
/**
195+
* @brief
196+
* A EventScheduler to schedule deliveries of events.
197+
*/
198+
199+
class EventScheduler
200+
{
201+
public:
202+
virtual ~EventScheduler() = default;
203+
CHIP_ERROR virtual ScheduleEventDelivery(ConcreteEventPath & aPath, uint32_t aBytesWritten) = 0;
204+
};
205+
194206
/**
195207
* @brief
196208
* A class for managing the in memory event logs. See documentation at the
@@ -225,6 +237,9 @@ class EventManagement : public DataModel::EventsGenerator
225237
* @param[in] aMonotonicStartupTime Time we should consider as "monotonic
226238
* time 0" for cases when we use
227239
* system-time event timestamps.
240+
*
241+
* @param[in] apEventScheduler Scheduler to deliver the event, default is the reporting
242+
* engine in InteractionModelEngine.
228243
*
229244
* @param[in] apEventScheduler Scheduler to deliver the event, default is the reporting
230245
* engine in InteractionModelEngine.
@@ -233,7 +248,8 @@ class EventManagement : public DataModel::EventsGenerator
233248
void Init(Messaging::ExchangeManager * apExchangeManager, uint32_t aNumBuffers, CircularEventBuffer * apCircularEventBuffer,
234249
const LogStorageResources * const apLogStorageResources,
235250
MonotonicallyIncreasingCounter<EventNumber> * apEventNumberCounter,
236-
System::Clock::Milliseconds64 aMonotonicStartupTime, EventScheduler * apEventScheduler = nullptr);
251+
System::Clock::Milliseconds64 aMonotonicStartupTime,
252+
EventScheduler* apEventScheduler = nullptr);
237253

238254
static EventManagement & GetInstance();
239255

@@ -568,7 +584,7 @@ class EventManagement : public DataModel::EventsGenerator
568584

569585
System::Clock::Milliseconds64 mMonotonicStartupTime;
570586

571-
EventScheduler * mpEventScheduler = nullptr;
587+
EventScheduler* mpEventScheduler = nullptr;
572588
};
573589

574590
} // namespace app

src/app/reporting/Engine.h

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <access/AccessControl.h>
2828
#include <app/EventScheduler.h>
29+
#include <app/EventManagement.h>
2930
#include <app/MessageDef/ReportDataMessage.h>
3031
#include <app/ReadHandler.h>
3132
#include <app/data-model-provider/ProviderChangeListener.h>
@@ -67,6 +68,8 @@ class Engine : public DataModel::ProviderChangeListener, public EventScheduler
6768

6869
/**
6970
* Initializes the reporting engine. Should only be called once.
71+
*
72+
* @param[in] A pointer to EventManagement. Use the global one by default.
7073
*
7174
* @param[in] A pointer to EventManagement. Use the global one by default.
7275
*

0 commit comments

Comments
 (0)