Equalizer  1.13.0
Parallel Rendering Framework
eq/fabric/error.h
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 
32 class Error
33 {
34  typedef void (Error::*bool_t)() const;
35  void bool_true() const {}
36 
37 public:
39  EQFABRIC_API Error( const uint32_t code,
40  const uint128_t& originator = uint128_t( ));
41 
43  EQFABRIC_API Error& operator = ( const ErrorCode code );
44 
46  EQFABRIC_API operator bool_t() const;
47 
49  EQFABRIC_API bool operator ! () const;
50 
52  EQFABRIC_API uint32_t getCode() const;
53 
55  EQFABRIC_API const uint128_t& getOriginator() const;
56 
58  EQFABRIC_API bool operator == ( const Error& rhs ) const;
59 
61  EQFABRIC_API bool operator != ( const Error& rhs ) const;
62 
64  EQFABRIC_API bool operator == ( const uint32_t code ) const;
65 
67  EQFABRIC_API bool operator != ( const uint32_t code ) const;
68 
69  EQFABRIC_API Error();
70  EQFABRIC_API void serialize( co::DataOStream& os ) const;
71  EQFABRIC_API void deserialize( co::DataIStream& is );
72 
73 private:
74  friend void lunchbox::byteswap< Error >( Error& value );
75 
76  uint32_t _code;
77  uint128_t _originator;
78 };
79 
81 EQFABRIC_API std::ostream& operator << ( std::ostream& os, const Error& );
82 
83 }
84 }
85 
86 namespace lunchbox
87 {
88 template<> inline void byteswap( eq::fabric::Error& value )
89 {
90  byteswap( value._code );
91  byteswap( value._originator );
92 }
93 }
94 
95 #endif // EQFABRIC_ERROR_H
Defines export visibility macros for library EqualizerFabric.
EQFABRIC_API const uint128_t & getOriginator() const
EQFABRIC_API uint32_t getCode() const
ErrorCode
Defines errors produced by Equalizer classes.
Definition: errorCodes.h:29
A wrapper for error codes to allow intuitive bool-like usage.
The Equalizer client library.
Definition: eq/agl/types.h:23
EQFABRIC_API bool operator==(const Error &rhs) const
EQFABRIC_API bool operator!=(const Error &rhs) const
EQFABRIC_API Error & operator=(const ErrorCode code)
Assign the given error code.
EQFABRIC_API bool operator!() const