@@ -14,10 +14,9 @@ QD_MODULE_REGISTRATION(qd::AppPartsManager);
1414
1515namespace qd {
1616
17- void AppPartsManager::sendAppEventMsg (qd::appMsg::BaseMsg& in_msg)
18- {
19- for (size_t i = 0 ; i < m_pParts.size (); ++i)
20- {
17+ void AppPartsManager::sendAppEventMsg (qd::appMsg::BaseMsg& in_msg) {
18+
19+ for (size_t i = 0 ; i < m_pParts.size (); ++i) {
2120 ApplicationPart* pCurPart = getPartByInd ((int )i);
2221 if (!pCurPart)
2322 return ;
@@ -26,23 +25,21 @@ void AppPartsManager::sendAppEventMsg(qd::appMsg::BaseMsg& in_msg)
2625}
2726
2827
29- qd::ApplicationPart* AppPartsManager::findPartByName (const qtd::string& strPartID) const
30- {
31- for (auto it = m_pParts.begin (); it != m_pParts.end (); ++it)
32- {
33- ApplicationPart* pCurPart = *it;
28+ qd::ApplicationPart* AppPartsManager::findPartByName (const qtd::string& strPartID) const {
29+
30+ for (const auto & pPart : m_pParts) {
31+ ApplicationPart* pCurPart = pPart;
3432 if (pCurPart && pCurPart->getPartName () == strPartID)
3533 return pCurPart;
3634 }
3735 return nullptr ;
3836}
3937
4038
41- int AppPartsManager::findPartIndex (ApplicationPart* pPart) const
42- {
39+ int AppPartsManager::findPartIndex (ApplicationPart* pPart) const {
40+
4341 int nSize = (int )m_pParts.size ();
44- for (int i = 0 ; i < nSize; ++i)
45- {
42+ for (int i = 0 ; i < nSize; ++i) {
4643 ApplicationPart* pCurPart = m_pParts[i];
4744 if (pCurPart == pPart)
4845 return i;
@@ -51,20 +48,19 @@ int AppPartsManager::findPartIndex(ApplicationPart* pPart) const
5148}
5249
5350
54- bool AppPartsManager::addPartTry (ref_ptr<ApplicationPart> pPart)
55- {
51+ bool AppPartsManager::addPartTry (ref_ptr<ApplicationPart> pPart) {
5652 assert (pPart);
5753 if (!pPart)
5854 return false ;
5955
6056 const qtd::string& strPartName = pPart->getPartName ();
6157 assert (!strPartName.empty ());
6258
63- if (qd::is_has (pPart, m_pParts))
64- return false ;
59+ // -Wambiguous-reversed-operator
60+ // if (qd::is_has(pPart, m_pParts))
61+ // return false;
6562
66- if (findPartByName (strPartName))
67- {
63+ if (findPartByName (strPartName)) {
6864 assert2 (0 , " addPartTry() Error - Part with this name already exists" );
6965 return false ;
7066 }
@@ -73,8 +69,7 @@ bool AppPartsManager::addPartTry(ref_ptr<ApplicationPart> pPart)
7369}
7470
7571
76- void AppPartsManager::addPart (ref_ptr<ApplicationPart> pPart)
77- {
72+ void AppPartsManager::addPart (ref_ptr<ApplicationPart> pPart) {
7873 assert (pPart);
7974 if (!pPart)
8075 return ;
@@ -83,22 +78,19 @@ void AppPartsManager::addPart(ref_ptr<ApplicationPart> pPart)
8378 if (strPartName.empty ())
8479 pPart->setPartName (pPart->getTypeInfo ().getTypeName ());
8580
86- if (!addPartTry (pPart))
87- {
81+ if (!addPartTry (pPart)) {
8882 G_THROW_OR_DO (Exception (" AddPartError: Duplicate Part Found: \" %s\" " , strPartName.c_str ()), return );
8983 }
9084}
9185
9286
93- void AppPartsManager::addPart (ref_ptr<ApplicationPart> p_part, const qtd::string& part_name_id)
94- {
87+ void AppPartsManager::addPart (ref_ptr<ApplicationPart> p_part, const qtd::string& part_name_id) {
9588 p_part->setPartName (part_name_id);
9689 addPart (p_part);
9790}
9891
9992
100- void AppPartsManager::destroyPart (ref_ptr<ApplicationPart> pPart)
101- {
93+ void AppPartsManager::destroyPart (ref_ptr<ApplicationPart> pPart) {
10294 if (!pPart)
10395 return ;
10496
@@ -108,42 +100,36 @@ void AppPartsManager::destroyPart(ref_ptr<ApplicationPart> pPart)
108100
109101 m_pParts[nInd] = nullptr ;
110102
111- if (!pPart->isPartDone ())
112- {
103+ if (!pPart->isPartDone ()) {
113104 pPart->destroy ();
114105 pPart->setPartDone (true );
115106 }
116107 pPart = nullptr ;
117108}
118109
119110
120- void AppPartsManager::destroy ()
121- {
111+ void AppPartsManager::destroy () {
122112 // CLog1::CSection cs("Destroy All Application Parts");
123113
124- for (int i = 0 ; i < (int )m_pParts.size (); i++)
125- {
114+ for (int i = 0 ; i < (int )m_pParts.size (); i++) {
126115 int nPart = ((int )m_pParts.size () - 1 ) - i;
127116 ApplicationPart* pPart = m_pParts[nPart];
128117 if (!pPart)
129118 continue ;
130- if (!pPart->isPartDone ())
131- {
119+ if (!pPart->isPartDone ()) {
132120 qd::appMsg::ON_PRE_DESTROY p;
133121 pPart->onAppEventProcImp (p);
134122 }
135123 c_def (0 );
136124 }
137125
138- for (int i = 0 ; i < (int )m_pParts.size (); i++)
139- {
126+ for (int i = 0 ; i < (int )m_pParts.size (); i++) {
140127 int nPart = ((int )m_pParts.size () - 1 ) - i;
141128 ref_ptr<ApplicationPart> pPart = m_pParts[nPart];
142129 m_pParts[nPart] = nullptr ;
143130 if (!pPart)
144131 continue ;
145- if (!pPart->isPartDone ())
146- {
132+ if (!pPart->isPartDone ()) {
147133 pPart->destroy ();
148134 pPart->setPartDone (true );
149135 }
@@ -153,21 +139,17 @@ void AppPartsManager::destroy()
153139}
154140
155141
156- AppPartsManager::~AppPartsManager ()
157- {
142+ AppPartsManager::~AppPartsManager () {
158143 assert (m_pParts.empty ());
159144}
160145
161146
162- void AppPartsManager::update (float dt, float time)
163- {
147+ void AppPartsManager::update (float dt, float time) {
164148 m_timeNowFrame = (TTime64)std::time (nullptr );
165- for (int i = 0 ; i < getNumAppParts (); i++)
166- {
149+ for (int i = 0 ; i < getNumAppParts (); i++) {
167150 ApplicationPart* pCurPart = getPartByInd (i);
168151
169- if (pCurPart && pCurPart->hasMtd (EAppPartMtd::UPDATE))
170- {
152+ if (pCurPart && pCurPart->hasMtd (EAppPartMtd::UPDATE)) {
171153 pCurPart->updateActivateTime ();
172154 if (!pCurPart->isReadyToActivate ())
173155 continue ;
@@ -178,13 +160,10 @@ void AppPartsManager::update(float dt, float time)
178160}
179161
180162
181- qd::EFlow AppPartsManager::onSdlEventProc (SDL_Event& event)
182- {
183- for (int i = 0 ; i < getNumAppParts (); i++)
184- {
163+ qd::EFlow AppPartsManager::onSdlEventProc (SDL_Event& event) {
164+ for (int i = 0 ; i < getNumAppParts (); i++) {
185165 ApplicationPart* pCurPart = m_pParts[i];
186- if (pCurPart && pCurPart->hasMtd (EAppPartMtd::UPDATE))
187- {
166+ if (pCurPart && pCurPart->hasMtd (EAppPartMtd::UPDATE)) {
188167 qd::EFlow r = pCurPart->onSdlEventProc (event);
189168 if (r.isStop ())
190169 return r;
@@ -194,39 +173,33 @@ qd::EFlow AppPartsManager::onSdlEventProc(SDL_Event& event)
194173}
195174
196175
197- void AppPartsManager::render ()
198- {
176+ void AppPartsManager::render () {
199177 static qd::vector<ApplicationPart*> pActParts;
200178 pActParts.clear ();
201179
202180 // MAIN RENDER
203- for (int i = 0 ; i < getNumAppParts (); i++)
204- {
181+ for (int i = 0 ; i < getNumAppParts (); i++) {
205182 ApplicationPart* pCurPart = m_pParts[i];
206183 if (pCurPart && pCurPart->isPartRenderable ())
207184 pActParts.push_back (pCurPart);
208185 }
209186 eastl::stable_sort (pActParts.begin (), pActParts.end (), &_getZOrderSort);
210187
211- for (int i = 0 ; i < (int )pActParts.size (); ++i)
212- {
188+ for (int i = 0 ; i < (int )pActParts.size (); ++i) {
213189 ApplicationPart* pCurPart = pActParts[i];
214190 pCurPart->renderAppPart ();
215191 }
216192}
217193
218194
219- void AppPartsManager::onModuleMessageProc (qd::moduleMsg::BaseMsg& in_msg)
220- {
221- switch (in_msg.id )
222- {
195+ void AppPartsManager::onModuleMessageProc (qd::moduleMsg::BaseMsg& in_msg) {
196+ switch (in_msg.id ) {
223197 case qd::moduleMsg::RENDER_IMGUI_DEBUG_INFO_TREE::ID:
224198 {
225199 // auto p = static_cast<Enm::EModuleMsg::RENDER_IMGUI_DEBUG_INFO_TREE_t*>(pMsgData);
226200 // qd::ImAPI::CImGuiBase& im = p->im;
227201 // _onImGuiDebugControl(im);
228- }
229- break ;
202+ } break ;
230203 default :
231204 break ;
232205 }
@@ -235,23 +208,20 @@ void AppPartsManager::onModuleMessageProc(qd::moduleMsg::BaseMsg& in_msg)
235208}
236209
237210
238- void AppPartsManager::_onImGuiDebugControl (qd::ImAPI::CImGuiBase& /* im*/ )
239- {
211+ void AppPartsManager::_onImGuiDebugControl (qd::ImAPI::CImGuiBase& /* im*/ ) {
212+
240213#ifdef QDMOD_IMGUI
241- for (ApplicationPart* pCurPart : m_pParts)
242- {
214+ for (ApplicationPart* pCurPart : m_pParts) {
243215 if (!pCurPart)
244216 continue ;
245217
246218 if (!ImGui::TreeNodeEx (pCurPart, ImGuiTreeNodeFlags_Framed, CC (pCurPart->getPartName ()), 0 ))
247219 continue ;
248220
249- if (im.TreeNode (" BasePartInfo" ))
250- {
221+ if (im.TreeNode (" BasePartInfo" )) {
251222 im.Text (" Init: %i" , (int )pCurPart->m_bPartInit );
252223 bool bVis = pCurPart->isPartRenderable ();
253- if (im.Checkbox (" IsVisible" , &bVis))
254- {
224+ if (im.Checkbox (" IsVisible" , &bVis)) {
255225 pCurPart->setPartRenderable (bVis);
256226 }
257227 float zOrder = pCurPart->m_ZOrder .ToFloat ();
0 commit comments