Ignore:
Timestamp:
03/31/03 10:37:56 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
8 edited

Legend:

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

    r1850 r1880  
    103103// default constructor - emty
    104104//
    105 MEvtLoop::MEvtLoop() : fParList(NULL), fProgress(NULL)
    106 {
    107     fName = "Evtloop";
     105MEvtLoop::MEvtLoop(const char *name) : fParList(NULL), fProgress(NULL)
     106{
     107    fName = name;
    108108}
    109109
     
    444444// gui elements to a macro-file.
    445445//
    446 
    447446void MEvtLoop::StreamPrimitive(ofstream &out) const
    448447{
    449     out << "   MEvtLoop " << GetUniqueName() << ";" << endl;
    450 }
    451 
     448    out << "   MEvtLoop " << GetUniqueName();
     449    if (fName!="Evtloop")
     450        out << "(\"" << fName << "\")";
     451    out << ";" << endl;
     452}
     453
     454// --------------------------------------------------------------------------
     455//
     456//
    452457void MEvtLoop::SavePrimitive(ofstream &out, Option_t *opt)
    453458{
     
    666671    return n;
    667672}
     673
     674// --------------------------------------------------------------------------
     675//
     676// Read the contents/setup of a parameter container/task from a TEnv
     677// instance (steering card/setup file).
     678// The key to search for in the file should be of the syntax:
     679//    prefix.vname
     680// While vname is a name which is specific for a single setup date
     681// (variable) of this container and prefix is something like:
     682//    evtloopname.name
     683// While name is the name of the containers/tasks in the parlist/tasklist
     684//
     685// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     686//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     687//
     688// If this cannot be found the next step is to search for
     689//      MImgCleanStd.CleaningLevel1:  3.0
     690// And if this doesn't exist, too, we should search for:
     691//      CleaningLevel1:  3.0
     692//
     693// Warning: The programmer is responsible for the names to be unique in
     694//          all Mars classes.
     695//
     696Bool_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     697{
     698    if (!prefix.IsNull())
     699        *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
     700
     701    *fLog << "1: " << "'" << prefix << "'" << (int)print << endl;
     702
     703    prefix = fName;
     704    prefix += ".";
     705
     706    *fLog << inf << "Reading resources for " << prefix /*TEnv::fRcName << " from " << env.GetRcName()*/ << endl;
     707
     708    if (fParList->ReadEnv(env, prefix, print)==kERROR)
     709    {
     710        *fLog << err << "ERROR - Reading Environment file." << endl;
     711        return kFALSE;
     712    }
     713
     714    return kTRUE;
     715}
     716
     717// --------------------------------------------------------------------------
     718//
     719// Write the contents/setup of a parameter container/task to a TEnv
     720// instance (steering card/setup file).
     721// The key to search for in the file should be of the syntax:
     722//    prefix.vname
     723// While vname is a name which is specific for a single setup date
     724// (variable) of this container and prefix is something like:
     725//    evtloopname.name
     726// While name is the name of the containers/tasks in the parlist/tasklist
     727//
     728// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     729//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     730//
     731// If this cannot be found the next step is to search for
     732//      MImgCleanStd.CleaningLevel1:  3.0
     733// And if this doesn't exist, too, we should search for:
     734//      CleaningLevel1:  3.0
     735//
     736// Warning: The programmer is responsible for the names to be unique in
     737//          all Mars classes.
     738//
     739Bool_t MEvtLoop::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
     740{
     741    if (!prefix.IsNull())
     742        *fLog << warn << "WARNING - Second argument in MEvtLoop::WriteEnv has no meaning... ignored." << endl;
     743
     744    prefix = fName;
     745    prefix += ".";
     746
     747    *fLog << inf << "Writing resources: " << prefix /*TEnv::fRcName << " to " << env.GetRcName()*/ << endl;
     748
     749    if (fParList->WriteEnv(env, prefix, print)!=kTRUE)
     750    {
     751        *fLog << err << "ERROR - Writing Environment file." << endl;
     752        return kFALSE;
     753    }
     754
     755    return kTRUE;
     756}
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r1657 r1880  
    3737
    3838public:
    39     MEvtLoop();
     39    MEvtLoop(const char *name="Evtloop");
    4040    virtual ~MEvtLoop();
    4141
     
    6666    void Print(Option_t *opt="") const;
    6767
     68    Bool_t ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
     69    Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
     70
    6871    ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
    6972};
  • 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}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1879 r1880  
    2323class ifstream;
    2424
     25class TEnv;
    2526class TDataMember;
    2627class TMethodCall;
     
    5657    virtual TObject    *Clone(const char *newname="") const;
    5758    virtual Int_t       Compare(const TObject *obj) const;
    58     virtual void        Copy(TObject &named);
     59    virtual void        Copy(TObject &named)
     60#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
     61const
     62#endif
     63        ;
    5964    virtual void        FillBuffer(char *&buffer);
    6065
     
    95100    virtual void SetNames(TObjArray &arr);
    96101
     102    virtual Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     103    virtual Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
     104
     105    Bool_t ReadEnv(const TEnv &env, Bool_t print=kFALSE) { return ReadEnv(env, "", print); }
     106    Bool_t WriteEnv(TEnv &env, Bool_t print=kFALSE) const { return WriteEnv(env, "", print); }
     107
     108    Bool_t IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const;
     109    Bool_t IsEnvDefined(const TEnv &env, TString name, Bool_t print) const;
     110
     111    Int_t       GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const;
     112    Double_t    GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const;
     113    const char *GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const;
     114
    97115    ClassDef(MParContainer, 0)  //The basis for all parameter containers
    98116};
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r1528 r1880  
    768768}
    769769
     770// --------------------------------------------------------------------------
     771//
     772// Read the contents/setup of a parameter container/task from a TEnv
     773// instance (steering card/setup file).
     774// The key to search for in the file should be of the syntax:
     775//    prefix.vname
     776// While vname is a name which is specific for a single setup date
     777// (variable) of this container and prefix is something like:
     778//    evtloopname.name
     779// While name is the name of the containers/tasks in the parlist/tasklist
     780//
     781// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     782//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     783//
     784// If this cannot be found the next step is to search for
     785//      MImgCleanStd.CleaningLevel1:  3.0
     786// And if this doesn't exist, too, we search for:
     787//      CleaningLevel1:  3.0
     788//
     789// Warning: The programmer is responsible for the names to be unique in
     790//          all Mars classes.
     791//
     792Bool_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     793{
     794    MParContainer *cont = NULL;
     795
     796    TIter Next(fContainer);
     797    while ((cont=(MParContainer*)Next()))
     798        if (cont->ReadEnv(env, print)==kERROR)
     799            return kERROR;
     800
     801    Next.Reset();
     802    while ((cont=(MParContainer*)Next()))
     803        if (cont->ReadEnv(env, prefix, print)==kERROR)
     804            return kERROR;
     805
     806    return kTRUE;
     807}
     808
     809// --------------------------------------------------------------------------
     810//
     811// Write the contents/setup of a parameter container/task to a TEnv
     812// instance (steering card/setup file).
     813// The key to search for in the file should be of the syntax:
     814//    prefix.vname
     815// While vname is a name which is specific for a single setup date
     816// (variable) of this container and prefix is something like:
     817//    evtloopname.name
     818// While name is the name of the containers/tasks in the parlist/tasklist
     819//
     820// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     821//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     822//
     823// If this cannot be found the next step is to search for
     824//      MImgCleanStd.CleaningLevel1:  3.0
     825// And if this doesn't exist, too, we search for:
     826//      CleaningLevel1:  3.0
     827//
     828// Warning: The programmer is responsible for the names to be unique in
     829//          all Mars classes.
     830//
     831Bool_t MParList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
     832{
     833    MParContainer *cont = NULL;
     834
     835    TIter Next(fContainer);
     836    while ((cont=(MParContainer*)Next()))
     837        if (!cont->WriteEnv(env, prefix, print))
     838            return kFALSE;
     839    return kTRUE;
     840}
  • trunk/MagicSoft/Mars/mbase/MParList.h

    r1879 r1880  
    9090    void SavePrimitive(ofstream &out, Option_t *o="");
    9191
     92    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     93    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
     94
    9295    ClassDef(MParList, 1) // list of parameter containers (MParContainer)
    9396};
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1666 r1880  
    643643}
    644644
     645// --------------------------------------------------------------------------
     646//
     647// Read the contents/setup of a parameter container/task from a TEnv
     648// instance (steering card/setup file).
     649// The key to search for in the file should be of the syntax:
     650//    prefix.vname
     651// While vname is a name which is specific for a single setup date
     652// (variable) of this container and prefix is something like:
     653//    evtloopname.name
     654// While name is the name of the containers/tasks in the parlist/tasklist
     655//
     656// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     657//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     658//
     659// If this cannot be found the next step is to search for
     660//      MImgCleanStd.CleaningLevel1:  3.0
     661// And if this doesn't exist, too, we should search for:
     662//      CleaningLevel1:  3.0
     663//
     664// Warning: The programmer is responsible for the names to be unique in
     665//          all Mars classes.
     666//
     667Bool_t MTaskList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     668{
     669    MParContainer *cont = NULL;
     670
     671    TIter Next(fTasks);
     672    while ((cont=(MParContainer*)Next()))
     673        if (cont->ReadEnv(env, print)==kERROR)
     674            return kERROR;
     675
     676    Next.Reset();
     677    while ((cont=(MParContainer*)Next()))
     678        if (cont->ReadEnv(env, prefix, print)==kERROR)
     679            return kERROR;
     680
     681    return kTRUE;
     682}
     683
     684// --------------------------------------------------------------------------
     685//
     686// Write the contents/setup of a parameter container/task to a TEnv
     687// instance (steering card/setup file).
     688// The key to search for in the file should be of the syntax:
     689//    prefix.vname
     690// While vname is a name which is specific for a single setup date
     691// (variable) of this container and prefix is something like:
     692//    evtloopname.name
     693// While name is the name of the containers/tasks in the parlist/tasklist
     694//
     695// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
     696//      Job4.MImgCleanStd.CleaningLevel2:  2.5
     697//
     698// If this cannot be found the next step is to search for
     699//      MImgCleanStd.CleaningLevel1:  3.0
     700// And if this doesn't exist, too, we should search for:
     701//      CleaningLevel1:  3.0
     702//
     703// Warning: The programmer is responsible for the names to be unique in
     704//          all Mars classes.
     705//
     706Bool_t MTaskList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
     707{
     708    MParContainer *cont = NULL;
     709
     710    TIter Next(fTasks);
     711    while ((cont=(MParContainer*)Next()))
     712        if (!cont->WriteEnv(env, prefix, print))
     713            return kFALSE;
     714    return kTRUE;
     715}
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r1661 r1880  
    6767    void SetNames(TObjArray &arr);
    6868
     69    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     70    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
     71
    6972    ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop
    7073};
Note: See TracChangeset for help on using the changeset viewer.