GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ParameterStatus.cxx
Go to the documentation of this file.
1 // $Id: TGo4ParameterStatus.cxx 2759 2020-04-16 13:00:41Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ParameterStatus.h"
15 
16 #include <iostream>
17 
18 #include "TROOT.h"
19 #include "TClass.h"
20 #include "TObjArray.h"
21 
22 #include "TGo4Log.h"
23 #include "TGo4Parameter.h"
24 
27  fxMemberValues(0)
28 {
29 }
30 
32  TGo4ObjectStatus(par),
33  fxMemberValues(0)
34 {
35  if ((par!=0) && membervalues) {
36  fxMemberValues = new TObjArray();
37  fxMemberValues->SetOwner(kTRUE);
39  }
40 }
41 
42 TGo4ParameterStatus::TGo4ParameterStatus(const char* parname, const char* parclass, TObjArray* items) :
44  fxMemberValues(items)
45 {
46  SetName(parname);
47  SetTitle("TGo4ParameterStatus title");
48  fxObjectClass = parclass;
49 }
50 
51 
53 {
54  if (fxMemberValues!=0) delete fxMemberValues;
55 }
56 
57 TObjArray* TGo4ParameterStatus::GetMemberValues(Bool_t takeit)
58 {
59  TObjArray* res = fxMemberValues;
60  if (takeit) fxMemberValues = 0;
61  return res;
62 }
63 
65 {
66  if ((par==0) || (fxMemberValues==0)) return kFALSE;
67  if (strcmp(GetObjectClass(), par->ClassName())!=0) return kFALSE;
68 
69  if (par->CustomUpdateFrom()) {
70  TGo4Parameter* copypar = CreateParameter();
71  par->UpdateFrom(copypar);
72  delete copypar;
73  } else {
75  }
76 
77  return kTRUE;
78 
79 }
80 
82 {
83  TClass* parclass = gROOT->GetClass(GetObjectClass());
84  if ((parclass==0) || (fxMemberValues==0)) return 0;
85 
86  TGo4Parameter* par = (TGo4Parameter*) parclass->New();
87 
88  if (par==0) return 0;
89 
90  par->SetName(GetName());
92 
93  return par;
94 }
95 
96 Int_t TGo4ParameterStatus::PrintStatus(Text_t* buffer, Int_t buflen)
97 {
98  GO4TRACE((12,"TGo4ParameterStatus::PrintStatus()",__LINE__, __FILE__));
99  if(buflen<=0 && buffer!=0) return 0;
100  Int_t locallen = 128000;
101  Text_t localbuf[128000];
102  Int_t size=0;
103  Text_t* current = localbuf;
104  Int_t restlen = locallen;
105  Int_t delta = TGo4ObjectStatus::PrintStatus(current,restlen);
106  restlen -= delta;
107  current += delta;
108  current = PrintIndent(current, restlen);
109  current = PrintBuffer(current, restlen, "G-OOOO-> Parameter Status Class Printout <-OOOO-G\n");
110  current = PrintIndent(current, restlen);
111  current = PrintBuffer(current, restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
112  // put printout of condition infos here:
113 
115  if(buffer==0) {
116  std::cout << localbuf << std::endl;
117  } else {
118  size = locallen-restlen;
119  if(size>buflen-1) size = buflen-1;
120  strncpy(buffer,localbuf,size);
121  }
122  return size;
123 }
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
Bool_t UpdateParameterValues(TGo4Parameter *par)
TObjArray * GetMemberValues(Bool_t takeit=kFALSE)
static Text_t * PrintIndent(Text_t *buffer, Int_t &buflen)
Definition: TGo4Status.cxx:72
TGo4Parameter * CreateParameter()
Bool_t SetMemberValues(TObjArray *fItems)
const char * GetObjectClass() const
#define GO4TRACE(X)
Definition: TGo4Log.h:26
virtual Bool_t UpdateFrom(TGo4Parameter *rhs)
virtual Bool_t CustomUpdateFrom() const
Definition: TGo4Parameter.h:55
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
static Text_t * PrintBuffer(char *buffer, Int_t &buflen, const char *text,...)
Definition: TGo4Status.cxx:84
void GetMemberValues(TObjArray *fItems)