1 #ifndef __STDAIR_FAC_FACBOMMANAGER_HPP
2 #define __STDAIR_FAC_FACBOMMANAGER_HPP
12 #include <boost/static_assert.hpp>
13 #include <boost/type_traits/is_same.hpp>
41 template <
typename OBJECT2,
typename OBJECT1>
53 template <
typename OBJECT2,
typename OBJECT1>
67 template <
typename OBJECT1,
typename OBJECT2>
68 static void addToList (OBJECT1&, OBJECT2&);
82 template <
typename OBJECT1,
typename OBJECT2>
96 template <
typename OBJECT1,
typename OBJECT2>
97 static void addToMap (OBJECT1&, OBJECT2&);
110 template <
typename OBJECT1,
typename OBJECT2>
125 template <
typename OBJECT1,
typename OBJECT2>
134 template <
typename PARENT,
typename CHILD>
147 template <
typename OBJECT2,
typename OBJECT1>
148 static void cloneHolder (OBJECT1&,
const OBJECT1&);
164 template <
typename OBJECT1,
typename OBJECT2>
180 template <
typename OBJECT1,
typename OBJECT2>
192 template <
typename OBJECT2,
typename OBJECT1>
207 iInventory.setAirlineFeature (iAirlineFeature);
215 iSegmentDate.linkWithOperating (iOperatingSegmentDate);
237 template <
typename OBJECT2,
typename OBJECT1>
246 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
247 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
248 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
249 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
255 const bool hasInsertBeenSuccessful =
256 ioObject1._holderMap.insert (
typename HolderMap_T::
257 value_type (&
typeid (OBJECT2),
258 lBomHolder_ptr)).second;
259 assert (hasInsertBeenSuccessful ==
true);
261 return *lBomHolder_ptr;
267 template <
typename OBJECT2,
typename OBJECT1>
276 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
277 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
278 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
279 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
284 HolderMap_T::const_iterator itHolder =
285 ioObject1._holderMap.find (&
typeid (OBJECT2));
287 if (itHolder != ioObject1._holderMap.end()) {
291 return lBomHolder_ptr;
296 template <
typename OBJECT2,
typename OBJECT1>
305 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
306 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
307 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
308 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
314 HolderMap_T::const_iterator itHolder =
315 ioObject1._holderMap.find (&
typeid (OBJECT2));
317 if (itHolder == ioObject1._holderMap.end()) {
318 lBomHolder_ptr = &addBomHolder<OBJECT2, OBJECT1> (ioObject1);
321 lBomHolder_ptr =
static_cast<BomHolder<OBJECT2>*
> (itHolder->second);
324 assert (lBomHolder_ptr != NULL);
326 return *lBomHolder_ptr;
331 template <
typename OBJECT1,
typename OBJECT2>
333 OBJECT1& ioObject1, OBJECT2& ioObject2) {
341 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
342 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
343 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
344 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
346 ioBomHolder._bomList.push_back (&ioObject2);
353 template <
typename OBJECT1,
typename OBJECT2>
362 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
363 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
364 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
365 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
369 addToList<OBJECT1, OBJECT2> (lBomHolder, ioObject1, ioObject2);
374 template <
typename OBJECT1,
typename OBJECT2>
376 OBJECT1& ioObject1, OBJECT2& ioObject2,
385 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
386 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
387 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
388 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
390 const bool insertionSucceeded =
391 ioBomHolder.
_bomMap.insert (
typename std::map<const MapKey_T, OBJECT2*>::
392 value_type (iKey, &ioObject2)).second;
394 if (insertionSucceeded ==
false) {
396 std::ostringstream oStr;
397 oStr <<
"The given object ('" << iKey
398 <<
"') can not be added to the map of '" << ioObject1.describeKey()
399 <<
"' object. That map already contains: '";
401 unsigned int idx = 0;
402 for (
typename std::map<const MapKey_T, OBJECT2*>::const_iterator iter =
404 iter != ioBomHolder.
_bomMap.end(); ++iter, ++idx) {
405 const OBJECT2* lCurrentObject_ptr = iter->second;
406 assert (lCurrentObject_ptr != NULL);
411 oStr << lCurrentObject_ptr->describeKey();
416 throw ObjectLinkingException (oStr.str());
432 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
433 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
434 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
435 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
439 addToMap<OBJECT1, OBJECT2> (lBomHolder, ioObject1, ioObject2, iKey);
445 template <
typename OBJECT1,
typename OBJECT2>
454 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
455 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
456 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
457 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
459 const MapKey_T& lKey = ioObject2.describeKey();
460 addToMap (ioObject1, ioObject2, lKey);
466 template <
typename OBJECT1,
typename OBJECT2>
475 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
476 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
477 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
478 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
482 addToList<OBJECT1, OBJECT2> (lBomHolder, ioObject1, ioObject2);
483 addToMap<OBJECT1, OBJECT2> (lBomHolder, ioObject1, ioObject2, iKey);
498 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
499 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
500 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
501 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
503 const MapKey_T& lKey = ioObject2.describeKey();
504 addToListAndMap<OBJECT1, OBJECT2> (ioObject1, ioObject2, lKey);
512 ioChild._parent = &ioParent;
522 BomManager::getBomHolder<OBJECT2> (iOri);
526 lDestHolder._bomMap = lOriginHolder.
_bomMap;
538 inline void FacBomManager::addToList <SegmentDate,SegmentDate>
542 ioSegmentDate._marketingSegmentDateList.push_back(&ioMarketingSegmentDate);
560 #endif // __STDAIR_FAC_FACBOMMANAGER_HPP