bolar_2 backup
This commit is contained in:
41
main/app/application.h
Normal file
41
main/app/application.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/app_event_queue.h"
|
||||
#include "core/runtime_state.h"
|
||||
#include "ports/effect_sink.h"
|
||||
#include "ports/event_publisher.h"
|
||||
#include "ports/application_observer.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace borla {
|
||||
|
||||
class Application final : public IEventPublisher {
|
||||
public:
|
||||
explicit Application(IEffectSink& effects);
|
||||
|
||||
[[noreturn]] void Run();
|
||||
bool Publish(const AppEvent& event) override;
|
||||
bool AddObserver(IApplicationObserver* observer)
|
||||
{
|
||||
if (observer == nullptr || observer_count_ >= observers_.size()) {
|
||||
return false;
|
||||
}
|
||||
observers_[observer_count_++] = observer;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RuntimeState& state() const { return state_; }
|
||||
|
||||
private:
|
||||
void ProcessEvent(const AppEvent& event);
|
||||
void LogState(const AppEvent& event) const;
|
||||
|
||||
IEffectSink& effects_;
|
||||
AppEventQueue events_;
|
||||
RuntimeState state_;
|
||||
std::array<IApplicationObserver*, 4> observers_{};
|
||||
size_t observer_count_ = 0;
|
||||
};
|
||||
|
||||
} // namespace borla
|
||||
Reference in New Issue
Block a user