| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# AlgorithmHistory.cpp

Go to the documentation of this file.

    00001
    00002 //
    00003 // $Id: AlgorithmHistory.cpp,v 1.1 2006/11/09 10:24:05 mato Exp $
    00004 //
    00005 // GaudiHistory/AlgorithmHistory.cpp
    00006 //
    00007 // Contains history information for an Algorithm
    00008 //
    00009 //
    00010 // @author: Charles Leggett
    00011 //
    00013
    00014 #include "GaudiKernel/AlgorithmHistory.h"
    00015 #include "GaudiKernel/JobHistory.h"
    00016 #include "GaudiKernel/Algorithm.h"
    00017 #include <iostream>
    00018 #include <assert.h>
    00019
    00020
    00021 using std::ostream;
    00022 using std::endl;
    00023 using std::type_info;
    00024 using std::vector;
    00025
    00026 //**********************************************************************
    00027 // Member functions.
    00028 //**********************************************************************
    00029
    00030 // Constructor.
    00031
    00032 AlgorithmHistory::AlgorithmHistory(const Algorithm& alg, const JobHistory* job)
    00033 :
    00034   m_algorithm_type(System::typeinfoName(typeid(alg))),
    00035   m_algorithm_version(alg.version()),
    00036   m_algorithm_name(alg.name()),
    00037   m_algorithm( &alg ),
    00038   m_properties(alg.getProperties()),
    00039   m_jobHistory(job)
    00040 {
    00041   assert( alg.subAlgorithms() != 0 );
    00042
    00043   for ( vector<Algorithm*>::const_iterator
    00044         ialg=alg.subAlgorithms()->begin();
    00045         ialg!=alg.subAlgorithms()->end(); ++ ialg ) {
    00046     m_subalgorithm_histories.push_back(new AlgorithmHistory(**ialg, job));
    00047   }
    00048 }
    00049
    00050 //**********************************************************************
    00051
    00052 AlgorithmHistory::AlgorithmHistory(const std::string& algVersion,
    00053                                    const std::string& algName,
    00054                                    const std::string& algType,
    00055                                    const PropertyList& props,
    00056                                    const HistoryList& subHists) :
    00057   m_algorithm_type(algType),   // FIXME type_info???
    00058   m_algorithm_version(algVersion),
    00059   m_algorithm_name(algName),
    00060   m_algorithm(0),
    00061   m_properties(props),
    00062   m_subalgorithm_histories(subHists) {}
    00063
    00064 //**********************************************************************
    00065
    00066 // Destructor.
    00067
    00068 AlgorithmHistory::~AlgorithmHistory() {
    00069   for ( HistoryList::const_iterator
    00070         iphist=m_subalgorithm_histories.begin();
    00071         iphist!=m_subalgorithm_histories.end(); ++iphist ) {
    00072     delete *iphist;
    00073   }
    00074 }
    00075
    00076 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    00077
    00078 const CLID&
    00079 AlgorithmHistory::classID() {
    00080
    00081   static CLID CLID_AlgorithmHistory = 56809101;  //from `clid AlgorithmHistory`
    00082   return CLID_AlgorithmHistory;
    00083
    00084 }
    00085
    00086 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    00087
    00088 void
    00089 AlgorithmHistory::dump(std::ostream& ost, const bool isXML, int ind) const {
    00090
    00091   if (!isXML) {
    00092     ost << "Type: " << algorithm_type() << endl;
    00093     ost << "Name: " << algorithm_name() << endl;
    00094     ost << "Version: " << algorithm_version() << endl;
    00095     // Properties.
    00096     ost << "Properties: [" << endl;;
    00097     for ( AlgorithmHistory::PropertyList::const_iterator
    00098             ipprop=properties().begin();
    00099           ipprop!=properties().end(); ++ipprop ) {
    00100       const Property& prop = **ipprop;
    00101       prop.fillStream(ost);
    00102       ost << endl;
    00103     }
    00104     ost << "]" << endl;
    00105     // Subalgorithms.
    00106     if ( subalgorithm_histories().size() == 0 ) {
    00107       ost << "No subalgorithms.";
    00108     } else {
    00109       ost << "Subalgorithms: {" << endl;
    00110       for ( AlgorithmHistory::HistoryList::const_iterator
    00111               iphist=subalgorithm_histories().begin();
    00112             iphist!=subalgorithm_histories().end(); ++iphist ) {
    00113         if ( iphist==subalgorithm_histories().begin() ) {
    00114           ost << "----------" << endl;
    00115         }
    00116         ost << **iphist << endl;
    00117         ost << "----------" << endl;
    00118       }
    00119       ost << "}";
    00120     }
    00121   } else {
    00122     ind += 2;
    00123     indent(ost,ind);
    00124     ost << "<COMPONENT name=\"" << algorithm_name()
    00125         << "\" class=\"" << convert_string(algorithm_type())
    00126         << "\" version=\"" << algorithm_version()
    00127         << "\">" << std::endl;
    00128
    00129     for ( AlgorithmHistory::PropertyList::const_iterator
    00130             ipprop=properties().begin();
    00131           ipprop!=properties().end(); ++ipprop ) {
    00132       const Property& prop = **ipprop;
    00133       indent(ost,ind+2);
    00134       ost << "<PROPERTY name=\"" << prop.name()
    00135           << "\" value=\"" << convert_string(prop.toString())
    00136           << "\" documentation=\"" << convert_string(prop.documentation())
    00137           << "\">" << std::endl;
    00138     }
    00139
    00140     // Subalgs
    00141     if ( subalgorithm_histories().size() != 0 ) {
    00142       for ( AlgorithmHistory::HistoryList::const_iterator
    00143               iphist=subalgorithm_histories().begin();
    00144             iphist!=subalgorithm_histories().end(); ++iphist ) {
    00145         (*iphist)->dump(ost,isXML,ind+2);
    00146       }
    00147
    00148     }
    00149
    00150     indent(ost,ind);
    00151     ost << "</COMPONENT>" << std::endl;
    00152
    00153
    00154
    00155
    00156
    00157   }
    00158 }
    00159
    00160
    00161 //**********************************************************************
    00162 // Free functions.
    00163 //**********************************************************************
    00164
    00165 // Output stream.
    00166
    00167 ostream& operator<<(ostream& lhs, const AlgorithmHistory& rhs) {
    00168
    00169   rhs.dump(lhs,false);
    00170
    00171   return lhs;
    00172 }
    00173
    00174 //**********************************************************************

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines