TvlSim Logo  1.00.0
C++ Simulated Travel-Oriented Distribution System Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BomAbstract.hpp
Go to the documentation of this file.
1 #ifndef __TVLSIM_BOM_BOMABSTRACT_HPP
2 #define __TVLSIM_BOM_BOMABSTRACT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iosfwd>
9 #include <string>
10 
11 namespace TVLSIM {
12 
14  class BomAbstract {
15  friend class FacBomAbstract;
16  public:
17  // /////////// Display support methods /////////
20  virtual void toStream (std::ostream& ioOut) const = 0;
21 
24  virtual void fromStream (std::istream& ioIn) = 0;
25 
27  virtual std::string toString() const = 0;
28 
31  virtual std::string describeKey() const = 0;
32 
35  virtual std::string describeShortKey() const = 0;
36 
37 
38  protected:
42 
44  virtual ~BomAbstract() {}
45  };
46 }
47 
53 template <class charT, class traits>
54 inline
55 std::basic_ostream<charT, traits>&
56 operator<< (std::basic_ostream<charT, traits>& ioOut,
57  const TVLSIM::BomAbstract& iBom) {
63  std::basic_ostringstream<charT,traits> ostr;
64  ostr.copyfmt (ioOut);
65  ostr.width (0);
66 
67  // Fill string stream
68  iBom.toStream (ostr);
69 
70  // Print string stream
71  ioOut << ostr.str();
72 
73  return ioOut;
74 }
75 
81 template <class charT, class traits>
82 inline
83 std::basic_istream<charT, traits>&
84 operator>> (std::basic_istream<charT, traits>& ioIn,
85  TVLSIM::BomAbstract& ioBom) {
86  // Fill Bom object with input stream
87  ioBom.fromStream (ioIn);
88  return ioIn;
89 }
90 
91 #endif // __TVLSIM_BOM_BOMABSTRACT_HPP