TraDemGen Logo  1.00.0
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
TRADEMGEN_Abstract.hpp
Go to the documentation of this file.
1 #ifndef __TRADEMGEN_TRADEMGEN_ABSTRACT_HPP
2 #define __TRADEMGEN_TRADEMGEN_ABSTRACT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <istream>
9 #include <ostream>
10 #include <sstream>
11 #include <string>
12 
13 namespace TRADEMGEN {
14 
17  public:
18  // /////////// Display support methods /////////
21  virtual void toStream (std::ostream& ioOut) const = 0;
22 
25  virtual void fromStream (std::istream& ioIn) = 0;
26 
28  virtual std::string toString() const = 0;
29 
30 
31  protected:
35 
37  virtual ~TRADEMGEN_Abstract() {}
38  };
39 }
40 
46 template <class charT, class traits>
47 inline
48 std::basic_ostream<charT, traits>&
49 operator<< (std::basic_ostream<charT, traits>& ioOut,
50  const TRADEMGEN::TRADEMGEN_Abstract& iStructure) {
56  std::basic_ostringstream<charT,traits> ostr;
57  ostr.copyfmt (ioOut);
58  ostr.width (0);
59 
60  // Fill string stream
61  iStructure.toStream (ostr);
62 
63  // Print string stream
64  ioOut << ostr.str();
65 
66  return ioOut;
67 }
68 
74 template <class charT, class traits>
75 inline
76 std::basic_istream<charT, traits>&
77 operator>> (std::basic_istream<charT, traits>& ioIn,
78  TRADEMGEN::TRADEMGEN_Abstract& ioStucture) {
79  // Fill Bom object with input stream
80  ioStucture.fromStream (ioIn);
81  return ioIn;
82 }
83 
84 #endif // __TRADEMGEN_TRADEMGEN_ABSTRACT_HPP