|
Gaudi Framework, version v22r2 |
| Home | Generated: Tue May 10 2011 |
The implementation of IGslSvc interface. More...
#include <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 | |
The implementation of IGslSvc interface.
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:
Definition at line 86 of file GslSvc.h.
typedef std::vector<IGslErrorHandler*> GslSvc::Handlers [private] |
typedef std::vector<std::string> GslSvc::Names [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 |
| name | service name |
| scv | pointer to service locator |
Definition at line 48 of file GslSvc.cpp.
: base_class ( name , svc ) , m_errorPolicy ( "GSL" ) , m_handlersTypeNames () , m_handlers () , m_ignore () { declareProperty( "ErrorPolicy" , m_errorPolicy ) ; declareProperty( "Handlers" , m_handlersTypeNames ) ; declareProperty( "IgnoreCodes" , m_ignore ) ; }
| GslSvc::~GslSvc | ( | ) | [virtual] |
| GslSvc::GslSvc | ( | ) | [private] |
default constructor is private
| GslSvc::GslSvc | ( | const GslSvc & | ) | [private] |
copy constructor is private
| StatusCode GslSvc::finalize | ( | void | ) | [virtual] |
standard service finalization
Reimplemented from Service.
Definition at line 164 of file GslSvc.cpp.
{
MsgStream log(msgSvc(), name());
log << MSG::DEBUG << "==> Finalize" << endmsg;
// deactivate the static accessor to the service
GaudiGSL::setGslSvc( 0 );
// finalize the base class
return Service::finalize() ;
}
| StatusCode GslSvc::handle | ( | const GslError & | error ) | const [virtual] |
handle the GSL error
| err | error |
| error | error |
Implements IGslSvc.
Definition at line 233 of file GslSvc.cpp.
{
StatusCode sc = StatusCode::SUCCESS ;
// code to be ignored?
if( m_ignore.end() != std::find( m_ignore.begin () ,
m_ignore.end () ,
error.code ) ) { return sc ; }
// invoke all handlers
for( Handlers::const_iterator handler = m_handlers.begin() ;
sc.isSuccess() && m_handlers.end() != handler ; ++handler )
{ sc = (*handler)->handle( error ); }
//
return sc ;
}
| IGslSvc::GslErrorHandler GslSvc::handler | ( | ) | const [virtual] |
retrieve the current GSL error handler
Implements IGslSvc.
Definition at line 182 of file GslSvc.cpp.
{
GslErrorHandler hh = gsl_set_error_handler( 0 );
gsl_set_error_handler( hh );
return hh ;
}
| 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.
{
// initialize the base class
StatusCode sc = Service::initialize();
MsgStream log( msgSvc() , name() );
if( sc.isFailure() )
{ log << MSG::ERROR
<< " Error in initialization of base class 'Service'"<< endmsg;
return sc;
}
// activate the static accessor to the service
GaudiGSL::setGslSvc( this );
// set the error handlers
if ( "GSL" == m_errorPolicy ) { /* nothing to do */ }
else if ( "Off" == m_errorPolicy )
{ gsl_set_error_handler_off() ; }
else if ( "Abort" == m_errorPolicy )
{ gsl_set_error_handler ( 0 ) ; }
else if ( "Ignore" == m_errorPolicy )
{ gsl_set_error_handler ( GslErrorHandlers::ignoreTheError ) ; }
else if ( "Exception" == m_errorPolicy )
{ gsl_set_error_handler ( GslErrorHandlers::throwException ) ; }
else if ( "Handle" == m_errorPolicy )
{ gsl_set_error_handler ( GslErrorHandlers::handleTheError ) ; }
else
{ log << MSG::ERROR
<< " Unknown Error policy '" << m_errorPolicy << "'"
<< " Valid policies: "
<< "[ 'GSL' , 'Off' , 'Abort' , 'Ignore' , 'Exception' , 'Handle' ]"
<< endmsg;
return StatusCode::FAILURE ;
}
GslErrorHandler handler = gsl_set_error_handler( 0 );
gsl_set_error_handler( handler );
if( 0 != handler )
{ log << MSG::VERBOSE
<< " GSL Error Handler is '"
<< System::typeinfoName( typeid(*handler) ) << "'"
<< endmsg; }
else { log << MSG::INFO << " Error Handler is NULL" << endmsg ; }
if( !m_handlersTypeNames.empty() )
{
SmartIF<IToolSvc> toolsvc(serviceLocator()->service("ToolSvc"));
if (!toolsvc.isValid()) {
log << MSG::ERROR << " Could not locate Tool Service! " << endmsg;
return StatusCode::FAILURE;
}
for( Names::const_iterator it = m_handlersTypeNames.begin() ;
m_handlersTypeNames.end() != it ; ++it )
{
std::string::const_iterator ipos =
std::find( it->begin() , it->end() , '/');
const std::string::size_type pos = ipos - it->begin() ;
IGslErrorHandler* eh = 0 ;
if( it->end() != ipos )
{ sc = toolsvc->retrieveTool
( std::string( *it , 0 , pos ) ,
std::string( *it , pos + 1, it->length() ), eh , this ) ; }
else
{ sc = toolsvc->retrieveTool
( *it , std::string( *it , pos + 1, it->length() ) ,
eh , this ) ; }
if( sc.isFailure() )
{ log << MSG::ERROR
<< " Could not retrieve tool '" << *it << "'"<< endmsg ;
return sc ; }
if( 0 == eh )
{ log << MSG::ERROR
<< " Could not retrieve tool '" << *it << "'"<< endmsg ;
return StatusCode::FAILURE ; }
m_handlers.push_back( eh );
}
}
//
return StatusCode::SUCCESS;
}
| IGslSvc::GslErrorHandler GslSvc::setHandler | ( | IGslSvc::GslErrorHandler | handler ) | const [virtual] |
set new GSL error handler
| handler | new GSL error handler |
| handler | new GSL error handler |
Implements IGslSvc.
Definition at line 197 of file GslSvc.cpp.
| 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 217 of file GslSvc.cpp.
{
if( GSL_SUCCESS == error ){ return StatusCode::SUCCESS ; }
StatusCode sc( error );
if( sc.isSuccess() ){ return StatusCode::FAILURE ; }
return sc ;
}
friend class SvcFactory< GslSvc > [friend] |
std::string GslSvc::m_errorPolicy [private] |
Handlers GslSvc::m_handlers [private] |
Names GslSvc::m_handlersTypeNames [private] |
std::vector<int> GslSvc::m_ignore [private] |