Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4ThreadManager/TGo4ReplaceException.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 #include "Go4ThreadManager/TGo4ThreadManager.h"
00018 #include "Go4ThreadManager/TGo4Runnable.h"
00019 #include "Go4Log/TGo4Log.h"
00020 
00021 TGo4ReplaceException::TGo4ReplaceException(const TGo4ReplaceException &right)
00022   :TGo4ThreadException(right)
00023 {
00024    TRACE((14,"TGo4ReplaceException::TGo4ReplaceException() copy constructor",__LINE__, __FILE__));
00025    fxNewRunnable=right.fxNewRunnable;
00026 }
00027 
00028 TGo4ReplaceException::TGo4ReplaceException (TGo4Runnable* runnable, TGo4Runnable* newrunnable, const Text_t* oldthreadname)
00029  :TGo4ThreadException(runnable, oldthreadname)
00030 {
00031    TRACE((14,"TGo4ReplaceException::TGo4ReplaceException(TGo4Runnable*,TGo4Runnable*,const Text_t*) constructor",__LINE__, __FILE__));
00032    fxDescription= "!!!-- Go4 Replace Exception --!!!";
00033    if(newrunnable==0)
00034       {
00035       TRACE((13,"TGo4ReplaceException constructor -- new runnable same as old runnable",__LINE__, __FILE__));
00036          fxNewRunnable=(TGo4Runnable*) runnable->Clone(); // deep copy
00037          *fxNewRunnable=*runnable;   // pointers to manager and thread are not streamed,
00038                                      // must be handed over by operator= of base class
00039       }
00040    else
00041       {
00042       TRACE((13,"TGo4ReplaceException constructor -- new runnable specified",__LINE__, __FILE__));
00043          fxNewRunnable=newrunnable;
00044       }
00045 }
00046 
00047 
00048 TGo4ReplaceException::~TGo4ReplaceException()
00049 {
00050   TRACE((14,"TGo4ReplaceException::~TGo4ReplaceException() destructor",__LINE__, __FILE__));
00051 }
00052 
00053 
00054 TGo4ReplaceException & TGo4ReplaceException::operator=(const TGo4ReplaceException &right)
00055 {
00056    TRACE((14,"TGo4ReplaceException::operator=",__LINE__, __FILE__));
00057    if (&right!=this)
00058       {
00059          TRACE((13,"TGo4ReplaceException::operator= processing copy",__LINE__, __FILE__));
00060          TGo4ThreadException::operator=(right); // copy base class members
00061          // put additional member copies here...
00062          fxNewRunnable=right.fxNewRunnable;
00063          return *this;
00064       }
00065    else
00066       {
00067          // copy is already source object
00068          TRACE((13,"TGo4ReplaceException::operator= source and destination objects are identical",__LINE__, __FILE__));
00069          return *this;
00070       }
00071 }
00072 
00073 Int_t TGo4ReplaceException::Handle ()
00074 {
00075    TRACE((14,"TGo4ReplaceException::Handle()",__LINE__, __FILE__));
00076     // first step: find out name of thread to be replaced
00077    Text_t name[TGo4ThreadManager::fguTEXTLENGTH];
00078    if(GetThreadName()==0)
00079       // no threadname specified, use name of thread associated with runnable
00080       {
00081          TRACE((13,"TGo4ReplaceException::Handle() -- replacing thread associated with runnable",__LINE__, __FILE__));
00082          strncpy(name,fxRunnable->GetThread()->GetName(),TGo4ThreadManager::fguTEXTLENGTH-1);
00083       }
00084    else
00085       // threadname given, use thread handler to cancel
00086       {
00087          TRACE((13,"TGo4ReplaceException::Handle() -- replacing thread by specified name",__LINE__, __FILE__));
00088          strncpy(name,GetThreadName(),TGo4ThreadManager::fguTEXTLENGTH-1);
00089       }
00090 
00091       // second step: remove it
00092       fxThreadHandler->RemoveThread(name);
00093 
00094     // third step: new thread
00095     fxThreadHandler->NewThread(name,fxNewRunnable);
00096     fxThreadHandler->Start(name);
00097 
00098     TThread::CancelPoint();
00099     return 0;
00100 
00101 }
00102 
00103 
00104 
00105 
00106 
00107 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:07 2005 for Go4-v2.10-5 by doxygen1.2.15