StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlightDate.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
10 #include <stdair/bom/Inventory.hpp>
12 #include <stdair/bom/LegDate.hpp>
14 
15 namespace stdair {
16 
17  // ////////////////////////////////////////////////////////////////////
18  FlightDate::FlightDate()
19  : _key (DEFAULT_FLIGHT_NUMBER, DEFAULT_DEPARTURE_DATE), _parent (NULL) {
20  // That constructor is used by the serialisation process
21  }
22 
23  // ////////////////////////////////////////////////////////////////////
24  FlightDate::FlightDate (const FlightDate&)
25  : _key (DEFAULT_FLIGHT_NUMBER, DEFAULT_DEPARTURE_DATE), _parent (NULL) {
26  assert (false);
27  }
28 
29  // ////////////////////////////////////////////////////////////////////
30  FlightDate::FlightDate (const Key_T& iKey) : _key (iKey), _parent (NULL) {
31  }
32 
33  // ////////////////////////////////////////////////////////////////////
35  }
36 
37  // ////////////////////////////////////////////////////////////////////
39  const Inventory* lInventory_ptr =
40  static_cast<const Inventory*> (getParent());
41  assert (lInventory_ptr != NULL);
42  return lInventory_ptr->getAirlineCode();
43  }
44 
45  // ////////////////////////////////////////////////////////////////////
46  std::string FlightDate::toString() const {
47  std::ostringstream oStr;
48  oStr << describeKey();
49  return oStr.str();
50  }
51 
52  // ////////////////////////////////////////////////////////////////////
53  LegDate* FlightDate::getLegDate (const std::string& iLegDateKeyStr) const {
54  LegDate* oLegDate_ptr =
55  BomManager::getObjectPtr<LegDate> (*this, iLegDateKeyStr);
56  return oLegDate_ptr;
57  }
58 
59  // ////////////////////////////////////////////////////////////////////
60  LegDate* FlightDate::getLegDate (const LegDateKey& iLegDateKey) const {
61  return getLegDate (iLegDateKey.toString());
62  }
63 
64  // ////////////////////////////////////////////////////////////////////
66  getSegmentDate (const std::string& iSegmentDateKeyStr) const {
67  SegmentDate* oSegmentDate_ptr =
68  BomManager::getObjectPtr<SegmentDate> (*this, iSegmentDateKeyStr);
69  return oSegmentDate_ptr;
70  }
71 
72  // ////////////////////////////////////////////////////////////////////
74  getSegmentDate (const SegmentDateKey& iSegmentDateKey) const {
75  return getSegmentDate (iSegmentDateKey.toString());
76  }
77 
78 }
79