LCOV - code coverage report
Current view: top level - co - connectionDescription.h (source / functions) Hit Total Coverage
Test: Collage Lines: 5 7 71.4 %
Date: 2018-01-09 16:37:03 Functions: 3 4 75.0 %

          Line data    Source code
       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             : {
      31             : /** Describes Connection parameters. */
      32             : class ConnectionDescription : public lunchbox::Referenced
      33             : {
      34             : public:
      35             :     /** The network protocol for the connection. @version 1.0 */
      36             :     ConnectionType type;
      37             : 
      38             :     /** The bandwidth in kilobyte per second. @version 1.0 */
      39             :     int32_t bandwidth;
      40             : 
      41             :     /** The listening port (TCPIP, IB, MCIP, RDMA). @version 1.0 */
      42             :     uint16_t port;
      43             : 
      44             :     /** Use a random, instead of fixed, multicast port. @version 1.2 */
      45             :     static const uint16_t RANDOM_MULTICAST_PORT = 1;
      46             : 
      47             :     /** The hostname to bind or connect to. @version 1.0 */
      48             :     std::string hostname;
      49             : 
      50             :     /** The host name of the interface (multicast). @version 1.0 */
      51             :     std::string interfacename;
      52             : 
      53             :     /** The filename used for named pipes. @version 1.0 */
      54             :     std::string filename;
      55             : 
      56             :     /** Construct a new, default description. @version 1.0 */
      57         551 :     ConnectionDescription()
      58         551 :         : type(CONNECTIONTYPE_TCPIP)
      59             :         , bandwidth(0)
      60             :         , port(0)
      61         551 :         , filename("default")
      62             :     {
      63         551 :     }
      64             : 
      65             :     /**
      66             :      * Construct a description from a string representation.
      67             :      *
      68             :      * The given data is consumed, that is, the data string should be empty
      69             :      * on return when a single description was given.
      70             :      *
      71             :      * @sa fromString()
      72             :      * @version 1.0
      73             :      */
      74             :     explicit ConnectionDescription(std::string& data);
      75             : 
      76             :     /** Serialize this description to a std::ostream. @version 1.0 */
      77             :     CO_API void serialize(std::ostream& os) const;
      78             : 
      79             :     /** @return this description as a string. @version 1.0 */
      80             :     CO_API std::string toString() const;
      81             : 
      82             :     /**
      83             :      * Read the connection description from a string.
      84             :      *
      85             :      * The string is consumed as the description is parsed. Two different
      86             :      * formats are recognized, a human-readable and a machine-readable. The
      87             :      * human-readable version has the format
      88             :      * <code>hostname[:port][:type]</code> or
      89             :      * <code>filename:PIPE</code>. The <code>type</code> parameter can be
      90             :      * TCPIP, IB, MCIP, UDT or RSP. The machine-readable format
      91             :      * contains all connection description parameters, is not documented and
      92             :      * subject to change.
      93             :      *
      94             :      * @param data the string containing the connection description.
      95             :      * @return true if the information was read correctly, false if not.
      96             :      * @version 1.0
      97             :      */
      98             :     CO_API bool fromString(std::string& data);
      99             : 
     100             :     /** @name Data Access */
     101             :     //@{
     102             :     /** @internal
     103             :      * @return true if the two descriptions configure the same mc group.
     104             :      */
     105             :     CO_API bool isSameMulticastGroup(ConstConnectionDescriptionPtr rhs);
     106             : 
     107             :     /** @return true if the two descriptions have the same values. */
     108             :     CO_API bool operator==(const ConnectionDescription& rhs) const;
     109             : 
     110             :     /** @return true if the two descriptions have the different values. */
     111           0 :     bool operator!=(const ConnectionDescription& rhs) const
     112             :     {
     113           0 :         return !(*this == rhs);
     114             :     }
     115             :     //@}
     116             : 
     117             :     /** @deprecated @name Deprecated Data Access */
     118             :     //@{
     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;
     127             :     //@}
     128             : 
     129             : protected:
     130        1084 :     virtual ~ConnectionDescription() {}
     131             : };
     132             : 
     133             : /** Output the given description in human-readable format. */
     134             : CO_API std::ostream& operator<<(std::ostream&, const ConnectionDescription&);
     135             : 
     136             : /** Serialize a vector of connection descriptions to a string. */
     137             : CO_API std::string serialize(const ConnectionDescriptions&);
     138             : 
     139             : /**
     140             :  * Deserialize a vector or connection descriptions from a string.
     141             :  *
     142             :  * Consumes the data.
     143             :  *
     144             :  * @param data The serialized connection descriptions.
     145             :  * @param descriptions return value, deserialized connection descriptions.
     146             :  * @return true on successful parsing, false otherwise.
     147             :  */
     148             : CO_API bool deserialize(std::string& data,
     149             :                         ConnectionDescriptions& descriptions);
     150             : }
     151             : 
     152             : #endif // CO_CONNECTION_DESCRIPTION_H

Generated by: LCOV version 1.11