| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# 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 const CLID& AlgorithmHistory::classID() {
    00077
    00078   static CLID CLID_AlgorithmHistory = 56809101;  //from `clid AlgorithmHistory`
    00079   return CLID_AlgorithmHistory;
    00080
    00081 }
    00082
    00083 //**********************************************************************
    00084 // Free functions.
    00085 //**********************************************************************
    00086
    00087 // Output stream.
    00088
    00089 ostream& operator<<(ostream& lhs, const AlgorithmHistory& rhs) {
    00090   lhs << "Type: " << rhs.algorithm_type() << endl;
    00091   lhs << "Name: " << rhs.algorithm_name() << endl;
    00092   lhs << "Version: " << rhs.algorithm_version() << endl;
    00093   // Properties.
    00094   lhs << "Properties: [" << endl;;
    00095   for ( AlgorithmHistory::PropertyList::const_iterator
    00096         ipprop=rhs.properties().begin();
    00097         ipprop!=rhs.properties().end(); ++ipprop ) {
    00098     const Property& prop = **ipprop;
    00099     prop.fillStream(lhs);
    00100     lhs << endl;
    00101     //    lhs << "  " << prop.type() << " " << prop.name() << endl;
    00102 //      << " == "
    00103 //              << prop.fillStream(lhs) << endl;
    00104   }
    00105   lhs << "]" << endl;
    00106   // Subalgorithms.
    00107   if ( rhs.subalgorithm_histories().size() == 0 ) {
    00108     lhs << "No subalgorithms.";
    00109   } else {
    00110     lhs << "Subalgorithms: {" << endl;
    00111     for ( AlgorithmHistory::HistoryList::const_iterator
    00112           iphist=rhs.subalgorithm_histories().begin();
    00113           iphist!=rhs.subalgorithm_histories().end(); ++iphist ) {
    00114       if ( iphist==rhs.subalgorithm_histories().begin() ) {
    00115         lhs << "----------" << endl;
    00116       }
    00117       lhs << **iphist << endl;
    00118       lhs << "----------" << endl;
    00119     }
    00120     lhs << "}";
    00121   }
    00122   return lhs;
    00123 }
    00124
    00125 //**********************************************************************