switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Socket / SocketHandle.cc
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief SocketHandle non-inline non-template implementation
30  */
31
32 #include "SocketHandle.hh"
33 #include "SocketHandle.ih"
34
35 // Custom includes
36 #include <sstream>
37 #include <senf/Utils/TypeInfo.hh>
38
39 //#include "SocketHandle.mpp"
40 #define prefix_
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 // senf::SocketBody
45
46 prefix_ void senf::SocketBody::state(SocketStateMap & map, unsigned lod)
47 {
48     map["file.handle"]     << fd();
49     map["file.refcount"]   << refcount();
50     map["socket.server"]   << isServer();
51     map["socket.protocol"] << v_protocolName();
52     map["socket.protocol.policy"] << prettyName(typeid(protocol().policy()));
53     protocol().state(map,lod);
54 }
55
56 prefix_ void senf::SocketBody::v_close()
57 {
58     protocol().close();
59 }
60
61 prefix_ void senf::SocketBody::v_terminate()
62 {
63     protocol().terminate();
64 }
65
66 prefix_ bool senf::SocketBody::v_eof()
67     const
68 {
69     return protocol().eof();
70 }
71
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 // senf::detail::StateMapOrdering
74
75 namespace {
76     bool contains(std::string::const_iterator b, std::string::const_iterator e, char c)
77     {
78         for (; b != e; ++b)
79             if (*b == c)
80                 return true;
81         return false;
82     }
83 }
84
85 prefix_ std::string senf::detail::dumpState(SocketStateMap const & map)
86 {
87     std::stringstream s;
88     SocketStateMap::const_iterator i (map.begin());
89     SocketStateMap::const_iterator i_end (map.end());
90     for (; i != i_end; ++i)
91         s << i->first << ": " << i->second << "\n";
92     return s.str();
93 }
94
95 //-/////////////////////////////////////////////////////////////////////////////////////////////////
96 #undef prefix_
97 //#include "SocketHandle.mpp"
98
99 \f
100 // Local Variables:
101 // mode: c++
102 // fill-column: 100
103 // c-file-style: "senf"
104 // indent-tabs-mode: nil
105 // ispell-local-dictionary: "american"
106 // compile-command: "scons -u test"
107 // comment-column: 40
108 // End: