Collage  1.4.0
High-performance C++ library for developing object-oriented distributed applications.
connectionDescription.h
1 
2 /* Copyright (c) 2005-2015, 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  static const uint16_t RANDOM_MULTICAST_PORT = 1;
46 
48  std::string hostname;
49 
51  std::string interfacename;
52 
54  std::string filename;
55 
58  : type( CONNECTIONTYPE_TCPIP )
59  , bandwidth( 0 )
60  , port( 0 )
61  , filename( "default" )
62  {}
63 
73  explicit ConnectionDescription( std::string& data );
74 
76  CO_API void serialize( std::ostream& os ) const;
77 
79  CO_API std::string toString() const;
80 
97  CO_API bool fromString( std::string& data );
98 
104  CO_API bool isSameMulticastGroup( ConstConnectionDescriptionPtr rhs );
105 
107  CO_API bool operator == ( const ConnectionDescription& rhs ) const;
108 
110  bool operator != ( const ConnectionDescription& rhs ) const
111  { return !( *this == rhs ); }
113 
116  CO_API void setHostname( const std::string& hostname );
117  CO_API const std::string& getHostname() const;
118 
119  CO_API void setInterface( const std::string& interfacename );
120  CO_API const std::string& getInterface() const;
121 
122  CO_API void setFilename( const std::string& filename );
123  CO_API const std::string& getFilename() const;
125 
126 protected:
127  virtual ~ConnectionDescription() {}
128 };
129 
131 CO_API std::ostream& operator << ( std::ostream&,
132  const ConnectionDescription& );
133 
135 CO_API std::string serialize( const ConnectionDescriptions& );
136 
146 CO_API bool deserialize( std::string& data,
147  ConnectionDescriptions& descriptions );
148 }
149 
150 #endif // CO_CONNECTION_DESCRIPTION_H
Describes Connection parameters.
Defines export visibility macros for library Collage.
int32_t bandwidth
The bandwidth in kilobyte per second.
CO_API std::string serialize(const ConnectionDescriptions &)
Serialize a vector of connection descriptions to a string.
ConnectionType type
The network protocol for the connection.
CO_API void serialize(std::ostream &os) const
Serialize this description to a std::ostream.
uint16_t port
The listening port (TCPIP, IB, MCIP, RDMA).
bool operator!=(const ConnectionDescription &rhs) const
std::string interfacename
The host name of the interface (multicast).
Object-oriented network library.
Definition: barrier.h:27
ConnectionDescription()
Construct a new, default description.
CO_API std::string toString() const
std::string hostname
The hostname to bind or connect to.
CO_API bool operator==(const ConnectionDescription &rhs) const
static const uint16_t RANDOM_MULTICAST_PORT
Use a random, instead of fixed, multicast port.
CO_API bool fromString(std::string &data)
Read the connection description from a string.
ConnectionType
The supported network protocols.
std::vector< ConnectionDescriptionPtr > ConnectionDescriptions
A vector of ConnectionDescriptionPtr's.
Definition: types.h:131
CO_API bool deserialize(std::string &data, ConnectionDescriptions &descriptions)
Deserialize a vector or connection descriptions from a string.
lunchbox::RefPtr< const ConnectionDescription > ConstConnectionDescriptionPtr
A reference pointer for const ConnectionDescription pointers.
Definition: types.h:98
std::string filename
The filename used for named pipes.