Ignore:
Timestamp:
11/17/03 14:29:54 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
3 edited

Legend:

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

    r2491 r2519  
    101101
    102102#ifdef _REENTRANT
    103 // FIXME: Replace Mutex by TMutex
    104 #include <pthread.h>
     103#include <TMutex.h>
    105104#endif
    106105#include <TGTextView.h>
     
    148147    // Creat drawing semaphore
    149148    //
    150     fMuxGui = new pthread_mutex_t;
    151     pthread_mutex_init((pthread_mutex_t*)fMuxGui, NULL);
     149    fMuxGui = new TMutex;
    152150#endif
    153151}
     
    158156// which is used for the output (i)
    159157//
    160 MLog::MLog(int i) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(i), fIsNull(kFALSE), fout(NULL), fOutAllocated(kFALSE), fgui(NULL), fNumLines(0)
     158MLog::MLog(int i) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(i), fIsNull(kFALSE), fOut(NULL), fOutAllocated(kFALSE), fGui(NULL), fNumLines(0)
    161159{
    162160    Init();
     
    168166// ofstream as the default output device
    169167//
    170 MLog::MLog(ofstream &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fout(&out), fOutAllocated(kFALSE), fgui(NULL), fNumLines(0)
     168MLog::MLog(ofstream &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fOut(&out), fOutAllocated(kFALSE), fGui(NULL), fNumLines(0)
    171169{
    172170    Init();
     
    178176// TGTextView as the default output device
    179177//
    180 MLog::MLog(TGTextView &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eGui), fout(NULL), fOutAllocated(kFALSE), fgui(&out), fNumLines(0)
     178MLog::MLog(TGTextView &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eGui), fOut(NULL), fOutAllocated(kFALSE), fGui(&out), fNumLines(0)
    181179{
    182180    Init();
     
    189187// or not.
    190188//
    191 MLog::MLog(const char *fname, int flag) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fgui(NULL), fNumLines(0)
     189MLog::MLog(const char *fname, int flag) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fGui(NULL), fNumLines(0)
    192190{
    193191    Init();
     
    205203    DeallocateFile();
    206204#ifdef _REENTRANT
    207     pthread_mutex_destroy((pthread_mutex_t*)fMuxGui);
     205    delete fMuxGui;
    208206#endif
    209207}
     
    310308        Output(cerr, len);
    311309
    312     if (fDevice&eFile && fout)
    313         fout->write(fBase, len);
    314 
    315     if (fDevice&eGui && fgui)
     310    if (fDevice&eFile && fOut)
     311        fOut->write(fBase, len);
     312
     313    if (fDevice&eGui && fGui)
    316314    {
    317315        // check whether the current text was flushed or endl'ed
     
    348346    Lock();
    349347
    350     TGText &txt=*fgui->GetText();
     348    TGText &txt=*fGui->GetText();
    351349
    352350    // copy lines to TGListBox
     
    367365
    368366    // show last entry
    369     fgui->Layout();
    370     fgui->SetVsbPosition(txt.RowCount()-1);
     367    fGui->Layout();
     368    fGui->SetVsbPosition(txt.RowCount()-1);
    371369
    372370    // tell a main loop, that list box contents have changed
    373     fgui->SetBit(kHasChanged);
     371    fGui->SetBit(kHasChanged);
    374372
    375373    // release mutex
     
    380378{
    381379#ifdef _REENTRANT
    382     pthread_mutex_lock((pthread_mutex_t*)fMuxGui);
     380    fMuxGui->Lock();
    383381#endif
    384382}
     
    387385{
    388386#ifdef _REENTRANT
    389     pthread_mutex_unlock((pthread_mutex_t*)fMuxGui);
     387    fMuxGui->UnLock();
    390388#endif
    391389}
     
    411409        cerr.flush();
    412410
    413     if (fDevice&eFile && fout)
    414         fout->flush();
     411    if (fDevice&eFile && fOut)
     412        fOut->flush();
    415413
    416414    return 0;
     
    455453    // gcc 3.2:
    456454    char *txt = (char*)"logXXXXXX";
    457     fout = fname ? new ofstream(fname) : new ofstream(/*mkstemp(*/txt/*)*/);
     455    fOut = fname ? new ofstream(fname) : new ofstream(/*mkstemp(*/txt/*)*/);
    458456    fOutAllocated = kTRUE;
    459457}
     
    467465{
    468466    if (fOutAllocated)
    469         delete fout;
     467        delete fOut;
    470468}
    471469
  • trunk/MagicSoft/Mars/mbase/MLog.h

    r2236 r2519  
    1313#define bsz    160 // two standard lines
    1414
     15class TMutex;
    1516class TGTextView;
    1617
     
    5758    Bool_t fIsNull;           //! Switch output completely off
    5859
    59     ofstream   *fout;          //! possible file output stream
     60    ofstream   *fOut;          //! possible file output stream
    6061    Bool_t      fOutAllocated; //! flag if fout is created by MLogging
    61     TGTextView *fgui;          //! Text View output
     62    TGTextView *fGui;          //! Text View output
    6263
    6364    Bool_t     fIsDirectGui;  //! Pipe text directly to the GUI (for single threaded environments)
     
    6768
    6869#ifdef _REENTRANT
    69     void *fMuxGui;            //! Mutex locking access of TGListBox
     70    TMutex *fMuxGui;          //! Mutex locking access of TGListBox
    7071#endif
    7172
     
    119120    void SetOutputGui(TGTextView *out, int flag=-1)
    120121    {
    121         fgui = out;
     122        fGui = out;
    122123        CheckFlag(eGui, flag);
    123124    }
     
    133134        //
    134135        DeallocateFile();
    135         fout = &out;
     136        fOut = &out;
    136137        CheckFlag(eFile, flag);
    137138    }
     
    162163        // I would implement a GetFileName-function, too.
    163164        //
    164         if (!fout)
     165        if (!fOut)
    165166            ReallocateFile(NULL);
    166         return *fout;
     167        return *fOut;
    167168    }
    168169
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r2493 r2519  
    894894    // in the same thread
    895895    //
    896     if (fMutex->TryLock()==13)
     896    if (fMutex->TryLock())
    897897        return;
    898898
Note: See TracChangeset for help on using the changeset viewer.