LCOV - code coverage report
Current view: top level - eq/fabric - error.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 32 53 60.4 %
Date: 2016-07-30 05:04:55 Functions: 12 20 60.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2015, 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             : #include "error.h"
      20             : 
      21             : #include "errorRegistry.h"
      22             : #include "global.h"
      23             : 
      24             : #include <co/dataIStream.h>
      25             : #include <co/dataOStream.h>
      26             : 
      27             : namespace eq
      28             : {
      29             : namespace fabric
      30             : {
      31             : 
      32             : namespace
      33             : {
      34        1988 : struct ErrorData
      35             : {
      36             :     const uint32_t code;
      37             :     const std::string text;
      38             : };
      39             : 
      40          56 : ErrorData _errors[] = {
      41             :     { ERROR_FBO_UNSUPPORTED, "Framebuffer objects not supported" },
      42             :     { ERROR_FRAMEBUFFER_STATUS, "Error querying framebuffer status" },
      43             :     { ERROR_FRAMEBUFFER_UNSUPPORTED, "Unsupported framebuffer format" },
      44             :     { ERROR_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,
      45             :       "Framebuffer incomplete, missing attachment" },
      46             :     { ERROR_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,
      47             :       "Framebuffer incomplete, incomplete attachment" },
      48             :     { ERROR_FRAMEBUFFER_INCOMPLETE_DIMENSIONS,
      49             :       "Framebuffer incomplete, attached images must have same dimensions" },
      50             :     { ERROR_FRAMEBUFFER_INCOMPLETE_FORMATS,
      51             :       "Framebuffer incomplete, attached images must have same format" },
      52             :     { ERROR_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER,
      53             :       "Framebuffer incomplete, missing draw buffer" },
      54             :     { ERROR_FRAMEBUFFER_INCOMPLETE_READ_BUFFER,
      55             :       "Framebuffer incomplete, missing read buffer" },
      56             :     { ERROR_FRAMEBUFFER_INITIALIZED, "FBO already initialized" },
      57             :     { ERROR_FRAMEBUFFER_INVALID_SIZE, "FBO size not supported" },
      58             :     { ERROR_FRAMEBUFFER_INVALID_SAMPLES, "Multisampled FBO not supported" },
      59             :     { ERROR_CUDACONTEXT_DEVICE_NOTFOUND,
      60             :       "Device not found, not enough CUDA devices" },
      61             :     { ERROR_CUDACONTEXT_INIT_FAILED,
      62             :       "CUDA initialization failed (see client log for more information)" },
      63             :     { ERROR_CUDACONTEXT_MISSING_SUPPORT,
      64             :       "Client library compiled without CUDA support" },
      65             : 
      66             :     { ERROR_WINDOWSYSTEM_UNKNOWN, "Unknown windowing system" },
      67             : 
      68             :     { ERROR_NODE_LAUNCH, "Execution of node launch command failed" },
      69             :     { ERROR_NODE_CONNECT, "Node process did not start" },
      70             : 
      71             :     { ERROR_PIPE_NODE_NOTRUNNING, "Node not running" },
      72             : 
      73             :     { ERROR_SYSTEMPIPE_PIXELFORMAT_NOTFOUND,
      74             :       "Can't find temporary pixel format" },
      75             :     { ERROR_SYSTEMPIPE_CREATECONTEXT_FAILED,
      76             :       "Can't create temporary OpenGL context" },
      77             :     { ERROR_SYSTEMPIPE_CREATEWINDOW_FAILED, "Can't create temporary window" },
      78             : 
      79             :     { ERROR_AGLPIPE_DISPLAYS_NOTFOUND, "Can't get display identifier list" },
      80             :     { ERROR_AGLPIPE_DEVICE_NOTFOUND, "Can't get display identifier for device"},
      81             : 
      82             :     { ERROR_GLXPIPE_DEVICE_NOTFOUND, "Can't open display" },
      83             :     { ERROR_GLXPIPE_GLX_NOTFOUND, "Display does not support GLX" },
      84             :     { ERROR_GLXPIPE_GLXEWINIT_FAILED, "Pipe GLXEW initialization failed" },
      85             : 
      86             :     { ERROR_WGL_CREATEAFFINITYDC_FAILED, "Can't create affinity DC" },
      87             :     { ERROR_WGLPIPE_ENUMDISPLAYS_FAILED, "Can't enumerate display devices" },
      88             :     { ERROR_WGLPIPE_CREATEDC_FAILED, "Can't create device context" },
      89             :     { ERROR_WGLPIPE_ENUMGPUS_FAILED, "Can't enumerate GPU" },
      90             :     { ERROR_WGLPIPE_REGISTERCLASS_FAILED,
      91             :       "Can't register temporary window class" },
      92             :     { ERROR_WGLPIPE_SETPF_FAILED, "Can't set temporary pixel format" },
      93             :     { ERROR_WGLPIPE_WGLEWINIT_FAILED, "Pipe WGLEW initialization failed" },
      94             : 
      95             :     { ERROR_WINDOW_PIPE_NOTRUNNING, "Pipe not running" },
      96             :     { ERROR_WINDOW_PVP_INVALID, "Invalid window pixel viewport" },
      97             : 
      98             :     { ERROR_SYSTEMWINDOW_PIXELFORMAT_NOTFOUND,
      99             :       "Can't find matching pixel format" },
     100             :     { ERROR_SYSTEMWINDOW_NO_PIXELFORMAT, "Missing pixel format" },
     101             :     { ERROR_SYSTEMWINDOW_ARB_FLOAT_FB_REQUIRED,
     102             :       "Floating-point framebuffer not supported" },
     103             : 
     104             :     { ERROR_AGLWINDOW_NO_CONTEXT, "Missing AGL context" },
     105             :     { ERROR_AGLWINDOW_CREATECONTEXT_FAILED, "Can't create AGL context" },
     106             :     { ERROR_AGLWINDOW_CREATEPBUFFER_FAILED, "Can't create AGL PBuffer" },
     107             :     { ERROR_AGLWINDOW_SETPBUFFER_FAILED, "Can't set AGL PBuffer" },
     108             :     { ERROR_AGLWINDOW_CREATEWINDOW_FAILED, "Can't create Carbon window" },
     109             :     { ERROR_AGLWINDOW_SETWINDOW_FAILED, "Can't set Carbon window" },
     110             : 
     111             :     { ERROR_GLXWINDOW_NO_DRAWABLE, "Missing GLX drawable" },
     112             :     { ERROR_GLXWINDOW_NO_DISPLAY, "Missing X11 display connection" },
     113             :     { ERROR_GLXWINDOW_CREATECONTEXT_FAILED, "Can't create glX context" },
     114             :     { ERROR_GLXWINDOW_CREATEWINDOW_FAILED, "Can't create X11 window" },
     115             :     { ERROR_GLXWINDOW_GLXQUERYVERSION_FAILED, "Can't get GLX version" },
     116             :     { ERROR_GLXWINDOW_GLX_1_3_REQUIRED, "Need at least GLX 1.3" },
     117             :     { ERROR_GLXWINDOW_NO_FBCONFIG, "Can't find FBConfig for visual" },
     118             :     { ERROR_GLXWINDOW_NO_VISUAL, "FBConfig has no associated visual" },
     119             :     { ERROR_GLXWINDOW_CREATEPBUFFER_FAILED, "Can't create glX PBuffer" },
     120             :     { ERROR_GLXWINDOW_FBCONFIG_REQUIRED,
     121             :       "Can't find FBConfig functions (GLX 1.3 or GLX_SGIX_fbconfig" },
     122             : 
     123             :     { ERROR_WGLWINDOW_NO_DRAWABLE, "Missing WGL drawable" },
     124             :     { ERROR_WGLWINDOW_SETPIXELFORMAT_FAILED, "Can't set window pixel format" },
     125             :     { ERROR_WGLWINDOW_REGISTERCLASS_FAILED, "Can't register window class" },
     126             :     { ERROR_WGLWINDOW_FULLSCREEN_FAILED, "Can't switch to fullscreen mode" },
     127             :     { ERROR_WGLWINDOW_CREATEWINDOW_FAILED, "Can't create window" },
     128             :     { ERROR_WGLWINDOW_ARB_PBUFFER_REQUIRED, "WGL_ARB_pbuffer not supported" },
     129             :     { ERROR_WGLWINDOW_CREATEPBUFFER_FAILED, "Can't create PBuffer" },
     130             :     { ERROR_WGLWINDOW_SETAFFINITY_PF_FAILED, "Can't set affinity pixel format"},
     131             :     { ERROR_WGLWINDOW_CHOOSE_PF_ARB_FAILED,
     132             :       "Can't choose pixel format using ARB extension"},
     133             :     { ERROR_WGLWINDOW_CREATECONTEXT_FAILED, "Can't create WGL context" },
     134             : 
     135             :     { ERROR_CHANNEL_WINDOW_NOTRUNNING, "Window not running" },
     136             : 
     137             :     { ERROR_PBO_UNSUPPORTED, "Pixel Buffer Objects not supported" },
     138             :     { ERROR_PBO_NOT_INITIALIZED, "PBO is not initialized" },
     139             :     { ERROR_PBO_SIZE_TOO_SMALL, "PBO size is too small, it has to be > 0" },
     140             :     { ERROR_PBO_TYPE_UNSUPPORTED, "Unsupported PBO type" },
     141             : 
     142             :     { 0, "" } // last!
     143          28 : };
     144             : }
     145             : 
     146          12 : void _initErrors()
     147             : {
     148          12 :     eq::fabric::ErrorRegistry& registry =eq::fabric::Global::getErrorRegistry();
     149         852 :     for( size_t i=0; _errors[i].code != 0; ++i )
     150         840 :         registry.setString( _errors[i].code, _errors[i].text );
     151          12 : }
     152             : 
     153          12 : void _exitErrors()
     154             : {
     155          12 :     eq::fabric::ErrorRegistry& registry =eq::fabric::Global::getErrorRegistry();
     156         852 :     for( size_t i=0; _errors[i].code != 0; ++i )
     157         840 :         registry.eraseString( _errors[i].code );
     158          12 : }
     159             : 
     160           6 : Error::Error()
     161             :     : _code( ERROR_NONE )
     162           6 :     , _originator()
     163           6 : {}
     164             : 
     165          10 : Error::Error( const uint32_t code, const uint128_t& originator )
     166             :     : _code( code )
     167          10 :     , _originator( originator )
     168          10 : {}
     169             : 
     170           0 : Error& Error::operator = ( const ErrorCode code )
     171             : {
     172           0 :     _code = code;
     173           0 :     return *this;
     174             : }
     175             : 
     176           2 : Error::operator bool_t() const
     177             : {
     178           2 :     return _code != ERROR_NONE ? &Error::bool_true : 0;
     179             : }
     180             : 
     181           6 : bool Error::operator ! () const
     182             : {
     183           6 :     return _code == ERROR_NONE;\
     184             : }
     185             : 
     186          30 : uint32_t Error::getCode() const
     187             : {
     188          30 :     return _code;
     189             : }
     190             : 
     191           0 : const uint128_t& Error::getOriginator() const
     192             : {
     193           0 :     return _originator;
     194             : }
     195             : 
     196           0 : bool Error::operator == ( const Error& rhs ) const
     197             : {
     198           0 :     return _code == rhs._code;
     199             : }
     200             : 
     201           0 : bool Error::operator != ( const Error& rhs ) const
     202             : {
     203           0 :     return _code != rhs._code;
     204             : }
     205             : 
     206           0 : bool Error::operator == ( const uint32_t code ) const
     207             : {
     208           0 :     return _code == code;
     209             : }
     210             : 
     211           0 : bool Error::operator != ( const uint32_t code ) const
     212             : {
     213           0 :     return _code != code;
     214             : }
     215             : 
     216           0 : void Error::serialize( co::DataOStream& os ) const
     217             : {
     218           0 :     os << _code << _originator;
     219           0 : }
     220             : 
     221           0 : void Error::deserialize( co::DataIStream& is )
     222             : {
     223           0 :     is >> _code >> _originator;
     224           0 : }
     225             : 
     226          12 : std::ostream& operator << ( std::ostream& os, const Error& error )
     227             : {
     228          12 :     const ErrorRegistry& registry = Global::getErrorRegistry();
     229          12 :     const std::string& text = registry.getString( error.getCode( ));
     230             : 
     231          12 :     if( text.empty( ))
     232           0 :         return os << "error 0x" << std::hex << uint32_t( error.getCode( ))
     233           0 :                   << std::dec;
     234             : 
     235          12 :     return os << text << " (0x" << std::hex << uint32_t( error.getCode( ))
     236          12 :               << std::dec << ")";
     237             : }
     238             : 
     239             : } // fabric
     240          84 : } // eq

Generated by: LCOV version 1.11