/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ToolUsingTool.cc
Go to the documentation of this file.
00001 #include "ToolUsingTool.h"
00002 
00003 
00005 
00006 ToolUsingTool::ToolUsingTool( const std::string& type, const std::string& name,
00007                       const IInterface* parent ) 
00008    : AlgTool( type, name, parent ), m_log( msgSvc(), name ),
00009      m_pubTool( "ConcreteTool/PublicConcreteTool" ),         // no parent, making it public
00010      m_privTool( "ConcreteTool", this ), m_toolArray( this ) // adding 'this' makes it private
00011 {
00012 
00013 // declare any properties here
00014 
00015    declareProperty( "Factor", m_factor = 1., "multiplicative factor to perform task" );
00016 
00017    declareProperty( "TheToolPubTool",   m_pubTool,   "global helper to offload tasks to" );
00018    declareProperty( "TheToolTool",      m_privTool,  "helper to offload some tasks to" );
00019    declareProperty( "TheToolToolArray", m_toolArray, "list of helpers to offload some tasks to" );
00020    
00021    // set default toolArray
00022    m_toolArray.push_back( "ConcreteTool/CxxDefaultTool" );
00023 }
00024 
00025 
00026 //___________________________________________________________________________
00027 StatusCode ToolUsingTool::queryInterface( const InterfaceID& riid, void** ppvIf )
00028 {
00029    if ( riid == IVirtualTool::interfaceID() )  {
00030       *ppvIf = (IVirtualTool*)this;
00031       addRef();
00032       return StatusCode::SUCCESS;
00033    }
00034 
00035    return AlgTool::queryInterface( riid, ppvIf );
00036 }
00037 
00038 //___________________________________________________________________________
00039 StatusCode ToolUsingTool::initialize()
00040 {
00041 
00042 // perform necessary one-off initialization
00043 
00044 // needed if OutputLevel property was modified
00045    m_log.setLevel( outputLevel() );
00046 
00047 // verify that our tool handle is pointing to an accessible tool
00048    if ( m_pubTool.retrieve().isFailure() ) {
00049       m_log << MSG::FATAL << "Failed to retrieve " << m_pubTool << endreq;
00050       return StatusCode::FAILURE;
00051    } else {
00052       m_log << MSG::INFO << "Retrieved " << m_pubTool << endreq;
00053    }
00054 
00055    if ( m_privTool.retrieve().isFailure() ) {
00056       m_log << MSG::FATAL << "Failed to retrieve " << m_privTool << endreq;
00057       return StatusCode::FAILURE;
00058    } else {
00059       m_log << MSG::INFO << "Retrieved " << m_privTool << endreq;
00060    }
00061    
00062    if ( m_toolArray.retrieve().isFailure() ) {
00063      m_log << MSG::ERROR << "Failed to retreive " << m_toolArray << endreq;
00064       return StatusCode::FAILURE;
00065    } else {
00066      m_log << MSG::INFO << "Retrieved " << m_toolArray << endreq;
00067    }
00068 
00069    return StatusCode::SUCCESS;
00070 }
00071 
00072 //___________________________________________________________________________
00073 StatusCode ToolUsingTool::finalize()
00074 {
00075 
00076 // perform work done at shutdown
00077 
00078    return StatusCode::SUCCESS;
00079 }
00080 
00081 //___________________________________________________________________________
00082 StatusCode ToolUsingTool::doSomething( double& result )
00083 {
00084 
00085 // do what needs to be done
00086    m_log << MSG::INFO << "performing task using tool (factor: " << m_factor << ") ..." << endreq;
00087 
00088    StatusCode sc = m_pubTool->doSomething( result );
00089    if ( sc.isFailure() ) {
00090       m_log << MSG::ERROR << "the global, public tool failed it's task ... stop!" << endreq;
00091       return sc;
00092    }
00093 
00094    sc = m_privTool->doSomething( result );
00095    if ( sc.isFailure() ) {
00096       m_log << MSG::ERROR << "my tool failed it's task ... stop!" << endreq;
00097       return sc;
00098    }
00099 
00100    m_log << MSG::INFO << "... task using tool is done";
00101    if ( m_log.level() <= MSG::DEBUG ) { m_log << ", result: " << result; }
00102    m_log << endreq;
00103 
00104 // make list of tools do their work
00105    double newvalue = 12345.0;
00106    ToolHandleArray< IVirtualTool >::iterator itPriv = m_toolArray.begin(),
00107      itPrivEnd = m_toolArray.end();
00108    for (  ; itPriv != itPrivEnd; ++itPriv ) {
00109      sc = (*itPriv)->doSomething( newvalue );
00110      if ( sc.isFailure() ) {
00111        m_log << MSG::ERROR << "tool " << (*itPriv).typeAndName() << " failed it's task ... stop!" << endreq;
00112        return sc;
00113      }
00114    }
00115  
00116    return StatusCode::SUCCESS;
00117 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:53:50 for ConfigurableExample by doxygen 1.7.4