121#ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CLONE_FACTORY_H
122#define LASS_GUARDIAN_OF_INCLUSION_UTIL_CLONE_FACTORY_H
134 class AbstractProduct,
135 class IdentifierType,
136 class ProductCloner = AbstractProduct*(*)(
const AbstractProduct&)
142 typedef AbstractProduct TAbstractProduct;
143 typedef IdentifierType TIdentifier;
144 typedef ProductCloner TProductCloner;
157 typename CallTraits<IdentifierType>::TParam iIdentifier,
158 std::unique_ptr<AbstractProduct> iPrototype)
160 return prototypes_.insert(
typename TPrototypes::value_type(
161 iIdentifier, std::move(iPrototype))).second;
166 bool unsubscribe(
typename CallTraits<IdentifierType>::TParam iIdentifier)
168 return prototypes_.erase(iIdentifier) == 1;
174 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier)
const
176 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
177 if (i == prototypes_.end())
179 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
180 <<
"' passed to CloneFactory.");
182 return cloner_(*i->second);
188 template <
typename P1>
189 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
192 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
193 if (i == prototypes_.end())
195 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
196 <<
"' passed to CloneFactory.");
198 return cloner_(*i->second, iP1);
204 template <
typename P1,
typename P2>
205 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
206 P1& iP1, P2& iP2)
const
208 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
209 if (i == prototypes_.end())
211 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
212 <<
"' passed to CloneFactory.");
214 return cloner_(*i->second, iP1, iP2);
220 template <
typename P1,
typename P2,
typename P3>
221 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
222 P1& iP1, P2& iP2, P3& iP3)
const
224 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
225 if (i == prototypes_.end())
227 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
228 <<
"' passed to CloneFactory.");
230 return cloner_(*i->second, iP1, iP2, iP3);
236 template <
typename P1,
typename P2,
typename P3,
typename P4>
237 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
238 P1& iP1, P2& iP2, P3& iP3, P4& iP4)
const
240 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
241 if (i == prototypes_.end())
243 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
244 <<
"' passed to CloneFactory.");
246 return cloner_(*i->second, iP1, iP2, iP3, iP4);
252 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
253 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
254 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5)
const
256 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
257 if (i == prototypes_.end())
259 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
260 <<
"' passed to CloneFactory.");
262 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5);
268 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
269 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
270 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6)
const
272 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
273 if (i == prototypes_.end())
275 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
276 <<
"' passed to CloneFactory.");
278 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6);
284 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7>
285 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
286 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7)
const
288 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
289 if (i == prototypes_.end())
291 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
292 <<
"' passed to CloneFactory.");
294 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7);
300 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8>
301 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
302 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8)
const
304 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
305 if (i == prototypes_.end())
307 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
308 <<
"' passed to CloneFactory.");
310 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8);
316 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9>
317 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
318 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9)
const
320 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
321 if (i == prototypes_.end())
323 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
324 <<
"' passed to CloneFactory.");
326 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9);
332 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
typename P10>
333 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
334 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9, P10& iP10)
const
336 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
337 if (i == prototypes_.end())
339 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
340 <<
"' passed to CloneFactory.");
342 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10);
348 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
typename P10,
typename P11>
349 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
350 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9, P10& iP10, P11& iP11)
const
352 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
353 if (i == prototypes_.end())
355 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
356 <<
"' passed to CloneFactory.");
358 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11);
364 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
typename P10,
typename P11,
typename P12>
365 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
366 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9, P10& iP10, P11& iP11, P12& iP12)
const
368 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
369 if (i == prototypes_.end())
371 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
372 <<
"' passed to CloneFactory.");
374 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12);
380 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
typename P10,
typename P11,
typename P12,
typename P13>
381 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
382 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9, P10& iP10, P11& iP11, P12& iP12, P13& iP13)
const
384 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
385 if (i == prototypes_.end())
387 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
388 <<
"' passed to CloneFactory.");
390 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13);
396 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
typename P10,
typename P11,
typename P12,
typename P13,
typename P14>
397 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
398 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9, P10& iP10, P11& iP11, P12& iP12, P13& iP13, P14& iP14)
const
400 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
401 if (i == prototypes_.end())
403 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
404 <<
"' passed to CloneFactory.");
406 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14);
412 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
typename P10,
typename P11,
typename P12,
typename P13,
typename P14,
typename P15>
413 AbstractProduct*
make(
typename CallTraits<IdentifierType>::TParam iIdentifier,
414 P1& iP1, P2& iP2, P3& iP3, P4& iP4, P5& iP5, P6& iP6, P7& iP7, P8& iP8, P9& iP9, P10& iP10, P11& iP11, P12& iP12, P13& iP13, P14& iP14, P15& iP15)
const
416 typename TPrototypes::const_iterator i = prototypes_.find(iIdentifier);
417 if (i == prototypes_.end())
419 LASS_THROW(
"Unknown Product identifier '" << iIdentifier
420 <<
"' passed to CloneFactory.");
422 return cloner_(*i->second, iP1, iP2, iP3, iP4, iP5, iP6, iP7, iP8, iP9, iP10, iP11, iP12, iP13, iP14, iP15);
428 typedef SharedPtr<AbstractProduct> TPrototypePtr;
429 typedef std::map<IdentifierType, TPrototypePtr> TPrototypes;
431 TPrototypes prototypes_;
432 TProductCloner cloner_;
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9, P10 &iP10, P11 &iP11, P12 &iP12, P13 &iP13, P14 &iP14, P15 &iP15) const
create a new concrete product by cloning the prototype with 15 additional parameter(s).
bool unsubscribe(typename CallTraits< IdentifierType >::TParam iIdentifier)
unregister a concrete product by its iIdentifier
bool subscribe(typename CallTraits< IdentifierType >::TParam iIdentifier, std::unique_ptr< AbstractProduct > iPrototype)
register a concrete product to the CloneFactory by a iIdentifier that will identify the product,...
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2) const
create a new concrete product by cloning the prototype with 2 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1) const
create a new concrete product by cloning the prototype with 1 additional parameter(s).
CloneFactory(typename CallTraits< ProductCloner >::TParam iCloner)
create a clone factory by specifying its cloner function iCloner.
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4) const
create a new concrete product by cloning the prototype with 4 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9, P10 &iP10, P11 &iP11, P12 &iP12, P13 &iP13) const
create a new concrete product by cloning the prototype with 13 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5) const
create a new concrete product by cloning the prototype with 5 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9) const
create a new concrete product by cloning the prototype with 9 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3) const
create a new concrete product by cloning the prototype with 3 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier) const
Create a new concrete product by cloning the prototype only to be used if maker don't want any parame...
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8) const
create a new concrete product by cloning the prototype with 8 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9, P10 &iP10, P11 &iP11) const
create a new concrete product by cloning the prototype with 11 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6) const
create a new concrete product by cloning the prototype with 6 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9, P10 &iP10) const
create a new concrete product by cloning the prototype with 10 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9, P10 &iP10, P11 &iP11, P12 &iP12) const
create a new concrete product by cloning the prototype with 12 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7, P8 &iP8, P9 &iP9, P10 &iP10, P11 &iP11, P12 &iP12, P13 &iP13, P14 &iP14) const
create a new concrete product by cloning the prototype with 14 additional parameter(s).
AbstractProduct * make(typename CallTraits< IdentifierType >::TParam iIdentifier, P1 &iP1, P2 &iP2, P3 &iP3, P4 &iP4, P5 &iP5, P6 &iP6, P7 &iP7) const
create a new concrete product by cloning the prototype with 7 additional parameter(s).
general utility, debug facilities, ...
Library for Assembled Shared Sources.