Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Loaders/ILoadersContext.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Loaders/ILoadersContext.h@0ca50d275b9a |
children | 4fb8fdf03314 |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../Messages/IObserver.h" | |
25 #include "../Messages/IObservable.h" | |
26 #include "../Oracle/IOracleCommand.h" | |
27 | |
28 #include <boost/shared_ptr.hpp> | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 class ILoadersContext : public boost::noncopyable | |
33 { | |
34 public: | |
35 class ILock : public boost::noncopyable | |
36 { | |
37 public: | |
38 virtual ~ILock() | |
39 { | |
40 } | |
41 | |
42 /** | |
43 * This method is useful for loaders that must be able to | |
44 * re-lock the Stone loaders context in the future (for instance | |
45 * to schedule new commands once some command is processed). | |
46 **/ | |
47 virtual ILoadersContext& GetContext() const = 0; | |
48 | |
49 /** | |
50 * Get a reference to the observable against which a loader must | |
51 * listen to be informed of messages issued by the oracle once | |
52 * some command is processed. | |
53 **/ | |
54 virtual IObservable& GetOracleObservable() const = 0; | |
55 | |
56 /** | |
57 * Schedule a new command for further processing by the | |
58 * oracle. The "receiver" argument indicates to which object the | |
59 * notification messages are sent by the oracle upon completion | |
60 * of the command. The command is possibly not directly sent to | |
61 * the oracle: Instead, an internal "OracleScheduler" object is | |
62 * often used as a priority queue to rule the order in which | |
63 * commands are actually sent to the oracle. Hence the | |
64 * "priority" argument (commands with lower value are executed | |
65 * first). | |
66 **/ | |
67 virtual void Schedule(boost::shared_ptr<IObserver> receiver, | |
68 int priority, | |
69 IOracleCommand* command /* Takes ownership */) = 0; | |
70 | |
71 /** | |
72 * Cancel all the commands that are waiting in the | |
73 * "OracleScheduler" queue and that are linked to the given | |
74 * receiver (i.e. the observer that was specified at the time | |
75 * method "Schedule()" was called). This is useful for real-time | |
76 * processing, as it allows to replace commands that were | |
77 * scheduled in the past by more urgent commands. | |
78 * | |
79 * Note that this call does not affect commands that would have | |
80 * already be sent to the oracle. As a consequence, the receiver | |
81 * might still receive messages that were sent to the oracle | |
82 * before the cancellation (be prepared to handle such | |
83 * messages). | |
84 **/ | |
85 virtual void CancelRequests(boost::shared_ptr<IObserver> receiver) = 0; | |
86 | |
87 /** | |
88 * Same as "CancelRequests()", but targets all the receivers. | |
89 **/ | |
90 virtual void CancelAllRequests() = 0; | |
91 | |
92 /** | |
93 * Add a reference to the given observer in the Stone loaders | |
94 * context. This can be used to match the lifetime of a loader | |
95 * with the lifetime of the Stone context: This is useful if | |
96 * your Stone application does not keep a reference to the | |
97 * loader by itself (typically in global promises), which would | |
98 * make the loader disappear as soon as the scope of the | |
99 * variable is left. | |
100 **/ | |
101 virtual void AddLoader(boost::shared_ptr<IObserver> loader) = 0; | |
102 | |
103 /** | |
104 * Returns the number of commands that were scheduled and | |
105 * processed using the "Schedule()" method. By "processed" | |
106 * commands, we refer to the number of commands that were either | |
107 * executed by the oracle, or canceled by the user. So the | |
108 * counting sequences are monotonically increasing over time. | |
109 **/ | |
110 virtual void GetStatistics(uint64_t& scheduledCommands, | |
111 uint64_t& processedCommands) = 0; | |
112 }; | |
113 | |
114 virtual ~ILoadersContext() | |
115 { | |
116 } | |
117 | |
118 /** | |
119 * Locks the Stone loaders context, to give access to its | |
120 * underlying features. This is important for Stone applications | |
121 * running in a multi-threaded environment, for which a global | |
122 * mutex is locked. | |
123 **/ | |
124 virtual ILock* Lock() = 0; | |
125 }; | |
126 } |