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

In This Package:

Public Member Functions | Static Public Member Functions | Private Attributes
ToolUsingTool Class Reference

#include <ToolUsingTool.h>

Inheritance diagram for ToolUsingTool:
Inheritance graph
[legend]
Collaboration diagram for ToolUsingTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ToolUsingTool (const std::string &, const std::string &, const IInterface *)
StatusCode queryInterface (const InterfaceID &riid, void **ppvIf)
StatusCode initialize ()
StatusCode finalize ()
virtual StatusCode doSomething (double &result)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Attributes

MsgStream m_log
double m_factor
ToolHandle< IVirtualToolm_pubTool
ToolHandle< IVirtualToolm_privTool
ToolHandleArray< IVirtualToolm_toolArray

Detailed Description

Definition at line 15 of file ToolUsingTool.h.


Constructor & Destructor Documentation

ToolUsingTool::ToolUsingTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 6 of file ToolUsingTool.cc.

   : AlgTool( type, name, parent ), m_log( msgSvc(), name ),
     m_pubTool( "ConcreteTool/PublicConcreteTool" ),         // no parent, making it public
     m_privTool( "ConcreteTool", this ), m_toolArray( this ) // adding 'this' makes it private
{

// declare any properties here

   declareProperty( "Factor", m_factor = 1., "multiplicative factor to perform task" );

   declareProperty( "TheToolPubTool",   m_pubTool,   "global helper to offload tasks to" );
   declareProperty( "TheToolTool",      m_privTool,  "helper to offload some tasks to" );
   declareProperty( "TheToolToolArray", m_toolArray, "list of helpers to offload some tasks to" );
   
   // set default toolArray
   m_toolArray.push_back( "ConcreteTool/CxxDefaultTool" );
}

Member Function Documentation

StatusCode ToolUsingTool::queryInterface ( const InterfaceID &  riid,
void **  ppvIf 
)

Definition at line 27 of file ToolUsingTool.cc.

{
   if ( riid == IVirtualTool::interfaceID() )  {
      *ppvIf = (IVirtualTool*)this;
      addRef();
      return StatusCode::SUCCESS;
   }

   return AlgTool::queryInterface( riid, ppvIf );
}
StatusCode ToolUsingTool::initialize ( )

Definition at line 39 of file ToolUsingTool.cc.

{

// perform necessary one-off initialization

// needed if OutputLevel property was modified
   m_log.setLevel( outputLevel() );

// verify that our tool handle is pointing to an accessible tool
   if ( m_pubTool.retrieve().isFailure() ) {
      m_log << MSG::FATAL << "Failed to retrieve " << m_pubTool << endreq;
      return StatusCode::FAILURE;
   } else {
      m_log << MSG::INFO << "Retrieved " << m_pubTool << endreq;
   }

   if ( m_privTool.retrieve().isFailure() ) {
      m_log << MSG::FATAL << "Failed to retrieve " << m_privTool << endreq;
      return StatusCode::FAILURE;
   } else {
      m_log << MSG::INFO << "Retrieved " << m_privTool << endreq;
   }
   
   if ( m_toolArray.retrieve().isFailure() ) {
     m_log << MSG::ERROR << "Failed to retreive " << m_toolArray << endreq;
      return StatusCode::FAILURE;
   } else {
     m_log << MSG::INFO << "Retrieved " << m_toolArray << endreq;
   }

   return StatusCode::SUCCESS;
}
StatusCode ToolUsingTool::finalize ( )

Definition at line 73 of file ToolUsingTool.cc.

{

// perform work done at shutdown

   return StatusCode::SUCCESS;
}
StatusCode ToolUsingTool::doSomething ( double &  result) [virtual]

Implements IVirtualTool.

Definition at line 82 of file ToolUsingTool.cc.

{

// do what needs to be done
   m_log << MSG::INFO << "performing task using tool (factor: " << m_factor << ") ..." << endreq;

   StatusCode sc = m_pubTool->doSomething( result );
   if ( sc.isFailure() ) {
      m_log << MSG::ERROR << "the global, public tool failed it's task ... stop!" << endreq;
      return sc;
   }

   sc = m_privTool->doSomething( result );
   if ( sc.isFailure() ) {
      m_log << MSG::ERROR << "my tool failed it's task ... stop!" << endreq;
      return sc;
   }

   m_log << MSG::INFO << "... task using tool is done";
   if ( m_log.level() <= MSG::DEBUG ) { m_log << ", result: " << result; }
   m_log << endreq;

// make list of tools do their work
   double newvalue = 12345.0;
   ToolHandleArray< IVirtualTool >::iterator itPriv = m_toolArray.begin(),
     itPrivEnd = m_toolArray.end();
   for (  ; itPriv != itPrivEnd; ++itPriv ) {
     sc = (*itPriv)->doSomething( newvalue );
     if ( sc.isFailure() ) {
       m_log << MSG::ERROR << "tool " << (*itPriv).typeAndName() << " failed it's task ... stop!" << endreq;
       return sc;
     }
   }
 
   return StatusCode::SUCCESS;
}
static const InterfaceID& ToolUsingTool::interfaceID ( ) [inline, static]

Reimplemented from IVirtualTool.

Definition at line 31 of file ToolUsingTool.h.


Member Data Documentation

MsgStream ToolUsingTool::m_log [private]

Definition at line 34 of file ToolUsingTool.h.

double ToolUsingTool::m_factor [private]

Definition at line 37 of file ToolUsingTool.h.

ToolHandle< IVirtualTool > ToolUsingTool::m_pubTool [private]

Definition at line 39 of file ToolUsingTool.h.

ToolHandle< IVirtualTool > ToolUsingTool::m_privTool [private]

Definition at line 40 of file ToolUsingTool.h.

ToolHandleArray< IVirtualTool > ToolUsingTool::m_toolArray [private]

Definition at line 41 of file ToolUsingTool.h.


The documentation for this class was generated from the following files:
| 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