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

/Go4CommandsAnalysis/TGo4ComCreateObject.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 "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");  // this command needs client as receiver
00034                                                  // to send back status message
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");  // this command needs client as receiver
00046                                                  // to send back status message
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             } // if(ana)
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 //----------------------------END OF GO4 SOURCE FILE ---------------------

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