61 using Scalar =
typename Traits::Scalar;
62 enum { numPhases = 3 };
69 using Stone1Params =
typename Stone1Material::Params;
70 using Stone2Params =
typename Stone2Material::Params;
71 using DefaultParams =
typename DefaultMaterial::Params;
72 using TwoPhaseParams =
typename TwoPhaseMaterial::Params;
74 template <
class ParamT>
77 inline void operator () (
void* ptr )
79 delete static_cast< ParamT*
> (ptr);
83 using ParamPointerType = std::shared_ptr<void>;
98 setApproach( other.approach() );
104 setApproach( other.approach() );
108 void setApproach(EclMultiplexerApproach newApproach)
110 assert(realParams_ == 0);
111 approach_ = newApproach;
113 switch (approach()) {
114 case EclMultiplexerApproach::Stone1:
115 realParams_ = ParamPointerType(
new Stone1Params, Deleter< Stone1Params > () );
118 case EclMultiplexerApproach::Stone2:
119 realParams_ = ParamPointerType(
new Stone2Params, Deleter< Stone2Params > () );
122 case EclMultiplexerApproach::Default:
123 realParams_ = ParamPointerType(
new DefaultParams, Deleter< DefaultParams > () );
126 case EclMultiplexerApproach::TwoPhase:
127 realParams_ = ParamPointerType(
new TwoPhaseParams, Deleter< TwoPhaseParams > () );
130 case EclMultiplexerApproach::OnePhase:
136 EclMultiplexerApproach approach()
const
137 {
return approach_; }
140 template <EclMultiplexerApproach approachV>
141 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, Stone1Params>::type&
144 assert(approach() == approachV);
145 return this->
template castTo<Stone1Params>();
148 template <EclMultiplexerApproach approachV>
149 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, const Stone1Params>::type&
150 getRealParams()
const
152 assert(approach() == approachV);
153 return this->
template castTo<Stone1Params>();
157 template <EclMultiplexerApproach approachV>
158 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, Stone2Params>::type&
161 assert(approach() == approachV);
162 return this->
template castTo<Stone2Params>();
165 template <EclMultiplexerApproach approachV>
166 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, const Stone2Params>::type&
167 getRealParams()
const
169 assert(approach() == approachV);
170 return this->
template castTo<Stone2Params>();
174 template <EclMultiplexerApproach approachV>
175 typename std::enable_if<approachV == EclMultiplexerApproach::Default, DefaultParams>::type&
178 assert(approach() == approachV);
179 return this->
template castTo<DefaultParams>();
182 template <EclMultiplexerApproach approachV>
183 typename std::enable_if<approachV == EclMultiplexerApproach::Default, const DefaultParams>::type&
184 getRealParams()
const
186 assert(approach() == approachV);
187 return this->
template castTo<DefaultParams>();
191 template <EclMultiplexerApproach approachV>
192 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, TwoPhaseParams>::type&
195 assert(approach() == approachV);
196 return this->
template castTo<TwoPhaseParams>();
199 template <EclMultiplexerApproach approachV>
200 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, const TwoPhaseParams>::type&
201 getRealParams()
const
203 assert(approach() == approachV);
204 return this->
template castTo<TwoPhaseParams>();
207 template<
class Serializer>
208 void serializeOp(Serializer& serializer)
210 switch (approach()) {
211 case EclMultiplexerApproach::Stone1:
212 serializer(castTo<Stone1Params>());
215 case EclMultiplexerApproach::Stone2:
216 serializer(castTo<Stone2Params>());
219 case EclMultiplexerApproach::Default:
220 serializer(castTo<DefaultParams>());
223 case EclMultiplexerApproach::TwoPhase:
224 serializer(castTo<TwoPhaseParams>());
227 case EclMultiplexerApproach::OnePhase:
234 template <
class ParamT>
237 return *(
static_cast<ParamT *
> (realParams_.operator->()));
240 template <
class ParamT>
241 const ParamT& castTo()
const
243 return *(
static_cast<const ParamT *
> (realParams_.operator->()));
246 EclMultiplexerApproach approach_;
247 ParamPointerType realParams_;