Ignore:
Timestamp:
03/31/03 10:37:56 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1794 r1880  
    4040#include <fstream.h>     // ofstream, AsciiWrite
    4141
    42 #include <TROOT.h>       // TROOT::Identlevel
     42#include <TEnv.h>        // Env::Lookup
    4343#include <TClass.h>      // IsA
    4444#include <TObjArray.h>   // TObjArray
     
    5454#include "MEvtLoop.h"    // gListOfPrimitives
    5555#else
    56 TList *gListOfPrimitives;
     56TList *gListOfPrimitives; // forard declaration in MParContainer.h
    5757#endif
    5858
     
    122122//
    123123void MParContainer::Copy(TObject &obj)
     124#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
     125const
     126#endif
    124127{
    125128    MParContainer &cont = (MParContainer&)obj;
     
    449452    return (MParContainer*)IsA()->New();
    450453}
     454
     455// --------------------------------------------------------------------------
     456//
     457// Read the contents/setup of a parameter container/task from a TEnv
     458// instance (steering card/setup file).
     459// The key to search for in the file should be of the syntax:
     460//    prefix.vname
     461// While vname is a name which is specific for a single setup date
     462// (variable) of this container and prefix is something like:
     463//    evtloopname.name
     464// While name is the name of the containers/tasks in the parlist/tasklist
     465//
     466// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     467//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     468//
     469// If this cannot be found the next step is to search for
     470//      MImgCleanStd.CleaningLevel1:  3.0
     471// And if this doesn't exist, too, we should search for:
     472//      CleaningLevel1:  3.0
     473//
     474// Warning: The programmer is responsible for the names to be unique in
     475//          all Mars classes.
     476//
     477Bool_t MParContainer::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     478{
     479    if (!IsEnvDefined(env, prefix, "", print))
     480        return kFALSE;
     481
     482    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but no " << IsA()->GetName() << "::ReadEnv." << endl;
     483    return kTRUE;
     484}
     485
     486// --------------------------------------------------------------------------
     487//
     488// Write the contents/setup of a parameter container/task to a TEnv
     489// instance (steering card/setup file).
     490// The key to search for in the file should be of the syntax:
     491//    prefix.vname
     492// While vname is a name which is specific for a single setup date
     493// (variable) of this container and prefix is something like:
     494//    evtloopname.name
     495// While name is the name of the containers/tasks in the parlist/tasklist
     496//
     497// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     498//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     499//
     500// If this cannot be found the next step is to search for
     501//      MImgCleanStd.CleaningLevel1:  3.0
     502// And if this doesn't exist, too, we should search for:
     503//      CleaningLevel1:  3.0
     504//
     505// Warning: The programmer is responsible for the names to be unique in
     506//          all Mars classes.
     507//
     508Bool_t MParContainer::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
     509{
     510    if (!IsEnvDefined(env, prefix, "", print))
     511        return kFALSE;
     512
     513    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but " << IsA()->GetName() << "::WriteEnv not overloaded." << endl;
     514    return kTRUE;
     515}
     516
     517Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const
     518{
     519    if (!postfix.IsNull())
     520        postfix.Insert(0, ".");
     521
     522    return IsEnvDefined(env, prefix+fName+postfix, print);
     523}
     524
     525Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString name, Bool_t print) const
     526{
     527    if (print)
     528        *fLog << all << GetDescriptor() << " - " << name << "... " << flush;
     529
     530    if (!((TEnv&)env).Defined(name))
     531    {
     532        if (print)
     533            *fLog << "not found." << endl;
     534        return kFALSE;
     535    }
     536
     537    if (print)
     538        *fLog << "found." << endl;
     539
     540    return kTRUE;
     541}
     542
     543Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const
     544{
     545    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
     546}
     547
     548Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const
     549{
     550    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
     551}
     552
     553const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const
     554{
     555    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
     556}
Note: See TracChangeset for help on using the changeset viewer.