76 using Scalar =
typename Traits::Scalar;
77 enum { numPhases = 3 };
84 using Stone1Params =
typename Stone1Material::Params;
85 using Stone2Params =
typename Stone2Material::Params;
86 using DefaultParams =
typename DefaultMaterial::Params;
87 using TwoPhaseParams =
typename TwoPhaseMaterial::Params;
89 template <
class ParamT>
92 inline void operator () (
void* ptr )
94 delete static_cast< ParamT*
> (ptr);
98 using ParamPointerType = std::shared_ptr<void>;
113 setApproach( other.approach() );
119 setApproach( other.approach() );
123 void setApproach(EclMultiplexerApproach newApproach)
125 assert(realParams_ == 0);
126 approach_ = newApproach;
128 switch (approach()) {
129 case EclMultiplexerApproach::Stone1:
130 realParams_ = ParamPointerType(
new Stone1Params, Deleter< Stone1Params > () );
133 case EclMultiplexerApproach::Stone2:
134 realParams_ = ParamPointerType(
new Stone2Params, Deleter< Stone2Params > () );
137 case EclMultiplexerApproach::Default:
138 realParams_ = ParamPointerType(
new DefaultParams, Deleter< DefaultParams > () );
141 case EclMultiplexerApproach::TwoPhase:
142 realParams_ = ParamPointerType(
new TwoPhaseParams, Deleter< TwoPhaseParams > () );
145 case EclMultiplexerApproach::OnePhase:
151 EclMultiplexerApproach approach()
const
152 {
return approach_; }
155 template <EclMultiplexerApproach approachV>
156 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, Stone1Params>::type&
159 assert(approach() == approachV);
160 return this->
template castTo<Stone1Params>();
163 template <EclMultiplexerApproach approachV>
164 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, const Stone1Params>::type&
165 getRealParams()
const
167 assert(approach() == approachV);
168 return this->
template castTo<Stone1Params>();
172 template <EclMultiplexerApproach approachV>
173 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, Stone2Params>::type&
176 assert(approach() == approachV);
177 return this->
template castTo<Stone2Params>();
180 template <EclMultiplexerApproach approachV>
181 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, const Stone2Params>::type&
182 getRealParams()
const
184 assert(approach() == approachV);
185 return this->
template castTo<Stone2Params>();
189 template <EclMultiplexerApproach approachV>
190 typename std::enable_if<approachV == EclMultiplexerApproach::Default, DefaultParams>::type&
193 assert(approach() == approachV);
194 return this->
template castTo<DefaultParams>();
197 template <EclMultiplexerApproach approachV>
198 typename std::enable_if<approachV == EclMultiplexerApproach::Default, const DefaultParams>::type&
199 getRealParams()
const
201 assert(approach() == approachV);
202 return this->
template castTo<DefaultParams>();
206 template <EclMultiplexerApproach approachV>
207 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, TwoPhaseParams>::type&
210 assert(approach() == approachV);
211 return this->
template castTo<TwoPhaseParams>();
214 template <EclMultiplexerApproach approachV>
215 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, const TwoPhaseParams>::type&
216 getRealParams()
const
218 assert(approach() == approachV);
219 return this->
template castTo<TwoPhaseParams>();
222 template<
class Serializer>
223 void serializeOp(Serializer& serializer)
225 switch (approach()) {
226 case EclMultiplexerApproach::Stone1:
227 serializer(castTo<Stone1Params>());
230 case EclMultiplexerApproach::Stone2:
231 serializer(castTo<Stone2Params>());
234 case EclMultiplexerApproach::Default:
235 serializer(castTo<DefaultParams>());
238 case EclMultiplexerApproach::TwoPhase:
239 serializer(castTo<TwoPhaseParams>());
242 case EclMultiplexerApproach::OnePhase:
249 template <
class ParamT>
252 return *(
static_cast<ParamT *
> (realParams_.operator->()));
255 template <
class ParamT>
256 const ParamT& castTo()
const
258 return *(
static_cast<const ParamT *
> (realParams_.operator->()));
261 EclMultiplexerApproach approach_{EclMultiplexerApproach::Default};
262 ParamPointerType realParams_;