comparison Framework/Deprecated/Loaders/LoaderStateMachine.h @ 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
43 /** 43 /**
44 This class is supplied with Oracle commands and will schedule up to 44 This class is supplied with Oracle commands and will schedule up to
45 simultaneousDownloads_ of them at the same time, then will schedule the 45 simultaneousDownloads_ of them at the same time, then will schedule the
46 rest once slots become available. It is used, a.o., by the 46 rest once slots become available. It is used, a.o., by the
47 OrtancMultiframeVolumeLoader class. 47 OrtancMultiframeVolumeLoader class.
48
49 To use it, you need to create commands that derive from State.
50
51 You need to initialize them with the object that must be called when
52 an answer is received.
48 */ 53 */
54
49 class LoaderStateMachine : public OrthancStone::ObserverBase<LoaderStateMachine> 55 class LoaderStateMachine : public OrthancStone::ObserverBase<LoaderStateMachine>
50 { 56 {
51 protected: 57 public:
52 class State : public Orthanc::IDynamicObject 58 class State : public Orthanc::IDynamicObject
53 { 59 {
54 private: 60 private:
55 LoaderStateMachine& that_; 61 LoaderStateMachine& that_;
56 62
103 bool active_; 109 bool active_;
104 unsigned int simultaneousDownloads_; 110 unsigned int simultaneousDownloads_;
105 PendingCommands pendingCommands_; 111 PendingCommands pendingCommands_;
106 unsigned int activeCommands_; 112 unsigned int activeCommands_;
107 113
114
108 public: 115 public:
109 LoaderStateMachine(OrthancStone::ILoadersContext& loadersContext); 116 LoaderStateMachine(OrthancStone::ILoadersContext& loadersContext);
117
118 void PostConstructor();
110 119
111 virtual ~LoaderStateMachine(); 120 virtual ~LoaderStateMachine();
112 121
113 bool IsActive() const 122 bool IsActive() const
114 { 123 {