UNAddressing.hh

Go to the documentation of this file.
00001 // $Id: UNAddressing.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     David Wagner <dw6@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 
00026 #ifndef HH_SENF_Socket_Protocols_UN_UNAddressing_
00027 #define HH_SENF_Socket_Protocols_UN_UNAddressing_ 1
00028 
00029 // Custom includes
00030 #include <iostream>
00031 #include <string>
00032 #include <sys/socket.h>
00033 #include <sys/un.h>
00034 #include <senf/Socket/Protocols/BSDAddressingPolicy.hh>
00035 #include <senf/Socket/Protocols/BSDSocketAddress.hh>
00036 
00037 //#include "UNAddressing.mpp"
00038 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00039 
00040 namespace senf {
00041 
00051     class UNSocketAddress
00052         : public BSDSocketAddress
00053     {
00054     public:
00055         static short const addressFamily = AF_UNIX;
00056 
00057         UNSocketAddress();
00058 
00059         explicit UNSocketAddress(std::string const & path);
00061 
00062         UNSocketAddress(const UNSocketAddress& other);
00063         UNSocketAddress& operator=(const UNSocketAddress& other);
00064 
00065         std::string path() const ;      
00066         void path(std::string const & path);
00067 
00068         using BSDSocketAddress::sockaddr_p;
00069         using BSDSocketAddress::socklen_p;
00070 
00071     private:
00072         struct sockaddr_un addr_;
00073     };
00074 
00079     std::ostream & operator<<(std::ostream & os, UNSocketAddress const & addr);
00080 
00082     //\{
00083 
00096     struct UNAddressingPolicy
00097         : public BSDAddressingPolicy,
00098           private BSDAddressingPolicyMixin<UNSocketAddress>
00099     {
00100         typedef UNSocketAddress Address;
00101 
00102         using BSDAddressingPolicyMixin<UNSocketAddress>::peer;
00103         using BSDAddressingPolicyMixin<UNSocketAddress>::local;
00104         using BSDAddressingPolicyMixin<UNSocketAddress>::connect;
00105         using BSDAddressingPolicyMixin<UNSocketAddress>::bind;
00106     };
00107 
00108     //\}
00109 }
00110 
00111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00112 #include "UNAddressing.cci"
00113 //#include "UNAddressing.ct"
00114 //#include "UNAddressing.cti"
00115 #endif
00116 
00117 
00118 // Local Variables:
00119 // mode: c++
00120 // fill-column: 100
00121 // comment-column: 40
00122 // c-file-style: "senf"
00123 // indent-tabs-mode: nil
00124 // ispell-local-dictionary: "american"
00125 // compile-command: "scons -u test"
00126 // End: