Collage  1.0.1
Object-Oriented C++ Network Library
connectionDescription.h
1 
2 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * This file is part of Collage <https://github.com/Eyescale/Collage>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef CO_CONNECTIONDESCRIPTION_H
21 #define CO_CONNECTIONDESCRIPTION_H
22 
23 #include <co/api.h>
24 #include <co/connectionType.h> // member enum
25 #include <co/types.h>
26 
27 #include <lunchbox/referenced.h> // base class
28 
29 namespace co
30 {
32  class ConnectionDescription : public lunchbox::Referenced
33  {
34  public:
37 
39  int32_t bandwidth;
40 
42  uint16_t port;
43 
45  std::string hostname;
46 
48  std::string interfacename;
49 
51  std::string filename;
52 
56  , bandwidth( 0 )
57  , port( 0 )
58  , filename( "default" )
59  {}
60 
70  ConnectionDescription( std::string& data );
71 
73  CO_API void serialize( std::ostream& os ) const;
74 
76  CO_API std::string toString() const;
77 
94  CO_API bool fromString( std::string& data );
95 
101  CO_API bool isSameMulticastGroup( ConstConnectionDescriptionPtr rhs );
102 
104  CO_API bool operator == ( const ConnectionDescription& rhs ) const;
105 
107  bool operator != ( const ConnectionDescription& rhs ) const
108  { return !( *this == rhs ); }
110 
113  CO_API void setHostname( const std::string& hostname );
114  CO_API const std::string& getHostname() const;
115 
116  CO_API void setInterface( const std::string& interfacename );
117  CO_API const std::string& getInterface() const;
118 
119  CO_API void setFilename( const std::string& filename );
120  CO_API const std::string& getFilename() const;
122 
123  protected:
124  virtual ~ConnectionDescription() {}
125  };
126 
128  CO_API std::ostream& operator << ( std::ostream&,
129  const ConnectionDescription& );
130 
132  CO_API std::string serialize( const ConnectionDescriptions& );
133 
143  CO_API bool deserialize( std::string& data,
144  ConnectionDescriptions& descriptions );
145 }
146 
147 #endif // CO_CONNECTION_DESCRIPTION_H
std::string interfacename
The host name of the interface (multicast).
uint16_t port
The listening port (TCPIP, SDP, IB, MCIP, RDMA).
bool operator!=(const ConnectionDescription &rhs) const
Describes Connection parameters.
CO_API std::string serialize(const ConnectionDescriptions &)
Serialize a vector of connection descriptions to a string.
CO_API void serialize(std::ostream &os) const
Serialize this description to a std::ostream.
ConnectionDescription()
Construct a new, default description.
int32_t bandwidth
The bandwidth in kilobyte per second.
CO_API bool fromString(std::string &data)
Read the connection description from a string.
std::string hostname
The hostname to bind or connect to.
ConnectionType
The supported network protocols.
std::vector< ConnectionDescriptionPtr > ConnectionDescriptions
A vector of ConnectionDescriptionPtr&#39;s.
Definition: types.h:123
CO_API bool deserialize(std::string &data, ConnectionDescriptions &descriptions)
Deserialize a vector or connection descriptions from a string.
std::string filename
The filename used for named pipes.
ConnectionType type
The network protocol for the connection.
lunchbox::RefPtr< const ConnectionDescription > ConstConnectionDescriptionPtr
A reference pointer for const ConnectionDescription pointers.
Definition: types.h:93
CO_API std::string toString() const
CO_API bool operator==(const ConnectionDescription &rhs) const