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

Generated by: LCOV version 1.11