Mercurial > hg > orthanc-stone
annotate Framework/Messages/MessageBroker.cpp @ 264:6b98ac45aaee am-2
documented how to compile and execute WASM samples
author | am@osimis.io |
---|---|
date | Tue, 21 Aug 2018 16:36:01 +0200 |
parents | e5a9b3d03478 |
children | c9cf95b49a86 |
rev | line source |
---|---|
250
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
1 /** |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
6 * |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
11 * |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
16 * |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
19 **/ |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
20 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
21 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
22 #include "MessageBroker.h" |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
23 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
24 #include <algorithm> |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
25 #include <assert.h> |
253 | 26 #include <vector> |
250
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
27 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
28 #include "IObserver.h" |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
29 #include "MessageType.h" |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
30 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
31 namespace OrthancStone { |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
32 |
258 | 33 void MessageBroker::EmitMessage(IObservable& from, std::set<IObserver*> observers, const IMessage& message) |
250
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
34 { |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
35 std::vector<IObserver*> activeObservers; |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
36 std::set_intersection(observers.begin(), |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
37 observers.end(), |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
38 activeObservers_.begin(), |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
39 activeObservers_.end(), |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
40 std::back_inserter(activeObservers) |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
41 ); |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
42 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
43 for (std::vector<IObserver*>::iterator observer = activeObservers.begin(); observer != activeObservers.end(); observer++) |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
44 { |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
45 (*observer)->HandleMessage(from, message); |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
46 } |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
47 } |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
48 |
5e642859267e
added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff
changeset
|
49 } |