StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BomAbstract.hpp
Go to the documentation of this file.
1 
6 #ifndef __STDAIR_BOM_BOMABSTRACT_HPP
7 #define __STDAIR_BOM_BOMABSTRACT_HPP
8 
9 // //////////////////////////////////////////////////////////////////////
10 // Import section
11 // //////////////////////////////////////////////////////////////////////
12 // STL
13 #include <iosfwd>
14 #include <string>
15 #include <map>
16 #include <typeinfo>
17 
18 namespace stdair {
19 
23  class BomAbstract {
24  public:
25  // /////////// Display support methods /////////
28  virtual void toStream (std::ostream& ioOut) const = 0;
29 
32  virtual void fromStream (std::istream& ioIn) = 0;
33 
35  virtual std::string toString() const = 0;
36 
37 
38  protected:
42  public:
44  virtual ~BomAbstract() {}
45  };
46 
47  /* Define the map of object holder type. */
48  typedef std::map<const std::type_info*, BomAbstract*> HolderMap_T;
49 }
50 
56 template <class charT, class traits>
57 inline
58 std::basic_ostream<charT, traits>&
59 operator<< (std::basic_ostream<charT, traits>& ioOut,
60  const stdair::BomAbstract& iBom) {
66  std::basic_ostringstream<charT,traits> ostr;
67  ostr.copyfmt (ioOut);
68  ostr.width (0);
69 
70  // Fill string stream
71  iBom.toStream (ostr);
72 
73  // Print string stream
74  ioOut << ostr.str();
75 
76  return ioOut;
77 }
78 
84 template <class charT, class traits>
85 inline
86 std::basic_istream<charT, traits>&
87 operator>> (std::basic_istream<charT, traits>& ioIn,
88  stdair::BomAbstract& ioBom) {
89  // Fill Bom object with input stream
90  ioBom.fromStream (ioIn);
91  return ioIn;
92 }
93 
94 #endif // __STDAIR_BOM_BOMABSTRACT_HPP