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

ProtocolClientSocketHandle.cti

Go to the documentation of this file.
00001 // $Id: ProtocolClientSocketHandle.cti 1742 2010-11-04 14:51:56Z g0dil $
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 
00028 // Definition of inline template functions
00029 
00030 //#include "ProtocolClientSocketHandle.ih"
00031 
00032 // Custom includes
00033 #include <senf/Utils/senfassert.hh>
00034 
00035 #define prefix_ inline
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 
00038 template <class SocketProtocol>
00039 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
00040 ProtocolClientSocketHandle(senf::NoInit_t)
00041 {}
00042 
00043 template <class SocketProtocol>
00044 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::ProtocolClientSocketHandle()
00045     : ClientSocketHandle<typename SocketProtocol::Policy>(
00046         std::auto_ptr<senf::SocketBody>(new senf::ProtocolSocketBody<SocketProtocol>(false)))
00047 {
00048     this->protocol().init_client();
00049 }
00050 
00051 #define BOOST_PP_ITERATION_PARAMS_1 \
00052     (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolClientSocketHandle.mpp), 2))
00053 #include BOOST_PP_ITERATE()
00054 
00055 template <class SocketProtocol>
00056 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
00057 ProtocolClientSocketHandle(FileHandle other, bool isChecked)
00058     : ClientSocketHandle<typename Protocol::Policy>(other, isChecked)
00059 {}
00060 
00061 template <class SocketProtocol>
00062 prefix_ SocketProtocol &
00063 senf::ProtocolClientSocketHandle<SocketProtocol>::protocol()
00064 {
00065     SENF_ASSERT( dynamic_cast<SocketProtocol *>(&this->body().protocol()),
00066                  "Internal failure: Incompatible protocol class found it's way into this handle");
00067     // Need dynamic_cast here, since senf::SocketProtocol is a
00068     // virtual base
00069     return dynamic_cast<SocketProtocol &>(this->body().protocol());
00070 }
00071 
00072 template <class SocketProtocol>
00073 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
00074 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
00075 {
00076     return ProtocolClientSocketHandle(handle,true);
00077 }
00078 
00079 template <class SocketProtocol>
00080 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
00081 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
00082 {
00083     ClientSocketHandle<typename SocketProtocol::Policy> h(
00084         ClientSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
00085     // throw std::bad_cast if the protocol is invalid
00086     dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
00087     return cast_static(handle);
00088 }
00089 
00090 template <class SocketProtocol>
00091 prefix_ void
00092 senf::ProtocolClientSocketHandle<SocketProtocol>::state(SocketStateMap & map,
00093                                                                unsigned lod)
00094 {
00095     map["handle"] = prettyName(typeid(*this));
00096     if (this->valid()) {
00097         map["valid"] << "true";
00098         this->body().state(map,lod);
00099     } else
00100         map["valid"] << "false";
00101 }
00102 
00103 template <class SocketProtocol>
00104 prefix_ std::string
00105 senf::ProtocolClientSocketHandle<SocketProtocol>::dumpState(unsigned lod)
00106 {
00107     SocketStateMap map;
00108     state(map,lod);
00109     return detail::dumpState(map);
00110 }
00111 
00112 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00113 #undef prefix_
00114 
00115 
00116 // Local Variables:
00117 // mode: c++
00118 // fill-column: 100
00119 // c-file-style: "senf"
00120 // indent-tabs-mode: nil
00121 // ispell-local-dictionary: "american"
00122 // compile-command: "scons -u test"
00123 // comment-column: 40
00124 // End:

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