Collage  1.7.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  }
64 
74  explicit ConnectionDescription(std::string& data);
75 
77  CO_API void serialize(std::ostream& os) const;
78 
80  CO_API std::string toString() const;
81 
98  CO_API bool fromString(std::string& data);
99 
105  CO_API bool isSameMulticastGroup(ConstConnectionDescriptionPtr rhs);
106 
108  CO_API bool operator==(const ConnectionDescription& rhs) const;
109 
111  bool operator!=(const ConnectionDescription& rhs) const
112  {
113  return !(*this == rhs);
114  }
116 
119  CO_API void setHostname(const std::string& hostname);
120  CO_API const std::string& getHostname() const;
121 
122  CO_API void setInterface(const std::string& interfacename);
123  CO_API const std::string& getInterface() const;
124 
125  CO_API void setFilename(const std::string& filename);
126  CO_API const std::string& getFilename() const;
128 
129 protected:
130  virtual ~ConnectionDescription() {}
131 };
132 
134 CO_API std::ostream& operator<<(std::ostream&, const ConnectionDescription&);
135 
137 CO_API std::string serialize(const ConnectionDescriptions&);
138 
148 CO_API bool deserialize(std::string& data,
149  ConnectionDescriptions& descriptions);
150 }
151 
152 #endif // CO_CONNECTION_DESCRIPTION_H
Describes Connection parameters.
Defines export visibility macros for library Collage.
int32_t bandwidth
The bandwidth in kilobyte per second.
std::vector< ConnectionDescriptionPtr > ConnectionDescriptions
A vector of ConnectionDescriptionPtr&#39;s.
Definition: types.h:131
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.
lunchbox::RefPtr< const ConnectionDescription > ConstConnectionDescriptionPtr
A reference pointer for const ConnectionDescription pointers.
Definition: types.h:98
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.
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.