Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Loaders/LoaderStateMachine.cpp @ 1314:9b126de2cde2 broker
Since the observer system now uses shared_ptr and many registrations are
done in the constructors, and since we cannot called shared_from_this() in
the constructors, it is mandatory to split construction from registration.
This has been done by making many ctors protected and replacing them
by factory methods that directly return shared_ptrs + added PostConstructor
method when base classes perform shared_from_this() calls too.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 16 Mar 2020 11:19:50 +0100 |
parents | 9bea7e15b519 |
children |
comparison
equal
deleted
inserted
replaced
1313:f30905f5d246 | 1314:9b126de2cde2 |
---|---|
172 using OrthancStone::ILoadersContext; | 172 using OrthancStone::ILoadersContext; |
173 | 173 |
174 LOG(TRACE) | 174 LOG(TRACE) |
175 << "LoaderStateMachine(" << std::hex << this | 175 << "LoaderStateMachine(" << std::hex << this |
176 << std::dec << ")::LoaderStateMachine()"; | 176 << std::dec << ")::LoaderStateMachine()"; |
177 | 177 } |
178 std::unique_ptr<ILoadersContext::ILock> lock(loadersContext_.Lock()); | 178 |
179 void LoaderStateMachine::PostConstructor() | |
180 { | |
181 std::unique_ptr<OrthancStone::ILoadersContext::ILock> | |
182 lock(loadersContext_.Lock()); | |
179 | 183 |
180 OrthancStone::IObservable& observable = lock->GetOracleObservable(); | 184 OrthancStone::IObservable& observable = lock->GetOracleObservable(); |
181 | 185 |
182 // TODO => Move this out of constructor WHY? | 186 // TODO => Move this out of constructor |
183 Register<OrthancStone::OrthancRestApiCommand::SuccessMessage>( | 187 Register<OrthancStone::OrthancRestApiCommand::SuccessMessage>( |
184 observable, &LoaderStateMachine::HandleSuccessMessage); | 188 observable, &LoaderStateMachine::HandleSuccessMessage); |
185 Register<OrthancStone::GetOrthancImageCommand::SuccessMessage>( | 189 Register<OrthancStone::GetOrthancImageCommand::SuccessMessage>( |
186 observable, &LoaderStateMachine::HandleSuccessMessage); | 190 observable, &LoaderStateMachine::HandleSuccessMessage); |
187 Register<OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage>( | 191 Register<OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage>( |