Ignore:
Timestamp:
08/25/04 17:30:31 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
5 edited

Legend:

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

    r4722 r4732  
    933933//      CleaningLevel1:  3.0
    934934//
     935//
     936// With the argument prefix you can overwrite the name of the MEvtLoop object
     937// as prefix - use with extreme care! The prifix argument must not end with
     938// a dot!
     939//
     940//
    935941// Warning: The programmer is responsible for the names to be unique in
    936942//          all Mars classes.
     
    938944Int_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    939945{
    940     if (!prefix.IsNull())
    941         *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
    942 
    943     prefix = fName;
     946//    if (!prefix.IsNull())
     947//        *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
     948
     949    if (prefix.IsNull())
     950        prefix = fName;
    944951    prefix += ".";
    945952
  • trunk/MagicSoft/Mars/mbase/MLog.cc

    r4722 r4732  
    107107#include <TGTextView.h>
    108108
    109 #include "MLogPlugin.h"
     109#include "MArgs.h"
    110110#include "MParContainer.h"
    111 #include "MArgs.h"
     111
     112#include "MLogHtml.h"
    112113
    113114ClassImp(MLog);
     
    520521    *this << "   -v#                       Verbosity level # [default=2]" << endl;
    521522    *this << "   -a, --no-colors           Do not use Ansii color codes" << endl;
     523    *this << "   --log[=file]              Write log-out to ascii-file [default: prgname.log]" << endl;
     524    *this << "   --html[=file]             Write log-out to html-file [default: prgname.html]" << endl;
    522525    *this << "   --debug[=n]               Enable root debugging [default: gDebug=1]" << endl;
     526    *this << "   --null                    Null output (supresses all output)" << endl;
    523527}
    524528
     
    527531// Setup MLog and global debug output from command line arguments.
    528532//
    529 //    gLog << "     -v#                              Verbosity level # [default=2]" << endl;
    530 //    gLog << "     -a, --no-colors                  Do not use Ansii color codes" << endl;
    531 //    gLog << "     --debug[=n]                      Enable root debugging (Default: gDebug=1)" << endl;
    532 //
    533533void MLog::Setup(MArgs &arg)
    534534{
    535     if (arg.HasOnlyAndRemove("--no-colors") || arg.HasOnlyAndRemove("-a"))
    536         SetNoColors();
    537 
    538     SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
    539 
     535    // FXIME: This is not really at a place where it belongs to!
    540536    gDebug = arg.HasOption("--debug=") ? arg.GetIntAndRemove("--debug=") : 0;
    541537    if (gDebug==0 && arg.HasOnlyAndRemove("--debug"))
    542538        gDebug=1;
     539
     540    TString f1 = arg.GetStringAndRemove("--log=", "");
     541    if (f1.IsNull() && arg.HasOnlyAndRemove("--log"))
     542        f1 = Form("%s.log", arg.GetName());
     543    if (!f1.IsNull())
     544    {
     545        SetOutputFile(f1);
     546        EnableOutputDevice(eFile);
     547    }
     548
     549    TString f2 = arg.GetStringAndRemove("--html=", "");
     550    if (f2.IsNull() && arg.HasOnlyAndRemove("--html"))
     551        f2 = Form("%s.html", arg.GetName());
     552    if (!f2.IsNull())
     553    {
     554        MLogHtml *html = new MLogHtml(f2);
     555        html->SetBit(kCanDelete);
     556        AddPlugin(html);
     557    }
     558
     559    const Bool_t null = arg.HasOnlyAndRemove("--null");
     560    if (null)
     561        SetNullOutput();
     562
     563    if (arg.HasOnlyAndRemove("--no-colors") || arg.HasOnlyAndRemove("-a"))
     564        SetNoColors();
     565
     566    SetDebugLevel(arg.GetIntAndRemove("-v", 2));
    543567}
    544568
     
    653677// is automatically removed from the list of active plugins.
    654678//
     679// If MLog should take the ownership cal plug->SetBit(kCanDelete);
     680//
    655681void MLog::AddPlugin(MLogPlugin *plug)
    656682{
    657683    fPlugins->Add(plug);
    658     plug->SetBit(kMustCleanup);
    659 }
     684}
  • trunk/MagicSoft/Mars/mbase/MTaskEnv.cc

    r4723 r4732  
    2727// MTaskEnv
    2828//
    29 // If you want to create a new task inside a macro you will have to compile
    30 // your macro using macro.C++, because the root interpreter cannot use
    31 // uncompiled classes. To workaround this problem you can write simple
    32 // funcions (which can be handled by CINT) and use MTaskEnv.
    33 //
    34 // This is a simple way to develop new code in a macro without need
    35 // to compile it.
    36 //
    37 // Example:
    38 //    Int_t Process()
    39 //    {
    40 //       gLog << "Processing..." << endl;
    41 //       return kTRUE;
    42 //    }
    43 //
    44 //    void main()
    45 //    {
    46 //       MTaskEnv task;
    47 //       task.SetProcess(Process);
    48 //       MTaskList list;
    49 //       list.AddToList(&task);
    50 //    }
     29// This class is used if a task - at runtime - should be replaced or setup
     30// from a resource file, eg.
     31//
     32//
     33// resources.rc:
     34//   MyTask: MThisIsMyClass
     35//   MyTask.Resource1: yes
     36//   MyTask.Resource2: 50
     37//
     38// macro.C:
     39//   MTaskList list;
     40//
     41//   MDefaultTask def;
     42//   MTaskEnv taskenv("MyTask");
     43//   taskenv.SetDefault(&def);
     44//
     45//   list.AddToList(&taskenv);
     46//   [...]
     47//   evtloop.ReadEnv("resource.rc");
     48//
     49// In this case MTaskEnv will act like MDefaultTask if nothing is found in the
     50// resource file. If the task is setup via the resource file like in the
     51// example above it will act like a MThisIsMyClass setup with Resource1 and
     52// Resource2.
     53//
     54//
     55// You can also skip the task completely if you setup (in lower case letters!)
     56//
     57// resources.rc:
     58//   MyTask: <dummy>
     59//
     60//
     61// A third option is to setup a MTaskEnv to be skipped except a task is
     62// initialized through the resource file:
     63//   MTaskEnv taskenv("MyTask");
     64//   taskenv.SetDefault(0);
    5165//
    5266//
     
    165179Bool_t MTaskEnv::ReInit(MParList *list)
    166180{
    167     *fLog << fTask->ClassName() << " - " << flush;
     181    *fLog << fTask->ClassName() << " <MTaskEnv>... " << flush;
    168182    return fTask->ReInit(list);
    169183}
     
    171185Int_t MTaskEnv::PreProcess(MParList *list)
    172186{
     187    if (TestBit(kIsDummy))
     188    {
     189        *fLog << inf << "Dummy Task... skipped." << endl;
     190        return kSKIP;
     191    }
     192
    173193    if (!fTask)
    174194    {
     
    177197    }
    178198
    179     *fLog << fTask->ClassName() << " - " << flush;
     199    *fLog << fTask->ClassName() << " <MTaskEnv>... " << flush;
    180200    return fTask->CallPreProcess(list);
    181201}
     
    188208Int_t MTaskEnv::PostProcess()
    189209{
    190     *fLog << fTask->ClassName() << " - " << flush;
     210    *fLog << fTask->ClassName() << " <MTaskEnv>... " << flush;
    191211    return fTask->CallPostProcess();
    192212}
     
    200220    task.ReplaceAll("\015", "");
    201221    task = task.Strip(TString::kBoth);
     222
     223    if (task=="<dummy>")
     224    {
     225        if (TestBit(kIsOwner) && fTask)
     226            delete fTask;
     227        fTask = 0;
     228        SetBit(kIsDummy);
     229        return kTRUE;
     230    }
     231
    202232    fTask = GetTask(task.Data());
    203233    if (!fTask)
  • trunk/MagicSoft/Mars/mbase/MTaskEnv.h

    r4723 r4732  
    1414    MTask *fTask;
    1515
    16     enum { kIsOwner = BIT(14) };
     16    enum { kIsOwner = BIT(14), kIsDummy = BIT(15) };
    1717
    1818    MTask *GetTask(const char *name) const;
     
    3333    void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
    3434
    35     void SetDefault(MTask *task) { fTask = task; }
     35    void SetDefault(MTask *task) { fTask = task; if (!task) SetBit(kIsDummy); }
    3636    void SetDefault(const char *def);
    3737
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r4627 r4732  
    7070
    7171#include <iomanip>
     72
     73#ifndef __USE_XOPEN
     74#define __USE_XOPEN // on some systems needed for strptime
     75#endif
    7276
    7377#include <time.h>     // struct tm
Note: See TracChangeset for help on using the changeset viewer.