annotate Framework/Messages/IMessage.h @ 724:5b16242cdc93

Fixed truncation warning
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 21 May 2019 10:39:14 +0200
parents f0008c55e5f7
children e713f1a99861 2d8ab34c8c91
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
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
24 #include <boost/noncopyable.hpp>
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
25
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
26 #include <string.h>
251
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 {
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
30 class MessageIdentifier
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
31 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
32 private:
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
33 const char* file_;
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
34 int line_;
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
35
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
36 public:
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
37 MessageIdentifier(const char* file,
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
38 int line) :
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
39 file_(file),
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
40 line_(line)
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
41 {
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
42 }
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
43
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
44 MessageIdentifier() :
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
45 file_(NULL),
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
46 line_(0)
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
47 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
48 }
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
49
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
50 bool operator< (const MessageIdentifier& other) const
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
51 {
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
52 if (file_ == NULL)
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
53 {
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
54 return false;
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
55 }
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
56 else if (line_ != other.line_)
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
57 {
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
58 return line_ < other.line_;
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
59 }
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
60 else
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
61 {
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
62 return strcmp(file_, other.file_) < 0;
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
63 }
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
64 }
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
65 };
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
66
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
67
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
68 /**
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
69 * Base messages that are exchanged between IObservable and
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
70 * IObserver. Messages are distinguished by the "__FILE__" and
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
71 * "__LINE__" macro, as in "Orthanc::SQLite::StatementId".
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
72 **/
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
73 class IMessage : public boost::noncopyable
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
74 {
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
75 public:
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
76 virtual ~IMessage()
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
77 {
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
78 }
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
79
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
80 virtual const MessageIdentifier& GetIdentifier() const = 0;
250
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
81 };
5e642859267e added new Observable/Observer & MessageBroker (not used yet)
am@osimis.io
parents:
diff changeset
82
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
83
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
84 /**
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
85 * Simple message implementation when no payload is needed but the
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
86 * origin is required. Sample usage:
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
87 * typedef OriginMessage<OrthancSlicesLoader> SliceGeometryErrorMessage;
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
88 **/
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
89 template <typename TOrigin>
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
90 class OriginMessage : public IMessage
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
91 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
92 private:
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
93 const TOrigin& origin_;
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 251
diff changeset
94
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
95 public:
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 397
diff changeset
96 OriginMessage(const TOrigin& origin) :
377
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 }
643
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
107
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
108
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
109 #define ORTHANC_STONE_MESSAGE(FILE, LINE) \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
110 public: \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
111 static const ::OrthancStone::MessageIdentifier& GetStaticIdentifier() \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
112 { \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
113 static const ::OrthancStone::MessageIdentifier id(FILE, LINE); \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
114 return id; \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
115 } \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
116 \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
117 virtual const ::OrthancStone::MessageIdentifier& GetIdentifier() const \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
118 { \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
119 return GetStaticIdentifier(); \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
120 }
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
121
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
122
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
123 #define ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(FILE, LINE, NAME, ORIGIN) \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
124 class NAME : public ::OrthancStone::OriginMessage<ORIGIN> \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
125 { \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
126 ORTHANC_STONE_MESSAGE(FILE, LINE); \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
127 \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
128 NAME(const ORIGIN& origin) : \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
129 OriginMessage(origin) \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
130 { \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
131 } \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
132 };
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
133
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
134
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
135 #define ORTHANC_STONE_DEFINE_EMPTY_MESSAGE(FILE, LINE, NAME) \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
136 class NAME : public ::OrthancStone::IMessage \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
137 { \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
138 ORTHANC_STONE_MESSAGE(FILE, LINE); \
f0008c55e5f7 getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
139 };