1 #ifndef __STDAIR_BOM_BOMMANAGER_HPP
2 #define __STDAIR_BOM_BOMMANAGER_HPP
13 #include <boost/static_assert.hpp>
14 #include <boost/type_traits/is_same.hpp>
41 template <
typename OBJECT2,
typename OBJECT1>
47 template <
typename OBJECT2,
typename OBJECT1>
53 template <
typename OBJECT2,
typename OBJECT1>
54 static bool hasList (
const OBJECT1&);
59 template <
typename OBJECT2,
typename OBJECT1>
60 static bool hasMap (
const OBJECT1&);
67 template <
typename PARENT,
typename CHILD>
73 template <
typename PARENT,
typename CHILD>
81 template <
typename OBJECT2,
typename OBJECT1>
87 template <
typename OBJECT2,
typename OBJECT1>
96 template <
typename OBJECT2,
typename OBJECT1>
102 template <
typename OBJECT2,
typename OBJECT1>
111 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
112 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
113 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
114 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
116 const HolderMap_T& lHolderMap = iObject1.getHolderMap();
118 HolderMap_T::const_iterator itHolder = lHolderMap.find (&
typeid (OBJECT2));
120 if (itHolder == lHolderMap.end()) {
121 const std::string lName (
typeid (OBJECT2).name());
123 + lName +
" within: "
124 + iObject1.describeKey());
127 const BomHolder<OBJECT2>* lBomHolder_ptr =
128 static_cast<const BomHolder<OBJECT2>*
> (itHolder->second);
129 assert (lBomHolder_ptr != NULL);
131 return *lBomHolder_ptr;
138 template <
typename OBJECT2,
typename OBJECT1>
139 const typename BomHolder<OBJECT2>::BomList_T&
BomManager::
147 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
148 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
157 template <
typename OBJECT2,
typename OBJECT1>
167 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
168 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
169 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, Inventory>::value ==
false
170 || boost::is_same<OBJECT2, AirlineFeature>::value ==
false));
180 template <
typename OBJECT2,
typename OBJECT1>
183 const HolderMap_T& lHolderMap = iObject1.getHolderMap();
184 HolderMap_T::const_iterator itHolder = lHolderMap.find (&
typeid (OBJECT2));
186 if (itHolder == lHolderMap.end()) {
191 assert (lBomHolder_ptr != NULL);
193 return !lBomHolder_ptr->
_bomList.empty();
200 template <
typename OBJECT2,
typename OBJECT1>
203 const HolderMap_T& lHolderMap = iObject1.getHolderMap();
204 HolderMap_T::const_iterator itHolder = lHolderMap.find (&
typeid (OBJECT2));
206 if (itHolder == lHolderMap.end()) {
211 assert (lBomHolder_ptr != NULL);
213 return !lBomHolder_ptr->
_bomMap.empty();
219 template <
typename PARENT,
typename CHILD>
222 PARENT*
const lParent_ptr =
static_cast<PARENT* const
> (iChild.getParent());
229 template <
typename PARENT,
typename CHILD>
232 PARENT*
const lParent_ptr = getParentPtr<PARENT> (iChild);
233 assert (lParent_ptr != NULL);
240 template <
typename OBJECT2,
typename OBJECT1>
249 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
250 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
252 OBJECT2* oBom_ptr = NULL;
254 const HolderMap_T& lHolderMap = iObject1.getHolderMap();
256 typename HolderMap_T::const_iterator itHolder =
257 lHolderMap.find (&
typeid (OBJECT2));
259 if (itHolder != lHolderMap.end()) {
263 assert (lBomHolder_ptr != NULL);
267 BomMap_T& lBomMap = lBomHolder_ptr->
_bomMap;
268 typename BomMap_T::iterator itBom = lBomMap.find (iKey);
270 if (itBom != lBomMap.end()) {
271 oBom_ptr = itBom->second;
272 assert (oBom_ptr != NULL);
282 template <
typename OBJECT2,
typename OBJECT1>
291 BOOST_STATIC_ASSERT ((boost::is_same<OBJECT1, SegmentDate>::value ==
false
292 || boost::is_same<OBJECT2, SegmentDate>::value ==
false));
294 OBJECT2* oBom_ptr = NULL;
296 typedef std::map<const MapKey_T, OBJECT2*> BomMap_T;
297 const BomMap_T& lBomMap = getMap<OBJECT2> (iObject1);
299 typename BomMap_T::const_iterator itBom = lBomMap.find (iKey);
301 if (itBom == lBomMap.end()) {
302 const std::string lName (
typeid (OBJECT2).name());
305 <<
" with key " << iKey <<
" within: "
306 << iObject1.describeKey());
310 oBom_ptr = itBom->second;
311 assert (oBom_ptr != NULL);
328 inline bool BomManager::hasList<SegmentDate,SegmentDate>
332 ioSegmentDate.getMarketingSegmentDateList ();
333 const bool isMarketingSegmentDateListEmpty =
334 lMarketingSegmentDateList.empty();
335 const bool hasMarketingSegmentDateList =
336 !isMarketingSegmentDateListEmpty;
337 return hasMarketingSegmentDateList;
345 BomManager::getList<SegmentDate,SegmentDate> (
const SegmentDate& ioSegmentDate) {
348 ioSegmentDate.getMarketingSegmentDateList ();
349 return lMarketingSegmentDateList;
357 inline bool BomManager::hasMap<SegmentDate,SegmentDate>
360 const bool hasMap =
false;
374 inline bool BomManager::hasList<AirlineFeature,Inventory>
377 const bool hasList =
false;
384 inline bool BomManager::hasMap<AirlineFeature,Inventory>
387 const bool hasMap =
false;
394 inline AirlineFeature* BomManager::getObjectPtr<AirlineFeature,Inventory>
397 AirlineFeature* lAirlineFeature_ptr = iInventory.getAirlineFeature ();
399 return lAirlineFeature_ptr;
405 inline AirlineFeature& BomManager::getObject<AirlineFeature,Inventory>
409 getObjectPtr<AirlineFeature,Inventory> (iInventory, iKey);
410 assert (lAirlineFeature_ptr != NULL);
412 return *lAirlineFeature_ptr;
417 #endif // __STDAIR_BOM_BOMMANAGER_HPP