comparison Framework/Layers/LayerSourceBase.cpp @ 86:02c3a7a4938f wasm

removing of the Start() mechanism
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 13:42:50 +0200
parents f5f54ed8d307
children 4a541cd4fa83
comparison
equal deleted inserted replaced
85:bd48431ac285 86:02c3a7a4938f
25 25
26 namespace OrthancStone 26 namespace OrthancStone
27 { 27 {
28 void LayerSourceBase::NotifyGeometryReady() 28 void LayerSourceBase::NotifyGeometryReady()
29 { 29 {
30 if (!started_)
31 {
32 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
33 }
34
35 if (observer_ != NULL) 30 if (observer_ != NULL)
36 { 31 {
37 observer_->NotifyGeometryReady(*this); 32 observer_->NotifyGeometryReady(*this);
38 } 33 }
39 } 34 }
40 35
41 void LayerSourceBase::NotifyGeometryError() 36 void LayerSourceBase::NotifyGeometryError()
42 { 37 {
43 if (!started_)
44 {
45 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
46 }
47
48 if (observer_ != NULL) 38 if (observer_ != NULL)
49 { 39 {
50 observer_->NotifyGeometryError(*this); 40 observer_->NotifyGeometryError(*this);
51 } 41 }
52 } 42 }
53 43
54 void LayerSourceBase::NotifySourceChange() 44 void LayerSourceBase::NotifySourceChange()
55 { 45 {
56 if (!started_)
57 {
58 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
59 }
60
61 if (observer_ != NULL) 46 if (observer_ != NULL)
62 { 47 {
63 observer_->NotifySourceChange(*this); 48 observer_->NotifySourceChange(*this);
64 } 49 }
65 } 50 }
66 51
67 void LayerSourceBase::NotifySliceChange(const Slice& slice) 52 void LayerSourceBase::NotifySliceChange(const Slice& slice)
68 { 53 {
69 if (!started_)
70 {
71 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
72 }
73
74 if (observer_ != NULL) 54 if (observer_ != NULL)
75 { 55 {
76 observer_->NotifySliceChange(*this, slice); 56 observer_->NotifySliceChange(*this, slice);
77 } 57 }
78 } 58 }
80 void LayerSourceBase::NotifyLayerReady(ILayerRenderer* layer, 60 void LayerSourceBase::NotifyLayerReady(ILayerRenderer* layer,
81 const Slice& slice) 61 const Slice& slice)
82 { 62 {
83 std::auto_ptr<ILayerRenderer> tmp(layer); 63 std::auto_ptr<ILayerRenderer> tmp(layer);
84 64
85 if (!started_)
86 {
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
88 }
89
90 if (layer == NULL) 65 if (layer == NULL)
91 { 66 {
92 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 67 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
93 } 68 }
94 69
98 } 73 }
99 } 74 }
100 75
101 void LayerSourceBase::NotifyLayerError(const SliceGeometry& slice) 76 void LayerSourceBase::NotifyLayerError(const SliceGeometry& slice)
102 { 77 {
103 if (!started_)
104 {
105 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
106 }
107
108 if (observer_ != NULL) 78 if (observer_ != NULL)
109 { 79 {
110 observer_->NotifyLayerError(*this, slice); 80 observer_->NotifyLayerError(*this, slice);
111 } 81 }
112 } 82 }
113 83
114 void LayerSourceBase::SetObserver(IObserver& observer) 84 void LayerSourceBase::SetObserver(IObserver& observer)
115 { 85 {
116 if (started_)
117 {
118 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
119 }
120
121 if (observer_ == NULL) 86 if (observer_ == NULL)
122 { 87 {
123 observer_ = &observer; 88 observer_ = &observer;
124 } 89 }
125 else 90 else
126 { 91 {
127 // Cannot add more than one observer 92 // Cannot add more than one observer
128 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 93 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
129 } 94 }
130 } 95 }
131
132 void LayerSourceBase::Start()
133 {
134 if (started_)
135 {
136 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
137 }
138 else
139 {
140 started_ = true;
141 StartInternal();
142 }
143 }
144 } 96 }