StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
BomAbstract.hpp
Go to the documentation of this file.
00001 
00006 #ifndef __STDAIR_BOM_BOMABSTRACT_HPP
00007 #define __STDAIR_BOM_BOMABSTRACT_HPP
00008 
00009 // //////////////////////////////////////////////////////////////////////
00010 // Import section
00011 // //////////////////////////////////////////////////////////////////////
00012 // STL
00013 #include <iosfwd>
00014 #include <string>
00015 #include <map>
00016 #include <typeinfo>
00017 
00018 namespace stdair {
00019 
00023   class BomAbstract {
00024   public:
00025     // /////////// Display support methods /////////
00028     virtual void toStream (std::ostream& ioOut) const = 0;
00029 
00032     virtual void fromStream (std::istream& ioIn) = 0;
00033 
00035     virtual std::string toString() const = 0;
00036 
00037     
00038   protected:
00040     BomAbstract() {}
00041     BomAbstract(const BomAbstract&) {}
00042   public:
00044     virtual ~BomAbstract() {}
00045   };
00046 
00047   /* Define the map of object holder type. */
00048   typedef std::map<const std::type_info*, BomAbstract*> HolderMap_T;
00049 }
00050 
00056 template <class charT, class traits>
00057 inline
00058 std::basic_ostream<charT, traits>&
00059 operator<< (std::basic_ostream<charT, traits>& ioOut,
00060             const stdair::BomAbstract& iBom) {
00066   std::basic_ostringstream<charT,traits> ostr;
00067   ostr.copyfmt (ioOut);
00068   ostr.width (0);
00069 
00070   // Fill string stream
00071   iBom.toStream (ostr);
00072 
00073   // Print string stream
00074   ioOut << ostr.str();
00075 
00076   return ioOut;
00077 }
00078 
00084 template <class charT, class traits>
00085 inline
00086 std::basic_istream<charT, traits>&
00087 operator>> (std::basic_istream<charT, traits>& ioIn,
00088             stdair::BomAbstract& ioBom) {
00089   // Fill Bom object with input stream
00090   ioBom.fromStream (ioIn);
00091   return ioIn;
00092 }
00093 
00094 #endif // __STDAIR_BOM_BOMABSTRACT_HPP