Mercurial > hg > orthanc-stone
changeset 643:f0008c55e5f7
getting rid of MessageType enumeration
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 10 May 2019 17:34:48 +0200 |
parents | 7ca8dc7ec17b |
children | b4fe9642e83b |
files | Framework/Layers/DicomSeriesVolumeSlicer.h Framework/Layers/IVolumeSlicer.h Framework/Messages/ICallable.h Framework/Messages/IMessage.h Framework/Messages/IObservable.cpp Framework/Messages/IObservable.h Framework/Radiography/RadiographyLayer.h Framework/Radiography/RadiographyScene.h Framework/Scene2D/ColorSceneLayer.h Framework/StoneEnumerations.h Framework/Toolbox/IDelayedCallExecutor.h Framework/Toolbox/IWebService.h Framework/Toolbox/OrthancApiClient.h Framework/Toolbox/OrthancSlicesLoader.h Framework/Viewport/IViewport.h Framework/Volumes/ISlicedVolume.h Framework/Volumes/IVolumeLoader.h Framework/Widgets/SliceViewerWidget.h Samples/Sdl/Loader.cpp UnitTestsSources/TestMessageBroker.cpp |
diffstat | 20 files changed, 203 insertions(+), 234 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Layers/DicomSeriesVolumeSlicer.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Layers/DicomSeriesVolumeSlicer.h Fri May 10 17:34:48 2019 +0200 @@ -38,8 +38,10 @@ { public: // TODO: Add "frame" and "instanceId" - class FrameReadyMessage : public OriginMessage<MessageType_DicomSeriesVolumeSlicer_FrameReady, DicomSeriesVolumeSlicer> + class FrameReadyMessage : public OriginMessage<DicomSeriesVolumeSlicer> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const Orthanc::ImageAccessor& frame_; SliceImageQuality imageQuality_;
--- a/Framework/Layers/IVolumeSlicer.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Layers/IVolumeSlicer.h Fri May 10 17:34:48 2019 +0200 @@ -33,18 +33,20 @@ class IVolumeSlicer : public IObservable { public: - typedef OriginMessage<MessageType_VolumeSlicer_GeometryReady, IVolumeSlicer> GeometryReadyMessage; - typedef OriginMessage<MessageType_VolumeSlicer_GeometryError, IVolumeSlicer> GeometryErrorMessage; - typedef OriginMessage<MessageType_VolumeSlicer_ContentChanged, IVolumeSlicer> ContentChangedMessage; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryReadyMessage, IVolumeSlicer); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryErrorMessage, IVolumeSlicer); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, ContentChangedMessage, IVolumeSlicer); - class SliceContentChangedMessage : public OriginMessage<MessageType_VolumeSlicer_SliceChanged, IVolumeSlicer> + class SliceContentChangedMessage : public OriginMessage<IVolumeSlicer> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const Slice& slice_; public: SliceContentChangedMessage(IVolumeSlicer& origin, - const Slice& slice) : + const Slice& slice) : OriginMessage(origin), slice_(slice) { @@ -57,8 +59,10 @@ }; - class LayerReadyMessage : public OriginMessage<MessageType_VolumeSlicer_LayerReady, IVolumeSlicer> + class LayerReadyMessage : public OriginMessage<IVolumeSlicer> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + public: class IRendererFactory : public boost::noncopyable { @@ -96,8 +100,10 @@ }; - class LayerErrorMessage : public OriginMessage<MessageType_VolumeSlicer_LayerError, IVolumeSlicer> + class LayerErrorMessage : public OriginMessage<IVolumeSlicer> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const CoordinateSystem3D& slice_;
--- a/Framework/Messages/ICallable.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Messages/ICallable.h Fri May 10 17:34:48 2019 +0200 @@ -41,7 +41,8 @@ virtual void Apply(const IMessage& message) = 0; - virtual MessageType GetMessageType() const = 0; + virtual const MessageIdentifier& GetMessageIdentifier() = 0; + virtual IObserver* GetObserver() const = 0; }; @@ -58,8 +59,8 @@ private: typedef void (TObserver::* MemberFunction) (const TMessage&); - TObserver& observer_; - MemberFunction function_; + TObserver& observer_; + MemberFunction function_; public: Callable(TObserver& observer, @@ -79,9 +80,9 @@ ApplyInternal(dynamic_cast<const TMessage&>(message)); } - virtual MessageType GetMessageType() const + virtual const MessageIdentifier& GetMessageIdentifier() { - return static_cast<MessageType>(TMessage::Type); + return TMessage::GetStaticIdentifier(); } virtual IObserver* GetObserver() const @@ -115,11 +116,6 @@ lambda_(dynamic_cast<const TMessage&>(message)); } - virtual MessageType GetMessageType() const - { - return static_cast<MessageType>(TMessage::Type); - } - virtual IObserver* GetObserver() const { return &observer_;
--- a/Framework/Messages/IMessage.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Messages/IMessage.h Fri May 10 17:34:48 2019 +0200 @@ -21,79 +21,79 @@ #pragma once -#include "../StoneEnumerations.h" +#include <boost/noncopyable.hpp> -#include <boost/noncopyable.hpp> +#include <string.h> namespace OrthancStone { - // base message that are exchanged between IObservable and IObserver - class IMessage : public boost::noncopyable + class MessageIdentifier { private: - MessageType messageType_; - - protected: - IMessage(MessageType messageType) : - messageType_(messageType) + const char* file_; + int line_; + + public: + MessageIdentifier(const char* file, + int line) : + file_(file), + line_(line) + { + } + + MessageIdentifier() : + file_(NULL), + line_(0) { } + + bool operator< (const MessageIdentifier& other) const + { + if (file_ == NULL) + { + return false; + } + else if (line_ != other.line_) + { + return line_ < other.line_; + } + else + { + return strcmp(file_, other.file_) < 0; + } + } + }; + + /** + * Base messages that are exchanged between IObservable and + * IObserver. Messages are distinguished by the "__FILE__" and + * "__LINE__" macro, as in "Orthanc::SQLite::StatementId". + **/ + class IMessage : public boost::noncopyable + { public: virtual ~IMessage() { } - virtual MessageType GetType() const - { - return messageType_; - } + virtual const MessageIdentifier& GetIdentifier() const = 0; }; - // base class to derive from to implement your own messages - // it handles the message type for you - template <MessageType type> - class BaseMessage : public IMessage - { - public: - enum - { - Type = type - }; - - BaseMessage() : - IMessage(static_cast<MessageType>(Type)) - { - } - }; - - - // simple message implementation when no payload is needed - // sample usage: - // typedef NoPayloadMessage<MessageType_VolumeSlicer_GeometryReady> GeometryReadyMessage; - template <MessageType type> - class NoPayloadMessage : public BaseMessage<type> - { - public: - NoPayloadMessage() : - BaseMessage<type>() - { - } - }; - - // simple message implementation when no payload is needed but the origin is required - // sample usage: - // typedef OriginMessage<MessageType_SliceLoader_GeometryError, OrthancSlicesLoader> SliceGeometryErrorMessage; - template <MessageType type, typename TOrigin> - class OriginMessage : public BaseMessage<type> + /** + * Simple message implementation when no payload is needed but the + * origin is required. Sample usage: + * typedef OriginMessage<OrthancSlicesLoader> SliceGeometryErrorMessage; + **/ + template <typename TOrigin> + class OriginMessage : public IMessage { private: - const TOrigin& origin_; + const TOrigin& origin_; public: OriginMessage(const TOrigin& origin) : - BaseMessage<type>(), origin_(origin) { } @@ -104,3 +104,36 @@ } }; } + + +#define ORTHANC_STONE_MESSAGE(FILE, LINE) \ + public: \ + static const ::OrthancStone::MessageIdentifier& GetStaticIdentifier() \ + { \ + static const ::OrthancStone::MessageIdentifier id(FILE, LINE); \ + return id; \ + } \ + \ + virtual const ::OrthancStone::MessageIdentifier& GetIdentifier() const \ + { \ + return GetStaticIdentifier(); \ + } + + +#define ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(FILE, LINE, NAME, ORIGIN) \ + class NAME : public ::OrthancStone::OriginMessage<ORIGIN> \ + { \ + ORTHANC_STONE_MESSAGE(FILE, LINE); \ + \ + NAME(const ORIGIN& origin) : \ + OriginMessage(origin) \ + { \ + } \ + }; + + +#define ORTHANC_STONE_DEFINE_EMPTY_MESSAGE(FILE, LINE, NAME) \ + class NAME : public ::OrthancStone::IMessage \ + { \ + ORTHANC_STONE_MESSAGE(FILE, LINE); \ + };
--- a/Framework/Messages/IObservable.cpp Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Messages/IObservable.cpp Fri May 10 17:34:48 2019 +0200 @@ -59,9 +59,8 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); } - MessageType messageType = callable->GetMessageType(); - - callables_[messageType].insert(callable); + const MessageIdentifier& id = callable->GetMessageIdentifier(); + callables_[id].insert(callable); } void IObservable::Unregister(IObserver *observer) @@ -87,7 +86,7 @@ void IObservable::EmitMessageInternal(const IObserver* receiver, const IMessage& message) { - Callables::const_iterator found = callables_.find(message.GetType()); + Callables::const_iterator found = callables_.find(message.GetIdentifier()); if (found != callables_.end()) {
--- a/Framework/Messages/IObservable.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Messages/IObservable.h Fri May 10 17:34:48 2019 +0200 @@ -35,8 +35,9 @@ class IObservable : public boost::noncopyable { private: - typedef std::map<int, std::set<ICallable*> > Callables; - typedef std::set<IMessageForwarder*> Forwarders; + typedef std::map<MessageIdentifier, std::set<ICallable*> > Callables; + + typedef std::set<IMessageForwarder*> Forwarders; MessageBroker& broker_; Callables callables_;
--- a/Framework/Radiography/RadiographyLayer.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Radiography/RadiographyLayer.h Fri May 10 17:34:48 2019 +0200 @@ -55,18 +55,7 @@ friend class RadiographyScene; public: - class LayerEditedMessage : - public OriginMessage<MessageType_RadiographyLayer_Edited, RadiographyLayer> - { - private: - - public: - LayerEditedMessage(const RadiographyLayer& origin) : - OriginMessage(origin) - { - } - }; - + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, LayerEditedMessage, RadiographyLayer); class Geometry {
--- a/Framework/Radiography/RadiographyScene.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Radiography/RadiographyScene.h Fri May 10 17:34:48 2019 +0200 @@ -37,9 +37,10 @@ public IObservable { public: - class GeometryChangedMessage : - public OriginMessage<MessageType_RadiographyScene_GeometryChanged, RadiographyScene> + class GeometryChangedMessage : public OriginMessage<RadiographyScene> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: RadiographyLayer& layer_; @@ -57,9 +58,10 @@ } }; - class ContentChangedMessage : - public OriginMessage<MessageType_RadiographyScene_ContentChanged, RadiographyScene> + class ContentChangedMessage : public OriginMessage<RadiographyScene> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: RadiographyLayer& layer_; @@ -77,9 +79,10 @@ } }; - class LayerEditedMessage : - public OriginMessage<MessageType_RadiographyScene_LayerEdited, RadiographyScene> + class LayerEditedMessage : public OriginMessage<RadiographyScene> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const RadiographyLayer& layer_; @@ -95,20 +98,12 @@ { return layer_; } - }; - class WindowingChangedMessage : - public OriginMessage<MessageType_RadiographyScene_WindowingChanged, RadiographyScene> - { - public: - WindowingChangedMessage(const RadiographyScene& origin) : - OriginMessage(origin) - { - } - }; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, WindowingChangedMessage, RadiographyScene); + class LayerAccessor : public boost::noncopyable { private:
--- a/Framework/Scene2D/ColorSceneLayer.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Scene2D/ColorSceneLayer.h Fri May 10 17:34:48 2019 +0200 @@ -35,17 +35,20 @@ uint8_t green_; uint8_t blue_; uint64_t revision_; + protected: void BumpRevision() { - // this is *not* thread-safe!!! + // this is *not* thread-safe!!! => (SJO) no problem, Stone assumes mono-threading revision_++; } + public: ColorSceneLayer() : red_(255), green_(255), - blue_(255) + blue_(255), + revision_(0) { }
--- a/Framework/StoneEnumerations.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/StoneEnumerations.h Fri May 10 17:34:48 2019 +0200 @@ -115,74 +115,6 @@ BitmapAnchor_TopRight }; - enum MessageType - { - MessageType_Widget_GeometryChanged, - MessageType_Widget_ContentChanged, - - MessageType_VolumeSlicer_GeometryReady, // instance tags have been loaded - MessageType_VolumeSlicer_GeometryError, - MessageType_VolumeSlicer_ContentChanged, - MessageType_VolumeSlicer_SliceChanged, - MessageType_VolumeSlicer_LayerReady, // layer is ready to be rendered - MessageType_VolumeSlicer_LayerError, - - MessageType_DicomSeriesVolumeSlicer_FrameReady, // pixels data of the frame have been loaded - - MessageType_SliceViewerWidget_DisplayedSlice, // The displayed slice has changed - - MessageType_SliceLoader_GeometryReady, - MessageType_SliceLoader_GeometryError, - MessageType_SliceLoader_ImageReady, - MessageType_SliceLoader_ImageError, - - MessageType_VolumeLoader_GeometryReady, - MessageType_VolumeLoader_GeometryError, - MessageType_VolumeLoader_ContentChanged, // Content of several slices in the loader has changed - - MessageType_SlicedVolume_GeometryReady, - MessageType_SlicedVolume_GeometryError, - MessageType_SlicedVolume_VolumeReady, - MessageType_SlicedVolume_ContentChanged, - MessageType_SlicedVolume_SliceContentChanged, - - MessageType_HttpRequestSuccess, - MessageType_HttpRequestError, - - MessageType_OrthancApi_InternalGetJsonResponseReady, - MessageType_OrthancApi_InternalGetJsonResponseError, - - MessageType_OrthancApi_GenericGetJson_Ready, - MessageType_OrthancApi_GenericGetBinary_Ready, - MessageType_OrthancApi_GenericHttpError_Ready, - MessageType_OrthancApi_GenericEmptyResponse_Ready, - - MessageType_RadiographyScene_GeometryChanged, - MessageType_RadiographyScene_ContentChanged, - MessageType_RadiographyScene_LayerEdited, - MessageType_RadiographyScene_WindowingChanged, - - MessageType_RadiographyLayer_Edited, - - MessageType_ViewportChanged, - - MessageType_Timeout, - - // used in unit tests only - MessageType_Test1, - MessageType_Test2, - - - - MessageType_OrthancRestApiCommand, - MessageType_GetOrthancImageCommand, - MessageType_GetOrthancWebViewerJpegCommand, - MessageType_OracleCommandExceptionMessage, - - MessageType_CustomMessage // Custom messages ids ust be greater than this (this one must remain in last position) - }; - - enum ControlPointType { ControlPoint_TopLeftCorner = 0,
--- a/Framework/Toolbox/IDelayedCallExecutor.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Toolbox/IDelayedCallExecutor.h Fri May 10 17:34:48 2019 +0200 @@ -39,8 +39,7 @@ MessageBroker& broker_; public: - - typedef NoPayloadMessage<MessageType_Timeout> TimeoutMessage; + ORTHANC_STONE_DEFINE_EMPTY_MESSAGE(__FILE__, __LINE__, TimeoutMessage); IDelayedCallExecutor(MessageBroker& broker) : broker_(broker)
--- a/Framework/Toolbox/IWebService.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Toolbox/IWebService.h Fri May 10 17:34:48 2019 +0200 @@ -45,8 +45,10 @@ public: typedef std::map<std::string, std::string> HttpHeaders; - class HttpRequestSuccessMessage : public BaseMessage<MessageType_HttpRequestSuccess> + class HttpRequestSuccessMessage : public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const std::string& uri_; const void* answer_; @@ -97,8 +99,10 @@ }; - class HttpRequestErrorMessage : public BaseMessage<MessageType_HttpRequestError> + class HttpRequestErrorMessage : public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const std::string& uri_; const Orthanc::IDynamicObject* payload_;
--- a/Framework/Toolbox/OrthancApiClient.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Toolbox/OrthancApiClient.h Fri May 10 17:34:48 2019 +0200 @@ -35,9 +35,10 @@ public IObserver { public: - class JsonResponseReadyMessage : - public BaseMessage<MessageType_OrthancApi_GenericGetJson_Ready> + class JsonResponseReadyMessage : public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const std::string& uri_; const Json::Value& json_; @@ -72,9 +73,10 @@ }; - class BinaryResponseReadyMessage : - public BaseMessage<MessageType_OrthancApi_GenericGetBinary_Ready> + class BinaryResponseReadyMessage : public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const std::string& uri_; const void* answer_; @@ -117,9 +119,10 @@ }; - class EmptyResponseReadyMessage : - public BaseMessage<MessageType_OrthancApi_GenericEmptyResponse_Ready> + class EmptyResponseReadyMessage : public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const std::string& uri_; const Orthanc::IDynamicObject* payload_;
--- a/Framework/Toolbox/OrthancSlicesLoader.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Toolbox/OrthancSlicesLoader.h Fri May 10 17:34:48 2019 +0200 @@ -35,13 +35,14 @@ class OrthancSlicesLoader : public IObservable, public IObserver { public: - - typedef OriginMessage<MessageType_SliceLoader_GeometryReady, OrthancSlicesLoader> SliceGeometryReadyMessage; - typedef OriginMessage<MessageType_SliceLoader_GeometryError, OrthancSlicesLoader> SliceGeometryErrorMessage; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, SliceGeometryReadyMessage, OrthancSlicesLoader); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, SliceGeometryErrorMessage, OrthancSlicesLoader); - class SliceImageReadyMessage : - public OriginMessage<MessageType_SliceLoader_ImageReady, OrthancSlicesLoader> + + class SliceImageReadyMessage : public OriginMessage<OrthancSlicesLoader> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: unsigned int sliceIndex_; const Slice& slice_; @@ -84,9 +85,10 @@ }; - class SliceImageErrorMessage : - public OriginMessage<MessageType_SliceLoader_ImageError, OrthancSlicesLoader> + class SliceImageErrorMessage : public OriginMessage<OrthancSlicesLoader> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const Slice& slice_; unsigned int sliceIndex_;
--- a/Framework/Viewport/IViewport.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Viewport/IViewport.h Fri May 10 17:34:48 2019 +0200 @@ -35,7 +35,7 @@ class IViewport : public IObservable { public: - typedef OriginMessage<MessageType_ViewportChanged, IViewport> ViewportChangedMessage; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, ViewportChangedMessage, IViewport); IViewport(MessageBroker& broker) : IObservable(broker)
--- a/Framework/Volumes/ISlicedVolume.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Volumes/ISlicedVolume.h Fri May 10 17:34:48 2019 +0200 @@ -29,14 +29,16 @@ class ISlicedVolume : public IObservable { public: - typedef OriginMessage<MessageType_SlicedVolume_ContentChanged, ISlicedVolume> ContentChangedMessage; - typedef OriginMessage<MessageType_SlicedVolume_GeometryError, ISlicedVolume> GeometryErrorMessage; - typedef OriginMessage<MessageType_SlicedVolume_GeometryReady, ISlicedVolume> GeometryReadyMessage; - typedef OriginMessage<MessageType_SlicedVolume_VolumeReady, ISlicedVolume> VolumeReadyMessage; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, ContentChangedMessage, ISlicedVolume); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryErrorMessage, ISlicedVolume); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryReadyMessage, ISlicedVolume); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, VolumeReadyMessage, ISlicedVolume); - class SliceContentChangedMessage : - public OriginMessage<MessageType_SlicedVolume_SliceContentChanged, ISlicedVolume> + + class SliceContentChangedMessage : public OriginMessage<ISlicedVolume> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: size_t sliceIndex_; const Slice& slice_;
--- a/Framework/Volumes/IVolumeLoader.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Volumes/IVolumeLoader.h Fri May 10 17:34:48 2019 +0200 @@ -28,9 +28,9 @@ class IVolumeLoader : public IObservable { public: - typedef OriginMessage<MessageType_VolumeLoader_GeometryReady, IVolumeLoader> GeometryReadyMessage; - typedef OriginMessage<MessageType_VolumeLoader_GeometryError, IVolumeLoader> GeometryErrorMessage; - typedef OriginMessage<MessageType_VolumeLoader_ContentChanged, IVolumeLoader> ContentChangedMessage; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryReadyMessage, IVolumeLoader); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryErrorMessage, IVolumeLoader); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, ContentChangedMessage, IVolumeLoader); IVolumeLoader(MessageBroker& broker) : IObservable(broker)
--- a/Framework/Widgets/SliceViewerWidget.h Fri May 10 14:54:03 2019 +0200 +++ b/Framework/Widgets/SliceViewerWidget.h Fri May 10 17:34:48 2019 +0200 @@ -36,12 +36,15 @@ public IObservable { public: - typedef OriginMessage<MessageType_Widget_GeometryChanged, SliceViewerWidget> GeometryChangedMessage; - typedef OriginMessage<MessageType_Widget_ContentChanged, SliceViewerWidget> ContentChangedMessage; + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryChangedMessage, SliceViewerWidget); + ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, ContentChangedMessage, SliceViewerWidget); + // TODO - Use this message in ReferenceLineSource - class DisplayedSliceMessage : public OriginMessage<MessageType_SliceViewerWidget_DisplayedSlice, SliceViewerWidget> + class DisplayedSliceMessage : public OriginMessage<SliceViewerWidget> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const Slice& slice_;
--- a/Samples/Sdl/Loader.cpp Fri May 10 14:54:03 2019 +0200 +++ b/Samples/Sdl/Loader.cpp Fri May 10 17:34:48 2019 +0200 @@ -139,9 +139,10 @@ - class OracleCommandExceptionMessage : - public OrthancStone::BaseMessage<OrthancStone::MessageType_OracleCommandExceptionMessage> + class OracleCommandExceptionMessage : public OrthancStone::IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: const IOracleCommand& command_; Orthanc::OrthancException exception_; @@ -178,9 +179,10 @@ class OrthancRestApiCommand : public OracleCommandWithPayload { public: - class SuccessMessage : public OrthancStone::OriginMessage<OrthancStone::MessageType_OrthancRestApiCommand, - OrthancRestApiCommand> + class SuccessMessage : public OrthancStone::OriginMessage<OrthancRestApiCommand> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: HttpHeaders headers_; std::string answer_; @@ -316,9 +318,10 @@ class GetOrthancImageCommand : public OracleCommandWithPayload { public: - class SuccessMessage : public OrthancStone::OriginMessage<OrthancStone::MessageType_GetOrthancImageCommand, - GetOrthancImageCommand> + class SuccessMessage : public OrthancStone::OriginMessage<GetOrthancImageCommand> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: std::auto_ptr<Orthanc::ImageAccessor> image_; Orthanc::MimeType mime_; @@ -461,9 +464,10 @@ class GetOrthancWebViewerJpegCommand : public OracleCommandWithPayload { public: - class SuccessMessage : public OrthancStone::OriginMessage<OrthancStone::MessageType_GetOrthancWebViewerJpegCommand, - GetOrthancWebViewerJpegCommand> + class SuccessMessage : public OrthancStone::OriginMessage<GetOrthancWebViewerJpegCommand> { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + private: std::auto_ptr<Orthanc::ImageAccessor> image_;
--- a/UnitTestsSources/TestMessageBroker.cpp Fri May 10 14:54:03 2019 +0200 +++ b/UnitTestsSources/TestMessageBroker.cpp Fri May 10 17:34:48 2019 +0200 @@ -34,32 +34,25 @@ using namespace OrthancStone; - enum CustomMessageType - { - CustomMessageType_First = MessageType_CustomMessage + 1, - - CustomMessageType_Completed, - CustomMessageType_Increment - }; - - class MyObservable : public IObservable { public: - struct MyCustomMessage: public BaseMessage<(MessageType) CustomMessageType_Completed> + struct MyCustomMessage : public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + int payload_; - MyCustomMessage(int payload) - : BaseMessage(), - payload_(payload) - {} + MyCustomMessage(int payload) : + payload_(payload) + { + } }; - MyObservable(MessageBroker& broker) - : IObservable(broker) - {} - + MyObservable(MessageBroker& broker) : + IObservable(broker) + { + } }; class MyObserver : public IObserver @@ -94,15 +87,18 @@ class MyPromiseSource : public IObservable { Promise* currentPromise_; + public: - struct MyPromiseMessage: public BaseMessage<MessageType_Test1> + struct MyPromiseMessage: public IMessage { + ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); + int increment; - MyPromiseMessage(int increment) - : BaseMessage(), - increment(increment) - {} + MyPromiseMessage(int increment) : + increment(increment) + { + } }; MyPromiseSource(MessageBroker& broker)