LCOV - code coverage report
Current view: top level - co - connectionDescription.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 4 6 66.7 %
Date: 2014-10-06 Functions: 3 4 75.0 %

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

Generated by: LCOV version 1.10