comparison Framework/Layers/LayerSourceBase.h @ 90:64e60018943f wasm

fix and observer refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 May 2017 11:04:18 +0200
parents f244018a4e4b
children f8bce1bebe01
comparison
equal deleted inserted replaced
89:f244018a4e4b 90:64e60018943f
20 20
21 21
22 #pragma once 22 #pragma once
23 23
24 #include "ILayerSource.h" 24 #include "ILayerSource.h"
25 #include "../Toolbox/ObserversRegistry.h"
25 26
26 namespace OrthancStone 27 namespace OrthancStone
27 { 28 {
28 class LayerSourceBase : public ILayerSource 29 class LayerSourceBase : public ILayerSource
29 { 30 {
30 private: 31 private:
31 IObserver* observer_; 32 typedef ObserversRegistry<ILayerSource, IObserver> Observers;
33
34 Observers observers_;
32 35
33 protected: 36 protected:
34 IObserver* GetObserver() const 37 void NotifyGeometryReady();
35 { 38
36 return observer_; // TODO REMOVE THIS, FOR TEST 39 void NotifyGeometryError();
37 }
38 40
39 void NotifyContentChange(); 41 void NotifyContentChange();
40 42
41 void NotifySliceChange(const Slice& slice); 43 void NotifySliceChange(const Slice& slice);
42 44
43 // Takes ownership of "layer" (that cannot be "NULL")
44 void NotifyLayerReady(ILayerRenderer* layer, 45 void NotifyLayerReady(ILayerRenderer* layer,
45 const Slice& slice); 46 const Slice& slice);
46 47
47 void NotifyLayerError(const SliceGeometry& slice); 48 void NotifyLayerError(const SliceGeometry& slice);
48 49
49 public: 50 public:
50 LayerSourceBase() : 51 virtual void Register(IObserver& observer);
51 observer_(NULL)
52 {
53 }
54
55 virtual void SetObserver(IObserver& observer);
56 }; 52 };
57 } 53 }