// $Id$ // // Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef IH_SocketHandle_ #define IH_SocketHandle_ 1 // Custom includes #include #include #include #include "FileHandle.hh" ///////////////////////////////ih.p//////////////////////////////////////// namespace senf { class SocketProtocol; namespace detail { class ConvertibleString : public std::string { public: ConvertibleString(); ConvertibleString(bool v); template ConvertibleString(T const & other); template ConvertibleString & operator+= (ConvertibleString const & other); }; struct StateMapOrdering : public std::binary_function { bool operator()(std::string a1, std::string a2) const; }; } typedef std::map< std::string, detail::ConvertibleString, detail::StateMapOrdering > SocketStateMap; namespace detail { std::string dumpState(SocketStateMap const & map); } class SocketBody : public FileBody { public: /////////////////////////////////////////////////////////////////////////// // Types typedef boost::intrusive_ptr ptr; /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ explicit SocketBody(std::auto_ptr protocol, bool isServer); SocketBody(std::auto_ptr protocol, bool isServer, int fd); // no copy // no conversion constructors ///@} /////////////////////////////////////////////////////////////////////////// SocketProtocol const & protocol() const; bool isServer(); void state(SocketStateMap & map, unsigned lod); private: virtual void v_close(); virtual void v_terminate(); virtual bool v_eof() const; boost::scoped_ptr protocol_; bool isServer_; }; } ///////////////////////////////ih.e//////////////////////////////////////// #endif // Local Variables: // mode: c++ // c-file-style: "senf" // End: