Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4ReplaceException.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4ReplaceException.h"
00017 
00018 #include "TThread.h"
00019 
00020 #include "TGo4Log.h"
00021 #include "TGo4Thread.h"
00022 #include "TGo4ThreadManager.h"
00023 #include "TGo4ThreadHandler.h"
00024 #include "TGo4Runnable.h"
00025 
00026 TGo4ReplaceException::TGo4ReplaceException(const TGo4ReplaceException &right)
00027   :TGo4ThreadException(right)
00028 {
00029    TRACE((14,"TGo4ReplaceException::TGo4ReplaceException() copy constructor",__LINE__, __FILE__));
00030    fxNewRunnable=right.fxNewRunnable;
00031 }
00032 
00033 TGo4ReplaceException::TGo4ReplaceException (TGo4Runnable* runnable, TGo4Runnable* newrunnable, const Text_t* oldthreadname)
00034  :TGo4ThreadException(runnable, oldthreadname)
00035 {
00036    TRACE((14,"TGo4ReplaceException::TGo4ReplaceException(TGo4Runnable*,TGo4Runnable*,const Text_t*) constructor",__LINE__, __FILE__));
00037    fxDescription= "!!!-- Go4 Replace Exception --!!!";
00038    if(newrunnable==0)
00039       {
00040       TRACE((13,"TGo4ReplaceException constructor -- new runnable same as old runnable",__LINE__, __FILE__));
00041          fxNewRunnable=(TGo4Runnable*) runnable->Clone(); // deep copy
00042          *fxNewRunnable=*runnable;   // pointers to manager and thread are not streamed,
00043                                      // must be handed over by operator= of base class
00044       }
00045    else
00046       {
00047       TRACE((13,"TGo4ReplaceException constructor -- new runnable specified",__LINE__, __FILE__));
00048          fxNewRunnable=newrunnable;
00049       }
00050 }
00051 
00052 
00053 TGo4ReplaceException::~TGo4ReplaceException()
00054 {
00055   TRACE((14,"TGo4ReplaceException::~TGo4ReplaceException() destructor",__LINE__, __FILE__));
00056 }
00057 
00058 
00059 TGo4ReplaceException & TGo4ReplaceException::operator=(const TGo4ReplaceException &right)
00060 {
00061    TRACE((14,"TGo4ReplaceException::operator=",__LINE__, __FILE__));
00062    if (&right!=this)
00063       {
00064          TRACE((13,"TGo4ReplaceException::operator= processing copy",__LINE__, __FILE__));
00065          TGo4ThreadException::operator=(right); // copy base class members
00066          // put additional member copies here...
00067          fxNewRunnable=right.fxNewRunnable;
00068          return *this;
00069       }
00070    else
00071       {
00072          // copy is already source object
00073          TRACE((13,"TGo4ReplaceException::operator= source and destination objects are identical",__LINE__, __FILE__));
00074          return *this;
00075       }
00076 }
00077 
00078 Int_t TGo4ReplaceException::Handle ()
00079 {
00080    TRACE((14,"TGo4ReplaceException::Handle()",__LINE__, __FILE__));
00081     // first step: find out name of thread to be replaced
00082    TString name;
00083    if(GetThreadName()==0)
00084       // no threadname specified, use name of thread associated with runnable
00085       {
00086          TRACE((13,"TGo4ReplaceException::Handle() -- replacing thread associated with runnable",__LINE__, __FILE__));
00087          name = fxRunnable->GetThread()->GetName();
00088       }
00089    else
00090       // threadname given, use thread handler to cancel
00091       {
00092          TRACE((13,"TGo4ReplaceException::Handle() -- replacing thread by specified name",__LINE__, __FILE__));
00093          name = GetThreadName();
00094       }
00095 
00096       // second step: remove it
00097       fxThreadHandler->RemoveThread(name.Data());
00098 
00099     // third step: new thread
00100     fxThreadHandler->NewThread(name,fxNewRunnable);
00101     fxThreadHandler->Start(name);
00102 
00103     TThread::CancelPoint();
00104     return 0;
00105 
00106 }
00107 
00108 
00109 
00110 
00111 
00112 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:31 2008 for Go4-v3.04-1 by  doxygen 1.4.2