ACF $AcfVersion:0$
TRuntimeStatusHanderCompWrap.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <imod/IModel.h>
10
11
12namespace ibase
13{
14
15
19template <class ComponentClass>
20class TRuntimeStatusHanderCompWrap: public ComponentClass
21{
22public:
23 typedef ComponentClass BaseClass;
24
30
31 I_BEGIN_BASE_COMPONENT(TRuntimeStatusHanderCompWrap);
32 I_ASSIGN(m_runtimeStatusCompPtr, "RuntimeStatus", "Application's runtime status", false, "RuntimeStatus");
33 I_ASSIGN_TO(m_runtimeStatusModelCompPtr, m_runtimeStatusCompPtr, false);
34 I_END_COMPONENT;
35
37
38protected:
42 virtual void OnSystemStarting();
43
47 virtual void OnSystemStarted();
48
52 virtual void OnSystemShutdown();
53
54 // reimplemented (icomp::CComponentBase)
55 virtual void OnComponentCreated() override;
56 virtual void OnComponentDestroyed() override;
57
58private:
59 class RuntimeStatusObserver: public imod::CMultiModelDispatcherBase
60 {
61 public:
62 RuntimeStatusObserver(TRuntimeStatusHanderCompWrap& parent);
63
64 protected:
65 // reimplemented (imod::CMultiModelDispatcherBase)
66 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
67
68 private:
70 };
71
72protected:
73 I_REF(ibase::IRuntimeStatusProvider, m_runtimeStatusCompPtr);
74 I_REF(imod::IModel, m_runtimeStatusModelCompPtr);
75
76 RuntimeStatusObserver m_statusObserver;
77};
78
79
80// public methods
81
82template <class ComponentClass>
87
88
89// protected methods
90
91template <class ComponentClass>
95
96
97template <class ComponentClass>
101
102
103template <class ComponentClass>
107
108
109// reimplemented (icomp::CComponentBase)
110
111template <class ComponentClass>
113{
114 BaseClass::OnComponentCreated();
115
116 if (m_runtimeStatusCompPtr.IsValid() && m_runtimeStatusModelCompPtr.IsValid()){
117 m_statusObserver.RegisterModel(m_runtimeStatusModelCompPtr.GetPtr(), MI_RUNTIME_STATUS);
118 }
119}
120
121
122template <class ComponentClass>
124{
125 m_statusObserver.UnregisterAllModels();
126
127 BaseClass::OnComponentDestroyed();
128}
129
130
131// public methods of the embedded class RuntimeStatusObserver
132
133template <class ComponentClass>
135 :m_parent(parent)
136{
137}
138
139
140// protected methods of the embedded class RuntimeStatusObserver
141
142// reimplemented (imod::CMultiModelDispatcherBase)
143
144template <class ComponentClass>
145void TRuntimeStatusHanderCompWrap<ComponentClass>::RuntimeStatusObserver::OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet)
146{
147 Q_UNUSED(changeSet);
148
149 if (modelId == MI_RUNTIME_STATUS){
150 switch (m_parent.m_runtimeStatusCompPtr->GetRuntimeStatus()){
152 m_parent.OnSystemStarting();
153 break;
154
156 m_parent.OnSystemStarted();
157 break;
158
160 m_parent.OnSystemShutdown();
161 break;
162
163 default:
164 break;
165 }
166 }
167}
168
169
170} // namespace ibase
171
172
Provider of the run-time status.
@ RS_SHUTDOWN
Process is in shutdown phase.
Wrapper for providing additional component life-cycle states based on the application's runtime statu...
virtual void OnSystemShutdown()
The method will be called before the event loop of the application is quit.
virtual void OnSystemStarted()
The method will be called after the application' initialization was completed.
virtual void OnSystemStarting()
The method will be called directly after the creating the event loop of the application.
Generic implementation of a data model changes notifier.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Set of change flags (its IDs).
Definition IChangeable.h:36
This namespace contains basic implementations of standard primitives on the component level.