| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ConcreteAlgorithm.cc

Go to the documentation of this file.
00001 #include "ConcreteAlgorithm.h"
00002 
00003 using namespace std;
00004 
00005 ConcreteAlgorithm::ConcreteAlgorithm(const string& name, ISvcLocator* svcloc)
00006     : Algorithm(name, svcloc)
00007     , m_log(msgSvc(),name)
00008     , m_privTool("ConcreteTool",this)
00009     , m_pubTool("ConcreteTool")
00010     , m_listOfPrivateTools(this)
00011     , m_listOfPublicTools()
00012 {
00013     declareProperty( "PrivateTool",  m_privTool, "A private tools" );
00014     declareProperty( "PublicTool",   m_pubTool,  "A public tools" );
00015     declareProperty( "PrivateToolList",  m_listOfPrivateTools, "list of private helper tools" );
00016     declareProperty( "PublicToolList",   m_listOfPublicTools,  "list of public helper tools" );
00017     declareProperty( "StringList", m_strings, "list of strings");
00018     declareProperty( "Double", m_double=3.141592, "a double");
00019 }
00020 ConcreteAlgorithm::~ConcreteAlgorithm()
00021 {
00022 }
00023 
00024 StatusCode ConcreteAlgorithm::initialize()
00025 {
00026     m_log << MSG::INFO << "initialize()" << endreq;
00027     m_log.setLevel( outputLevel() );
00028    
00029     m_log << "Retrieving public tool " << m_pubTool.typeAndName() << endreq;
00030     if ( m_pubTool.retrieve().isFailure() ) {
00031         m_log << MSG::ERROR << "Failed to retreive " << m_pubTool << endreq;
00032         return StatusCode::FAILURE;
00033     } else {
00034         m_log << MSG::INFO << "Retrieved " << m_pubTool << endreq;
00035     }
00036 
00037     m_log << "Retrieving private tool " << m_privTool.typeAndName() << endreq;
00038     if ( m_privTool.retrieve().isFailure() ) {
00039         m_log << MSG::ERROR << "Failed to retreive " << m_privTool << endreq;
00040         return StatusCode::FAILURE;
00041     } else {
00042         m_log << MSG::INFO << "Retrieved " << m_privTool << endreq;
00043     }
00044 
00045 
00046     // public
00047     m_log << MSG::INFO << "Retrieving public tool list" << endreq;
00048     if ( m_listOfPublicTools.retrieve().isFailure() ) {
00049         m_log << MSG::ERROR << "Failed to retreive " << m_listOfPublicTools << endreq;
00050         return StatusCode::FAILURE;
00051     } else {
00052         m_log << MSG::INFO << "Retrieved " << m_listOfPublicTools << endreq;
00053     }
00054 
00055     // private
00056     m_log << MSG::INFO << "Retrieving private tool list" << endreq;
00057     if ( m_listOfPrivateTools.retrieve().isFailure() ) {
00058         m_log << MSG::ERROR << "Failed to retreive " << m_listOfPrivateTools << endreq;
00059         return StatusCode::FAILURE;
00060     } else {
00061         m_log << MSG::INFO << "Retrieved " << m_listOfPrivateTools << endreq;
00062     }
00063 
00064     return StatusCode::SUCCESS;
00065 }
00066 StatusCode ConcreteAlgorithm::reinitialize()
00067 {
00068     m_log << MSG::INFO << "reinitialize()" << endreq;
00069     return this->initialize();
00070 }
00071 StatusCode ConcreteAlgorithm::beginRun()
00072 {
00073     m_log << MSG::INFO << "beginRun()" << endreq;
00074     return StatusCode::SUCCESS;
00075 }
00076 StatusCode ConcreteAlgorithm::execute()
00077 {
00078     m_log << MSG::INFO << "exectue()" << endreq;
00079 
00080     static int count = 0;
00081     ++count;
00082     double value = -5 + count;
00083 
00084     // make list of private tools do their work
00085     ToolHandleArray<IVirtualTool>::iterator itPriv = m_listOfPrivateTools.begin(),
00086         itPrivEnd = m_listOfPrivateTools.end();
00087     for (  ; itPriv != itPrivEnd; ++itPriv ) {
00088         StatusCode sc = (*itPriv)->doSomething(value);
00089         if ( sc.isFailure() ) {
00090             m_log << MSG::ERROR << "tool " << (*itPriv).typeAndName() 
00091                   << " failed it's task ... stop!" << endreq;
00092             return sc;
00093         }
00094         m_log << MSG::INFO << "Public: value = " << value << endreq;
00095     }
00096 
00097     // make list of tools do their work
00098     ToolHandleArray< IVirtualTool >::iterator itPub = m_listOfPublicTools.begin(),
00099         itPubEnd = m_listOfPublicTools.end();
00100     for (  ; itPub != itPubEnd; ++itPub ) {
00101         StatusCode sc = (*itPub)->doSomething(value);
00102         if ( sc.isFailure() ) {
00103             m_log << MSG::ERROR << "tool " << (*itPub).typeAndName() << 
00104                 " failed it's task ... stop!" << endreq;
00105             return sc;
00106         }
00107         m_log << MSG::INFO << "Private: value = " << value << endreq;
00108     }
00109     return StatusCode::SUCCESS;
00110 }
00111 StatusCode ConcreteAlgorithm::endRun()
00112 {
00113     m_log << MSG::INFO << "endRun()" << endreq;
00114     return StatusCode::SUCCESS;
00115 }
00116 StatusCode ConcreteAlgorithm::finalize()
00117 {
00118     m_log << MSG::INFO << "finalize()" << endreq;
00119     return StatusCode::SUCCESS;
00120 }
00121 
00122 StatusCode ConcreteAlgorithm::setProperty(const Property& p)
00123 {
00124     string name = p.name();
00125 
00126     m_log << MSG::INFO << "ConcreateAlgorithm::setProperty("<<name<<")" << endreq;
00127     if (dynamic_cast<const GaudiHandleProperty*>(&p)) {
00128         m_log << "Got a GaudiHandleProperty" << endreq;
00129     }
00130     if (dynamic_cast<const GaudiHandleArrayProperty*>(&p)) {
00131         m_log << "Got a GaudiHandleArrayProperty" << endreq;
00132         const GaudiHandleArrayProperty& ghap = dynamic_cast<const GaudiHandleArrayProperty&>(p);
00133         const vector<string> tan = ghap.value().typesAndNames();
00134         for (size_t ind=0; ind<tan.size(); ++ind) {
00135             m_log << "\n" << ind << ": " << tan[ind];
00136         }
00137         m_log << endreq;
00138     }
00139     if (dynamic_cast<const PropertyWithValue<GaudiHandleArrayBase>*>(&p)) {
00140         m_log << "Got a PropertyWithValue<GaudiHandleArrayBase>" << endreq;
00141     }
00142     // This is what the tool lists are coming in as!
00143     if (dynamic_cast<const SimpleProperty<string>*>(&p)) {
00144         m_log << "Got a SimpleProperty<string>" << endreq;
00145     }
00146 
00147     m_log << MSG::INFO << "Property::toString(): " << p.toString() << endreq;
00148 
00149     m_log << MSG::INFO << "Now calling Algorithm::setProperty()" << endreq;
00150     return Algorithm::setProperty(p);
00151 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:09:35 2011 for ConfigurableExample by doxygen 1.4.7