|
Gaudi Framework, version v21r6 |
| Home | Generated: 11 Nov 2009 |
#include <GslSvc.h>


The Gsl Service is teh service which perform intelligent error handling for GSL (GNU Scientific Library)
It provides a choice between different "Error Handling Policies"
Current implementation supports the several "error handling policies", which are driven by "ErrorPolicy" property of class GslSvc:
GslErrorHandlers::ingnoreTheError
GslErrorHandlers::throwException
Definition at line 86 of file GslSvc.h.
Public Member Functions | |
| virtual StatusCode | handle (const GslError &error) const |
| handle the GSL error | |
| virtual GslErrorHandler | handler () const |
| retrieve the current GSL error handler | |
| virtual GslErrorHandler | setHandler (GslErrorHandler handler) const |
| set new GSL error handler | |
| virtual StatusCode | status (const int error) const |
| transform GSL error code to Gaudi status code | |
| virtual StatusCode | initialize () |
| standard service initialization | |
| virtual StatusCode | finalize () |
| standard service finalization | |
| GslSvc (const std::string &name, ISvcLocator *svc) | |
| Standard constructor. | |
| virtual | ~GslSvc () |
| destructor, virtual and protected | |
Private Types | |
| typedef std::vector< std::string > | Names |
| external handlers | |
| typedef std::vector < IGslErrorHandler * > | Handlers |
Private Member Functions | |
| GslSvc () | |
| default constructor is private | |
| GslSvc (const GslSvc &) | |
| copy constructor is private | |
| GslSvc & | operator= (const GslSvc &) |
| assignment operator is private | |
Private Attributes | |
| std::string | m_errorPolicy |
| error policy | |
| Names | m_handlersTypeNames |
| Handlers | m_handlers |
| std::vector< int > | m_ignore |
| codes to be ignored | |
Friends | |
| class | SvcFactory< GslSvc > |
| friend factory for instantiation | |
typedef std::vector<std::string> GslSvc::Names [private] |
typedef std::vector<IGslErrorHandler*> GslSvc::Handlers [private] |
| GslSvc::GslSvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Standard constructor.
mandatory static factory for service instantiation
| name | service name | |
| scv | pointer to service locator |
ISvcFactory
IFactory Standard constructor
| name | service name | |
| scv | pointer to service locator |
Definition at line 48 of file GslSvc.cpp.
00050 : base_class ( name , svc ) 00051 , m_errorPolicy ( "GSL" ) 00052 , m_handlersTypeNames () 00053 , m_handlers () 00054 , m_ignore () 00055 { 00056 declareProperty( "ErrorPolicy" , m_errorPolicy ) ; 00057 declareProperty( "Handlers" , m_handlersTypeNames ) ; 00058 declareProperty( "IgnoreCodes" , m_ignore ) ; 00059 };
| GslSvc::~GslSvc | ( | ) | [virtual] |
| GslSvc::GslSvc | ( | ) | [private] |
default constructor is private
| GslSvc::GslSvc | ( | const GslSvc & | ) | [private] |
copy constructor is private
| StatusCode GslSvc::handle | ( | const GslError & | error | ) | const [virtual] |
handle the GSL error
| err | error |
| error | error |
Implements IGslSvc.
Definition at line 234 of file GslSvc.cpp.
00235 { 00236 StatusCode sc = StatusCode::SUCCESS ; 00237 // code to be ignored? 00238 if( m_ignore.end() != std::find( m_ignore.begin () , 00239 m_ignore.end () , 00240 error.code ) ) { return sc ; } 00241 // invoke all handlers 00242 for( Handlers::const_iterator handler = m_handlers.begin() ; 00243 sc.isSuccess() && m_handlers.end() != handler ; ++handler ) 00244 { sc = (*handler)->handle( error ); } 00245 // 00246 return sc ; 00247 };
| IGslSvc::GslErrorHandler GslSvc::handler | ( | ) | const [virtual] |
retrieve the current GSL error handler
current GSL error handler
Implements IGslSvc.
Definition at line 183 of file GslSvc.cpp.
00184 { 00185 GslErrorHandler hh = gsl_set_error_handler( 0 ); 00186 gsl_set_error_handler( hh ); 00187 return hh ; 00188 };
| virtual GslErrorHandler GslSvc::setHandler | ( | GslErrorHandler | handler | ) | const [virtual] |
set new GSL error handler
| handler | new GSL error handler |
| StatusCode GslSvc::status | ( | const int | error | ) | const [virtual] |
transform GSL error code to Gaudi status code
| error | GLS error code |
| error | GLS error code |
Implements IGslSvc.
Definition at line 218 of file GslSvc.cpp.
00219 { 00220 if( GSL_SUCCESS == error ){ return StatusCode::SUCCESS ; } 00221 StatusCode sc( error ); 00222 if( sc.isSuccess() ){ return StatusCode::FAILURE ; } 00223 return sc ; 00224 };
| StatusCode GslSvc::initialize | ( | ) | [virtual] |
standard service initialization
Prints the type of used handler get the handler
Get Tool Service
Reimplemented from Service.
Definition at line 75 of file GslSvc.cpp.
00076 { 00077 // initialize the base class 00078 StatusCode sc = Service::initialize(); 00079 MsgStream log( msgSvc() , name() ); 00080 if( sc.isFailure() ) 00081 { log << MSG::ERROR 00082 << " Error in initialization of base class 'Service'"<< endmsg; 00083 return sc; 00084 } 00085 // activate the static accessor to the service 00086 GaudiGSL::setGslSvc( this ); 00087 // set the error handlers 00088 if ( "GSL" == m_errorPolicy ) { /* nothing to do */ } 00089 else if ( "Off" == m_errorPolicy ) 00090 { gsl_set_error_handler_off() ; } 00091 else if ( "Abort" == m_errorPolicy ) 00092 { gsl_set_error_handler ( 0 ) ; } 00093 else if ( "Ignore" == m_errorPolicy ) 00094 { gsl_set_error_handler ( GslErrorHandlers::ignoreTheError ) ; } 00095 else if ( "Exception" == m_errorPolicy ) 00096 { gsl_set_error_handler ( GslErrorHandlers::throwException ) ; } 00097 else if ( "Handle" == m_errorPolicy ) 00098 { gsl_set_error_handler ( GslErrorHandlers::handleTheError ) ; } 00099 else 00100 { log << MSG::ERROR 00101 << " Unknown Error policy '" << m_errorPolicy << "'" 00102 << " Valid policies: " 00103 << "[ 'GSL' , 'Off' , 'Abort' , 'Ignore' , 'Exception' , 'Handle' ]" 00104 << endmsg; 00105 return StatusCode::FAILURE ; 00106 } 00109 GslErrorHandler handler = gsl_set_error_handler( 0 ); 00110 gsl_set_error_handler( handler ); 00111 if( 0 != handler ) 00112 { log << MSG::VERBOSE 00113 << " GSL Error Handler is '" 00114 << System::typeinfoName( typeid(*handler) ) << "'" 00115 << endmsg; } 00116 else { log << MSG::INFO << " Error Handler is NULL" << endmsg ; } 00117 00118 if( !m_handlersTypeNames.empty() ) 00119 { 00121 SmartIF<IToolSvc> toolsvc(serviceLocator()->service("ToolSvc")); 00122 if (!toolsvc.isValid()) { 00123 log << MSG::ERROR << " Could not locate Tool Service! " << endmsg; 00124 return StatusCode::FAILURE; 00125 } 00126 StatusCode sc; 00127 for( Names::const_iterator it = m_handlersTypeNames.begin() ; 00128 m_handlersTypeNames.end() != it ; ++it ) 00129 { 00130 std::string::const_iterator ipos = 00131 std::find( it->begin() , it->end() , '/'); 00132 const std::string::size_type pos = ipos - it->begin() ; 00133 IGslErrorHandler* eh = 0 ; 00134 if( it->end() != ipos ) 00135 { sc = toolsvc->retrieveTool 00136 ( std::string( *it , 0 , pos ) , 00137 std::string( *it , pos + 1, it->length() ), eh , this ) ; } 00138 else 00139 { sc = toolsvc->retrieveTool 00140 ( *it , std::string( *it , pos + 1, it->length() ) , 00141 eh , this ) ; } 00142 if( sc.isFailure() ) 00143 { log << MSG::ERROR 00144 << " Could not retrieve tool '" << *it << "'"<< endmsg ; 00145 return sc ; } 00146 if( 0 == eh ) 00147 { log << MSG::ERROR 00148 << " Could not retrieve tool '" << *it << "'"<< endmsg ; 00149 return StatusCode::FAILURE ; } 00150 m_handlers.push_back( eh ); 00151 } 00152 } 00153 // 00154 return StatusCode::SUCCESS; 00155 };
| StatusCode GslSvc::finalize | ( | void | ) | [virtual] |
standard service finalization
Reimplemented from Service.
Definition at line 165 of file GslSvc.cpp.
00166 { 00167 MsgStream log(msgSvc(), name()); 00168 log << MSG::DEBUG << "==> Finalize" << endmsg; 00169 00170 // deactivate the static accessor to the service 00171 GaudiGSL::setGslSvc( 0 ); 00172 00173 // finalize the base class 00174 return Service::finalize() ; 00175 };
friend class SvcFactory< GslSvc > [friend] |
std::string GslSvc::m_errorPolicy [private] |
Names GslSvc::m_handlersTypeNames [private] |
Handlers GslSvc::m_handlers [private] |
std::vector<int> GslSvc::m_ignore [private] |