LCOV - code coverage report
Current view: top level - eq/fabric - error.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 6 0.0 %
Date: 2016-09-29 05:02:09 Functions: 0 3 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2016, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQFABRIC_ERROR_H
      20             : #define EQFABRIC_ERROR_H
      21             : 
      22             : #include <eq/fabric/api.h>
      23             : #include <eq/fabric/types.h>
      24             : #include <lunchbox/bitOperation.h> // inline template specialization
      25             : 
      26             : namespace eq
      27             : {
      28             : namespace fabric
      29             : {
      30             : 
      31             : /** A wrapper for error codes to allow intuitive bool-like usage. */
      32           0 : class Error
      33             : {
      34             :     typedef void (Error::*bool_t)() const;
      35           0 :     void bool_true() const {}
      36             : 
      37             : public:
      38             :     /** Construct a new error. @version 1.7.1 */
      39             :     EQFABRIC_API Error( const uint32_t code,
      40             :                         const uint128_t& originator = uint128_t( ));
      41             : 
      42             :     /** Assign the given error code. @version 1.7.1*/
      43             :     EQFABRIC_API Error& operator = ( const ErrorCode code );
      44             : 
      45             :     /** @return true if an error occured. @version 1.7.1 */
      46             :     EQFABRIC_API operator bool_t() const;
      47             : 
      48             :     /** @return true if no error occured. @version 1.7.1 */
      49             :     EQFABRIC_API bool operator ! () const;
      50             : 
      51             :     /** @return the error code. @version 1.7.1 */
      52             :     EQFABRIC_API uint32_t getCode() const;
      53             : 
      54             :     /** @return the ID of the originator, a co::Object. @version 1.9 */
      55             :     EQFABRIC_API const uint128_t& getOriginator() const;
      56             : 
      57             :     /** @return true if the two errors have the same value. @version 1.7.1*/
      58             :     EQFABRIC_API bool operator == ( const Error& rhs ) const;
      59             : 
      60             :     /** @return true if the two errors have different values. @version 1.7.1*/
      61             :     EQFABRIC_API bool operator != ( const Error& rhs ) const;
      62             : 
      63             :     /** @return true if the two errors have the same value. @version 1.7.1*/
      64             :     EQFABRIC_API bool operator == ( const uint32_t code ) const;
      65             : 
      66             :     /** @return true if the two errors have different values. @version 1.7.1*/
      67             :     EQFABRIC_API bool operator != ( const uint32_t code ) const;
      68             : 
      69             :     EQFABRIC_API Error(); //!< @internal
      70             :     EQFABRIC_API void serialize( co::DataOStream& os ) const; //!< @internal
      71             :     EQFABRIC_API void deserialize( co::DataIStream& is ); //!< @internal
      72             : 
      73             : private:
      74             :     friend void lunchbox::byteswap< Error >( Error& value );
      75             : 
      76             :     uint32_t _code;
      77             :     uint128_t _originator;
      78             : };
      79             : 
      80             : /** Print the error in a human-readable format. @version 1.0 */
      81             : EQFABRIC_API std::ostream& operator << ( std::ostream& os, const Error& );
      82             : 
      83             : }
      84             : }
      85             : 
      86             : namespace lunchbox
      87             : {
      88           0 : template<> inline void byteswap( eq::fabric::Error& value )
      89             : {
      90           0 :     byteswap( value._code );
      91           0 :     byteswap( value._originator );
      92           0 : }
      93             : }
      94             : 
      95             : #endif // EQFABRIC_ERROR_H

Generated by: LCOV version 1.11