$treeview $search $mathjax
StdAir Logo  1.00.2
$projectbrief
$projectbrief
$searchbox

stdair/service/ServiceAbstract.hpp

Go to the documentation of this file.
00001 #ifndef __STDAIR_SVC_SERVICEABSTRACT_HPP
00002 #define __STDAIR_SVC_SERVICEABSTRACT_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <iosfwd>
00009 
00010 namespace stdair {
00011 
00015   class ServiceAbstract {
00016   public:
00017     
00021     virtual ~ServiceAbstract() {}
00022     
00028     virtual void toStream (std::ostream& ioOut) const {}
00029 
00035     virtual void fromStream (std::istream& ioIn) {}
00036     
00040     // virtual const std::string describe() const = 0;
00041 
00042   protected:
00046     ServiceAbstract() {}
00047   };
00048 }
00049 
00055 template <class charT, class traits>
00056 inline
00057 std::basic_ostream<charT, traits>&
00058 operator<< (std::basic_ostream<charT, traits>& ioOut,
00059             const stdair::ServiceAbstract& iService) {
00065   std::basic_ostringstream<charT,traits> ostr;
00066   ostr.copyfmt (ioOut);
00067   ostr.width (0);
00068 
00069   // Fill string stream
00070   iService.toStream (ostr);
00071 
00072   // Print string stream
00073   ioOut << ostr.str();
00074 
00075   return ioOut;
00076 }
00077 
00083 template <class charT, class traits>
00084 inline
00085 std::basic_istream<charT, traits>&
00086 operator>> (std::basic_istream<charT, traits>& ioIn,
00087             stdair::ServiceAbstract& ioService) {
00088   // Fill Service object with input stream
00089   ioService.fromStream (ioIn);
00090   return ioIn;
00091 }
00092 
00093 #endif // __STDAIR_SVC_SERVICEABSTRACT_HPP