00001 #ifndef __RMOL_SERVICEABSTRACT_HPP 00002 #define __RMOL_SERVICEABSTRACT_HPP 00003 00004 // ////////////////////////////////////////////////////////////////////// 00005 // Import section 00006 // ////////////////////////////////////////////////////////////////////// 00007 // STL 00008 #include <iostream> 00009 #include <sstream> 00010 00011 namespace RMOL { 00012 00014 class ServiceAbstract { 00015 public: 00016 00018 virtual ~ServiceAbstract() {} 00019 00022 virtual void toStream (std::ostream& ioOut) const {} 00023 00026 virtual void fromStream (std::istream& ioIn) {} 00027 00028 protected: 00030 ServiceAbstract() {} 00031 }; 00032 } 00033 00039 template <class charT, class traits> 00040 inline 00041 std::basic_ostream<charT, traits>& 00042 operator<< (std::basic_ostream<charT, traits>& ioOut, 00043 const RMOL::ServiceAbstract& iService) { 00049 std::basic_ostringstream<charT,traits> ostr; 00050 ostr.copyfmt (ioOut); 00051 ostr.width (0); 00052 00053 // Fill string stream 00054 iService.toStream (ostr); 00055 00056 // Print string stream 00057 ioOut << ostr.str(); 00058 00059 return ioOut; 00060 } 00061 00067 template <class charT, class traits> 00068 inline 00069 std::basic_istream<charT, traits>& 00070 operator>> (std::basic_istream<charT, traits>& ioIn, 00071 RMOL::ServiceAbstract& ioService) { 00072 // Fill Service object with input stream 00073 ioService.fromStream (ioIn); 00074 return ioIn; 00075 } 00076 00077 #endif // __RMOL_SERVICEABSTRACT_HPP
Generated on Fri Jul 30 21:53:39 2010 for RMOL by Doxygen 1.6.1