NEW FILE HEADER / COPYRIGHT FORMAT
[senf.git] / Socket / SocketHandle.cti
index dde5bf7..018620b 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
-// Copyright (C) 2006 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS) 
+// Competence Center NETwork research (NET), St. Augustin, GERMANY 
+//     Stefan Bund <g0dil@berlios.de>
 //
 // 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
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-// Definition of inline template functions
+/** \file
+    \brief SocketHandle inline template implementation
+ */
 
 #include "SocketHandle.ih"
 
 // Custom includes
 #include <typeinfo>
 #include <boost/lexical_cast.hpp>
-#include "Utils/TypeInfo.hh"
+#include "../Utils/TypeInfo.hh"
 
 #define prefix_ inline
 ///////////////////////////////cti.p///////////////////////////////////////
 
 template <class SocketPolicy>
+prefix_ senf::SocketHandle<SocketPolicy>::SocketHandle()
+{}
+
+template <class SocketPolicy>
 template <class OtherPolicy>
-prefix_ satcom::lib::SocketHandle<SocketPolicy>::SocketHandle(SocketHandle<OtherPolicy> other,
+prefix_ senf::SocketHandle<SocketPolicy>::SocketHandle(SocketHandle<OtherPolicy> other,
                                                               typename IsCompatible<OtherPolicy>::type *)
     : FileHandle(other)
 {}
 
 template <class SocketPolicy>
 template <class OtherPolicy>
-prefix_ typename satcom::lib::SocketHandle<SocketPolicy>::template IsCompatible<OtherPolicy>::type const &
-satcom::lib::SocketHandle<SocketPolicy>::operator=(SocketHandle<OtherPolicy> other)
+prefix_ typename senf::SocketHandle<SocketPolicy>::template IsCompatible<OtherPolicy>::type const &
+senf::SocketHandle<SocketPolicy>::operator=(SocketHandle<OtherPolicy> other)
 {
     assign(other);
     return *this;
 }
 
 template <class SocketPolicy>
-prefix_ 
-satcom::lib::SocketHandle<SocketPolicy>::SocketHandle(std::auto_ptr<SocketProtocol> protocol,
+prefix_
+senf::SocketHandle<SocketPolicy>::SocketHandle(std::auto_ptr<SocketProtocol> protocol,
                                                       bool isServer)
     : FileHandle(std::auto_ptr<FileBody>(new SocketBody(protocol,isServer)))
 {}
 
 template <class SocketPolicy>
-prefix_ satcom::lib::SocketHandle<SocketPolicy>::SocketHandle(FileHandle other, bool isChecked)
+prefix_ senf::SocketHandle<SocketPolicy>::SocketHandle(FileHandle other, bool isChecked)
     : FileHandle(other)
 {
     BOOST_ASSERT( isChecked );
@@ -64,14 +70,14 @@ prefix_ satcom::lib::SocketHandle<SocketPolicy>::SocketHandle(FileHandle other,
 }
 
 template <class SocketPolicy>
-prefix_ satcom::lib::SocketBody & satcom::lib::SocketHandle<SocketPolicy>::body()
+prefix_ senf::SocketBody & senf::SocketHandle<SocketPolicy>::body()
 {
     BOOST_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
     return static_cast<SocketBody &>(FileHandle::body());
 }
 
 template <class SocketPolicy>
-prefix_ satcom::lib::SocketBody const & satcom::lib::SocketHandle<SocketPolicy>::body()
+prefix_ senf::SocketBody const & senf::SocketHandle<SocketPolicy>::body()
     const
 {
     BOOST_ASSERT( dynamic_cast<SocketBody const *>(&FileHandle::body()) );
@@ -79,38 +85,38 @@ prefix_ satcom::lib::SocketBody const & satcom::lib::SocketHandle<SocketPolicy>:
 }
 
 template <class SocketPolicy>
-prefix_ satcom::lib::SocketProtocol const & satcom::lib::SocketHandle<SocketPolicy>::protocol()
+prefix_ senf::SocketProtocol const & senf::SocketHandle<SocketPolicy>::protocol()
     const
 {
     return body().protocol();
 }
 
 template <class SocketPolicy>
-prefix_ void satcom::lib::SocketHandle<SocketPolicy>::assign(FileHandle other)
+prefix_ void senf::SocketHandle<SocketPolicy>::assign(FileHandle other)
 {
     FileHandle::operator=(other);
 }
 
 template <class SocketPolicy>
-prefix_ satcom::lib::SocketHandle<SocketPolicy>
-satcom::lib::SocketHandle<SocketPolicy>::cast_static(FileHandle handle)
+prefix_ senf::SocketHandle<SocketPolicy>
+senf::SocketHandle<SocketPolicy>::cast_static(FileHandle handle)
 {
     return SocketHandle(handle,true);
 }
 
 template <class SocketPolicy>
-prefix_ satcom::lib::SocketHandle<SocketPolicy>
-satcom::lib::SocketHandle<SocketPolicy>::cast_dynamic(FileHandle handle)
+prefix_ senf::SocketHandle<SocketPolicy>
+senf::SocketHandle<SocketPolicy>::cast_dynamic(FileHandle handle)
 {
     // throws bad_cast if the body is not a SocketBody
     SocketBody & body (dynamic_cast<SocketBody&>(FileHandle::body(handle)));
-    // throws bad_cast if the poplicy is not compatible
+    // throws bad_cast if the policy is not compatible
     SocketPolicy::checkBaseOf(body.protocol().policy());
     return cast_static(handle);
 }
 
 template <class Target, class Source>
-prefix_ Target satcom::lib::static_socket_cast(Source handle)
+prefix_ Target senf::static_socket_cast(Source handle)
 {
     BOOST_STATIC_ASSERT((
         boost::is_convertible<Source*,FileHandle*>::value &&
@@ -122,7 +128,7 @@ prefix_ Target satcom::lib::static_socket_cast(Source handle)
 }
 
 template <class Target, class Source>
-prefix_ Target satcom::lib::dynamic_socket_cast(Source handle)
+prefix_ Target senf::dynamic_socket_cast(Source handle)
 {
     BOOST_STATIC_ASSERT((
         boost::is_convertible<Source*,FileHandle*>::value &&
@@ -133,7 +139,7 @@ prefix_ Target satcom::lib::dynamic_socket_cast(Source handle)
 }
 
 template <class Target, class Source>
-prefix_ bool satcom::lib::check_socket_cast(Source handle)
+prefix_ bool senf::check_socket_cast(Source handle)
 {
     BOOST_STATIC_ASSERT((
         boost::is_convertible<Source*,FileHandle*>::value &&
@@ -156,33 +162,35 @@ prefix_ bool satcom::lib::check_socket_cast(Source handle)
 }
 
 template <class SocketPolicy>
-prefix_ void satcom::lib::SocketHandle<SocketPolicy>::state(SocketStateMap & map, unsigned lod)
+prefix_ void senf::SocketHandle<SocketPolicy>::state(SocketStateMap & map, unsigned lod)
 {
-    map["handle"] = prettyName(typeid(*this));
+    // We use typeid here even though the type of *this is static
+    // (SocketHandle is not polymorphic and has no vtable). This will
+    // automatically include the SocketPolicy template parameter in
+    // the type name and therefore show the \e static policy of the
+    // socket handle.
+    map["handle"] << prettyName(typeid(*this));
     body().state(map,lod);
 }
 
 template <class SocketPolicy>
-prefix_ std::string satcom::lib::SocketHandle<SocketPolicy>::dumpState(unsigned lod)
+prefix_ std::string senf::SocketHandle<SocketPolicy>::dumpState(unsigned lod)
 {
     SocketStateMap map;
     state(map,lod);
     return detail::dumpState(map);
 }
 
-///////////////////////////////////////////////////////////////////////////
-// satcom::lib::detail::ConvertibleString
-
-template <class T>
-prefix_ satcom::lib::detail::ConvertibleString::ConvertibleString(T const & other)
-    : std::string(boost::lexical_cast<std::string>(other))
-{}
-
 ///////////////////////////////cti.e///////////////////////////////////////
 #undef prefix_
 
 \f
 // Local Variables:
 // mode: c++
-// c-file-style: "satcom"
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
 // End: