Mercurial > hg > orthanc-stone
comparison Framework/Loaders/GenericLoadersContext.h @ 1228:c471a0aa137b broker
adding the next generation of loaders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Dec 2019 13:58:37 +0100 |
parents | |
children | b9b5d4378874 |
comparison
equal
deleted
inserted
replaced
1227:a1c0c9c9f9af | 1228:c471a0aa137b |
---|---|
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-2019 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/IMessageEmitter.h" | |
25 #include "../Oracle/ThreadedOracle.h" | |
26 #include "DicomSource.h" | |
27 #include "ILoaderFactory.h" | |
28 #include "OracleScheduler.h" | |
29 | |
30 #include <Core/HttpClient.h> | |
31 #include <Core/Toolbox.h> | |
32 | |
33 #include <boost/thread/recursive_mutex.hpp> | |
34 | |
35 namespace OrthancStone | |
36 { | |
37 class GenericLoadersContext : | |
38 public ILoadersContext, | |
39 private IMessageEmitter | |
40 { | |
41 private: | |
42 class Locker; | |
43 | |
44 // "Recursive mutex" is necessary, to be able to run | |
45 // "ILoaderFactory" from a message handler triggered by | |
46 // "EmitMessage()" | |
47 boost::recursive_mutex mutex_; | |
48 | |
49 IObservable oracleObservable_; | |
50 std::auto_ptr<ThreadedOracle> oracle_; | |
51 boost::shared_ptr<OracleScheduler> scheduler_; | |
52 | |
53 // Necessary to keep the loaders persistent (including global | |
54 // function promises), after the function that created them is | |
55 // left. This avoids creating one global variable for each loader. | |
56 std::list< boost::shared_ptr<IObserver> > loaders_; | |
57 | |
58 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, | |
59 const IMessage& message); | |
60 | |
61 public: | |
62 GenericLoadersContext(unsigned int maxHighPriority, | |
63 unsigned int maxStandardPriority, | |
64 unsigned int maxLowPriority); | |
65 | |
66 virtual ~GenericLoadersContext(); | |
67 | |
68 virtual ILock* Lock() ORTHANC_OVERRIDE; | |
69 | |
70 virtual void GetStatistics(uint64_t& scheduledCommands, | |
71 uint64_t& processedCommands) ORTHANC_OVERRIDE; | |
72 | |
73 void SetOrthancParameters(const Orthanc::WebServiceParameters& parameters); | |
74 | |
75 void SetRootDirectory(const std::string& root); | |
76 | |
77 void SetDicomCacheSize(size_t size); | |
78 | |
79 void StartOracle(); | |
80 | |
81 void StopOracle(); | |
82 | |
83 void WaitUntilComplete(); | |
84 }; | |
85 } |