00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4ComCreateObject.h"
00017
00018 #include "TROOT.h"
00019 #include "TClass.h"
00020
00021 #include "Go4Log/TGo4Log.h"
00022 #include "Go4Analysis/TGo4AnalysisImp.h"
00023 #include "Go4AnalysisClient/TGo4AnalysisClientImp.h"
00024
00025
00026 TGo4ComCreateObject::TGo4ComCreateObject(const char* obname,
00027 const char* classname)
00028 :TGo4AnalysisObjectCommand("ANCreate",
00029 "Creates a new object by classname",
00030 obname)
00031 {
00032 TRACE((12,"TGo4ComCreateObject::TGo4ComCreateObject() ctor",__LINE__, __FILE__));
00033 SetReceiverName("AnalysisClient");
00034
00035 SetObjectClassName(classname);
00036 SetProtection(kGo4ComModeController);
00037 }
00038
00039 TGo4ComCreateObject::TGo4ComCreateObject()
00040 :TGo4AnalysisObjectCommand("ANCreate",
00041 "Creates a new object by classname",
00042 "histogram1")
00043 {
00044 TRACE((12,"TGo4ComCreateObject::TGo4ComCreateObject() ctor",__LINE__, __FILE__));
00045 SetReceiverName("AnalysisClient");
00046
00047 SetObjectClassName("TH1F");
00048 SetProtection(kGo4ComModeController);
00049 }
00050
00051 TGo4ComCreateObject::~TGo4ComCreateObject()
00052 {
00053 TRACE((12,"TGo4ComCreateObject::~TGo4ComCreateObject() dtor",__LINE__, __FILE__));
00054 }
00055
00056 Int_t TGo4ComCreateObject::ExeCom()
00057 {
00058 TRACE((12,"TGo4ComCreateObject::ExeCom()",__LINE__, __FILE__));
00059
00060 TGo4Analysis* ana=0;
00061 TGo4AnalysisClient* cli=dynamic_cast<TGo4AnalysisClient*> (fxReceiverBase);
00062 if(cli)
00063 {
00064 ana=TGo4Analysis::Instance();
00065 if(ana)
00066 {
00067 TNamed* ob=CreateObject();
00068 if(ana->AddObject(ob))
00069 {
00070 cli->SendStatusMessage(1, kFALSE,"Added new object %s to Go4 folders.",
00071 GetObjectName());
00072 }
00073 else
00074 {
00075 cli->SendStatusMessage(3, kFALSE,"ERROR on adding new object %s ",
00076 GetObjectName());
00077 delete ob;
00078 }
00079
00080 }
00081 else
00082 {
00083 cli->SendStatusMessage(3, kTRUE," %s ERROR no analysis",
00084 GetName());
00085 }
00086 }
00087 else
00088 {
00089 TRACE((11,"TGo4ComCreateObject::ExeCom() - no receiver specified ERROR!",__LINE__, __FILE__));
00090 TGo4Log::Debug(" !!! %s : NO RECEIVER ERROR!!!",GetName());
00091 return 1;
00092 }
00093
00094 return -1;
00095 }
00096
00097
00098 TNamed* TGo4ComCreateObject::CreateObject()
00099 {
00100 TRACE((12,"TGo4ComCreateObject::CreateObject()",__LINE__, __FILE__));
00101 gROOT->cd();
00102 TClass* theclass= gROOT->GetClass(GetObjectClassName());
00103 TNamed* ob= (TNamed*) ( theclass->New() );
00104 ob->SetName(GetObjectName());
00105 return ob;
00106 }
00107
00108 ClassImp(TGo4ComCreateObject)
00109
00110
00111
00112
00113