Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ParameterStatus.h"
00015
00016 #include "Riostream.h"
00017 #include "TObjArray.h"
00018 #include "TROOT.h"
00019 #include "TClass.h"
00020
00021 #include "TGo4Log.h"
00022 #include "TGo4Parameter.h"
00023
00024 TGo4ParameterStatus::TGo4ParameterStatus() :
00025 TGo4ObjectStatus(),
00026 fxMemberValues(0)
00027 {
00028 }
00029
00030 TGo4ParameterStatus::TGo4ParameterStatus(TGo4Parameter* par, Bool_t membervalues) :
00031 TGo4ObjectStatus(par),
00032 fxMemberValues(0)
00033 {
00034 if ((par!=0) && membervalues) {
00035 fxMemberValues = new TObjArray();
00036 fxMemberValues->SetOwner(kTRUE);
00037 par->GetMemberValues(fxMemberValues);
00038 }
00039 }
00040
00041 TGo4ParameterStatus::TGo4ParameterStatus(const char* parname, const char* parclass, TObjArray* items) :
00042 TGo4ObjectStatus(),
00043 fxMemberValues(items)
00044 {
00045 SetName(parname);
00046 SetTitle("TGo4ParameterStatus title");
00047 fxObjectClass = parclass;
00048 }
00049
00050
00051 TGo4ParameterStatus::~TGo4ParameterStatus()
00052 {
00053 if (fxMemberValues!=0) delete fxMemberValues;
00054 }
00055
00056 TObjArray* TGo4ParameterStatus::GetMemberValues(Bool_t takeit)
00057 {
00058 TObjArray* res = fxMemberValues;
00059 if (takeit) fxMemberValues = 0;
00060 return res;
00061 }
00062
00063 Bool_t TGo4ParameterStatus::UpdateParameterValues(TGo4Parameter* par)
00064 {
00065 if ((par==0) || (fxMemberValues==0)) return kFALSE;
00066 if (strcmp(GetObjectClass(), par->ClassName())!=0) return kFALSE;
00067
00068 if (par->CustomUpdateFrom()) {
00069 TGo4Parameter* copypar = CreateParameter();
00070 par->UpdateFrom(copypar);
00071 delete copypar;
00072 } else {
00073 par->SetMemberValues(fxMemberValues);
00074 }
00075
00076 return kTRUE;
00077
00078 }
00079
00080 TGo4Parameter* TGo4ParameterStatus::CreateParameter()
00081 {
00082 TClass* parclass = gROOT->GetClass(GetObjectClass());
00083 if ((parclass==0) || (fxMemberValues==0)) return 0;
00084
00085 TGo4Parameter* par = (TGo4Parameter*) parclass->New();
00086
00087 if (par==0) return 0;
00088
00089 par->SetName(GetName());
00090 par->SetMemberValues(fxMemberValues);
00091
00092 return par;
00093 }
00094
00095 Int_t TGo4ParameterStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00096 {
00097 GO4TRACE((12,"TGo4ParameterStatus::PrintStatus()",__LINE__, __FILE__));
00098 if(buflen<=0 && buffer!=0) return 0;
00099 Int_t locallen = 128000;
00100 Text_t localbuf[128000];
00101 Int_t size=0;
00102 Text_t* current = localbuf;
00103 Int_t restlen = locallen;
00104 Int_t delta = TGo4ObjectStatus::PrintStatus(current,restlen);
00105 restlen -= delta;
00106 current += delta;
00107 current = PrintIndent(current, restlen);
00108 current = PrintBuffer(current, restlen, "G-OOOO-> Parameter Status Class Printout <-OOOO-G\n");
00109 current = PrintIndent(current, restlen);
00110 current = PrintBuffer(current, restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00111
00112
00114 if(buffer==0) {
00115 std::cout << localbuf << std::endl;
00116 } else {
00117 size = locallen-restlen;
00118 if(size>buflen-1) size = buflen-1;
00119 strncpy(buffer,localbuf,size);
00120 }
00121 return size;
00122 }