LCOV - code coverage report
Current view: top level - eq/fabric - errorRegistry.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 20 23 87.0 %
Date: 2014-06-18 Functions: 9 10 90.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2012, Stefan Eilemann <eile@eyescale.ch>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include "errorRegistry.h"
      19             : 
      20             : #include "error.h"
      21             : 
      22             : #include <lunchbox/stdExt.h>
      23             : 
      24             : namespace eq
      25             : {
      26             : namespace fabric
      27             : {
      28             : namespace
      29             : {
      30          15 : static std::string _empty;
      31             : typedef stde::hash_map< uint32_t, std::string > ErrorHash;
      32             : }
      33             : 
      34             : namespace detail
      35             : {
      36          30 : class ErrorRegistry
      37             : {
      38             : public:
      39             :     ErrorHash errors;
      40             : };
      41             : }
      42             : 
      43          15 : ErrorRegistry::ErrorRegistry()
      44          15 :         : _impl( new detail::ErrorRegistry )
      45             : {
      46          15 :     _impl->errors[ ERROR_NONE ] = "no error";
      47          15 : }
      48             : 
      49          15 : ErrorRegistry::~ErrorRegistry()
      50             : {
      51          15 :     delete _impl;
      52          15 : }
      53             : 
      54          15 : const std::string& ErrorRegistry::getString( const uint32_t error ) const
      55             : {
      56          15 :     ErrorHash::const_iterator i = _impl->errors.find( error );
      57          15 :     if( i == _impl->errors.end( ))
      58           0 :         return _empty;
      59             : 
      60          15 :     return i->second;
      61             : }
      62             : 
      63             : 
      64         684 : void ErrorRegistry::setString( const uint32_t error, const std::string& text )
      65             : {
      66         684 :     _impl->errors[ error ] = text;
      67         684 : }
      68             : 
      69         684 : void ErrorRegistry::eraseString( const uint32_t error )
      70             : {
      71         684 :     _impl->errors.erase( error );
      72         684 : }
      73             : 
      74           0 : bool ErrorRegistry::isEmpty() const
      75             : {
      76           0 :     return _impl->errors.empty();
      77             : }
      78             : 
      79             : }
      80          45 : }

Generated by: LCOV version 1.10