LCOV - code coverage report
Current view: top level - eq/fabric - error.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 2 0.0 %
Date: 2017-12-16 05:07:20 Functions: 0 2 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2017, 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             : /** A wrapper for error codes to allow intuitive bool-like usage. */
      31           0 : class Error
      32             : {
      33             :     typedef void (Error::*bool_t)() const;
      34           0 :     void bool_true() const {}
      35             : public:
      36             :     /** Construct a new error. @version 1.7.1 */
      37             :     EQFABRIC_API Error(const uint32_t code,
      38             :                        const uint128_t& originator = uint128_t());
      39             : 
      40             :     /** Assign the given error code. @version 1.7.1*/
      41             :     EQFABRIC_API Error& operator=(const ErrorCode code);
      42             : 
      43             :     /** @return true if an error occured. @version 1.7.1 */
      44             :     EQFABRIC_API operator bool_t() const;
      45             : 
      46             :     /** @return true if no error occured. @version 1.7.1 */
      47             :     EQFABRIC_API bool operator!() const;
      48             : 
      49             :     /** @return the error code. @version 1.7.1 */
      50             :     EQFABRIC_API uint32_t getCode() const;
      51             : 
      52             :     /** @return the ID of the originator, a co::Object. @version 1.9 */
      53             :     EQFABRIC_API const uint128_t& getOriginator() const;
      54             : 
      55             :     /** @return true if the two errors have the same value. @version 1.7.1*/
      56             :     EQFABRIC_API bool operator==(const Error& rhs) const;
      57             : 
      58             :     /** @return true if the two errors have different values. @version 1.7.1*/
      59             :     EQFABRIC_API bool operator!=(const Error& rhs) const;
      60             : 
      61             :     /** @return true if the two errors have the same value. @version 1.7.1*/
      62             :     EQFABRIC_API bool operator==(const uint32_t code) const;
      63             : 
      64             :     /** @return true if the two errors have different values. @version 1.7.1*/
      65             :     EQFABRIC_API bool operator!=(const uint32_t code) const;
      66             : 
      67             :     EQFABRIC_API Error();                                   //!< @internal
      68             :     EQFABRIC_API void serialize(co::DataOStream& os) const; //!< @internal
      69             :     EQFABRIC_API void deserialize(co::DataIStream& is);     //!< @internal
      70             : 
      71             : private:
      72             :     uint32_t _code;
      73             :     uint128_t _originator;
      74             : };
      75             : 
      76             : /** Print the error in a human-readable format. @version 1.0 */
      77             : EQFABRIC_API std::ostream& operator<<(std::ostream& os, const Error&);
      78             : }
      79             : }
      80             : 
      81             : #endif // EQFABRIC_ERROR_H

Generated by: LCOV version 1.11