Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

SocketHandle.hh

Go to the documentation of this file.
00001 // $Id:SocketHandle.hh 218 2007-03-20 14:39:32Z tho $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00027 #ifndef HH_SENF_Socket_SocketHandle_
00028 #define HH_SENF_Socket_SocketHandle_ 1
00029 
00030 //#include "SocketHandle.mpp"
00031 #include "SocketHandle.ih"
00032 
00033 // Custom includes
00034 #include <memory> // std::auto_ptr
00035 #include "FileHandle.hh"
00036 #include "SocketPolicy.hh"
00037 
00038 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00039 
00040 namespace senf {
00041 
00043     //\{
00044 
00068     template <class SPolicy>
00069     class SocketHandle
00070         : public FileHandle
00071     {
00072     public:
00073         //-////////////////////////////////////////////////////////////////////////
00074         // Types
00075 
00076         typedef SPolicy Policy;
00077 
00084         template <class OtherPolicy>
00085         struct IsCompatible
00086             : public boost::enable_if< SocketPolicyIsBaseOf<Policy,OtherPolicy>, SocketHandle >
00087         {};
00088 
00089         //-////////////////////////////////////////////////////////////////////////
00091         //\{
00092 
00093         // default default constructor
00094         // default copy constructor
00095         // default copy assignment
00096         // default destructor
00097 
00098         // here to implement
00099         SocketHandle();
00100 
00101         // conversion constructors
00102 
00103         template <class OtherPolicy>
00104         SocketHandle(SocketHandle<OtherPolicy> other,
00105                      typename IsCompatible<OtherPolicy>::type * = 0);
00108 
00109         //\}
00110         //-////////////////////////////////////////////////////////////////////////
00111 
00112         template <class OtherPolicy>
00113         typename IsCompatible<OtherPolicy>::type const & operator=(SocketHandle<OtherPolicy> other);
00116 
00117         void state(SocketStateMap & map, unsigned lod=0);
00119 
00138         std::string dumpState(unsigned lod=0);
00140 
00150         template <class Facet>
00151         Facet & facet();                
00152 
00160     protected:
00161         explicit SocketHandle(std::auto_ptr<SocketBody> body);
00163 
00167         SocketHandle(FileHandle other, bool isChecked);
00170 
00185         SocketBody & body();            
00186 
00189         SocketBody const & body() const; 
00190 
00193         SocketProtocol & protocol() const;
00195 
00196         void assign(FileHandle other);  
00198     public:
00199         static SocketHandle cast_static(FileHandle handle);
00201         static SocketHandle cast_dynamic(FileHandle handle);
00204     private:
00205 
00206     };
00207 
00214     template <class SPolicy>
00215     std::ostream & operator<<(std::ostream & os, SocketHandle<SPolicy> handle);
00216 
00234     template <class Target, class Source>
00235     Target static_socket_cast(Source handle);
00236 
00246     template <class Target, class Source>
00247     Target dynamic_socket_cast(Source handle);
00248 
00259     template <class Target, class Source>
00260     bool check_socket_cast(Source handle);
00261 
00262     //\}
00263 }
00264 
00265 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00266 #include "SocketHandle.cci"
00267 #include "SocketHandle.ct"
00268 #include "SocketHandle.cti"
00269 #endif
00270 
00271 
00272 // Local Variables:
00273 // mode: c++
00274 // fill-column: 100
00275 // c-file-style: "senf"
00276 // indent-tabs-mode: nil
00277 // ispell-local-dictionary: "american"
00278 // compile-command: "scons -u test"
00279 // comment-column: 40
00280 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research