annotate Framework/Messages/IMessage.h @ 542:efdf45c5aeb0

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Mar 2019 12:38:48 +0100
parents b70e9be013e4
children 9cd19b28f011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 406
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
250
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 #pragma once
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
23
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
24 #include "../StoneEnumerations.h"
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
25
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 250
diff changeset
26 #include <boost/noncopyable.hpp>
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 250
diff changeset
27
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
28 namespace OrthancStone
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
29 {
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
30 // base message that are exchanged between IObservable and IObserver
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
31 class IMessage : public boost::noncopyable
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
32 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
33 private:
302
4a79193ffb58 support for custom messages + no leaks in unit-tests
am@osimis.io
parents: 299
diff changeset
34 int messageType_;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
35
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
36 protected:
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
37 IMessage(const int& messageType) :
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
38 messageType_(messageType)
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
39 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
40 }
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
41
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
42 public:
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
43 virtual ~IMessage()
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
44 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
45 }
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
46
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
47 virtual int GetType() const
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
48 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
49 return messageType_;
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
50 }
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
51 };
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
52
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
53
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
54 // base class to derive from to implement your own messages
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
55 // it handles the message type for you
302
4a79193ffb58 support for custom messages + no leaks in unit-tests
am@osimis.io
parents: 299
diff changeset
56 template <int type>
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
57 class BaseMessage : public IMessage
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
58 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
59 public:
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
60 enum
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
61 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
62 Type = type
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
63 };
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
64
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
65 BaseMessage() :
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
66 IMessage(static_cast<int>(Type))
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
67 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
68 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
69 };
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
70
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
71
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
72 // simple message implementation when no payload is needed
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
73 // sample usage:
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
74 // typedef NoPayloadMessage<MessageType_VolumeSlicer_GeometryReady> GeometryReadyMessage;
304
am@osimis.io
parents: 302
diff changeset
75 template <int type>
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
76 class NoPayloadMessage : public BaseMessage<type>
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
77 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
78 public:
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
79 NoPayloadMessage() :
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
80 BaseMessage<type>()
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
81 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
82 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
83 };
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
84
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
85 // simple message implementation when no payload is needed but the origin is required
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
86 // sample usage:
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
87 // typedef OriginMessage<MessageType_SliceLoader_GeometryError, OrthancSlicesLoader> SliceGeometryErrorMessage;
304
am@osimis.io
parents: 302
diff changeset
88 template <int type, typename TOrigin>
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
89 class OriginMessage : public BaseMessage<type>
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
90 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
91 private:
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 397
diff changeset
92 const TOrigin& origin_;
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
93
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
94 public:
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 397
diff changeset
95 OriginMessage(const TOrigin& origin) :
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
96 BaseMessage<type>(),
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
97 origin_(origin)
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
98 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
99 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
100
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 397
diff changeset
101 const TOrigin& GetOrigin() const
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
102 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
103 return origin_;
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
104 }
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
105 };
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
106 }