00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4ParameterMember.h"
00017
00018 #include "RVersion.h"
00019 #include "TDataType.h"
00020 #include <stdlib.h>
00021
00022 TGo4ParameterMember::TGo4ParameterMember() :
00023 TNamed(),
00024 fTypeName(),
00025 fTypeId(0),
00026 fMemberId(0),
00027 fValue(),
00028 fIndex1(-1),
00029 fIndex2(-1),
00030 fObject(0),
00031 fObjectOwner(kTRUE),
00032 fVisible(kTRUE)
00033 {
00034 }
00035
00036 TGo4ParameterMember::TGo4ParameterMember(const char* name, const char* title) :
00037 TNamed(name, title),
00038 fTypeName(),
00039 fTypeId(0),
00040 fMemberId(0),
00041 fValue(),
00042 fIndex1(-1),
00043 fIndex2(-1),
00044 fObject(0),
00045 fObjectOwner(kTRUE),
00046 fVisible(kTRUE)
00047 {
00048 }
00049
00050 TGo4ParameterMember::~TGo4ParameterMember()
00051 {
00052 if ((fObject!=0) && fObjectOwner) {
00053 delete fObject;
00054 fObject = 0;
00055 }
00056 }
00057
00058 void TGo4ParameterMember::SetArrayIndexes(Int_t ndim, Int_t indx1, Int_t indx2)
00059 {
00060 switch(ndim) {
00061 case 1:
00062 fIndex1 = indx1;
00063 fIndex2 = -1;
00064 break;
00065 case 2:
00066 fIndex1 = indx1;
00067 fIndex2 = indx2;
00068 break;
00069 default:
00070 fIndex1 = -1;
00071 fIndex2 = -1;
00072 break;
00073 }
00074 }
00075
00076 Bool_t TGo4ParameterMember::CheckArrayIndexes(Int_t ndim, Int_t indx1, Int_t indx2)
00077 {
00078 switch(ndim) {
00079 case 1: return (fIndex1==indx1) && (fIndex2<0);
00080 case 2: return (fIndex1==indx1) && (fIndex2==indx2);
00081 default: return (fIndex1<0) && (fIndex2<0);
00082 }
00083
00084 return (fIndex1<0) && (fIndex2<0);
00085 }
00086
00087
00088 const char* TGo4ParameterMember::GetFullName(TString& buf)
00089 {
00090 buf = "";
00091 if ((fIndex1<0) && (fIndex2<0))
00092 buf = GetName();
00093 else
00094 if ((fIndex1>=0) && (fIndex2<0))
00095 buf.Form("%s[%d]",GetName(),fIndex1);
00096 else
00097 if ((fIndex1>=0) && (fIndex2>=0))
00098 buf.Form("%s[%d][%d]",GetName(),fIndex1,fIndex2);
00099 return buf.Data();
00100 }
00101
00102 void TGo4ParameterMember::SetObject(TObject* obj, Bool_t owner)
00103 {
00104 if ((fObject!=0) && fObjectOwner) delete fObject;
00105
00106 fObject = obj;
00107 fObjectOwner = owner;
00108 }
00109
00110
00111 void TGo4ParameterMember::SetValue(char* addr)
00112 {
00113 fValue = "";
00114 switch (fTypeId) {
00115 case kUInt_t: fValue.Form("%u", *((UInt_t*)addr)); break;
00116 case kInt_t: fValue.Form("%d", *((Int_t*)addr)); break;
00117 case kULong_t: fValue.Form("%lu", *((ULong_t*)addr)); break;
00118 case kLong_t: fValue.Form("%ld", *((Long_t*)addr)); break;
00119 case kULong64_t: fValue.Form("%llu", *((ULong64_t*)addr)); break;
00120 case kLong64_t: fValue.Form("%lld", *((Long64_t*)addr)); break;
00121 case kUShort_t: fValue.Form("%hu", *((UShort_t*)addr)); break;
00122 case kShort_t: fValue.Form("%hd", *((Short_t*)addr)); break;
00123 case kUChar_t: fValue.Form("%u", *((UChar_t*)addr)); break;
00124 case kChar_t: fValue.Form("%d", *((Char_t*)addr)); break;
00125 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,3,2)
00126 case kBool_t: fValue.Form("%d", *((Bool_t*)addr)); break;
00127 #endif
00128 case kFloat_t: fValue.Form("%f", *((Float_t*)addr)); break;
00129 case kDouble_t: fValue.Form("%f", *((Double_t*)addr)); break;
00130 case kDouble32_t: fValue.Form("%f", *((Double32_t*)addr)); break;
00131 case kTString_t: fValue = *((TString*)addr); break;
00132 case kTGo4Fitter_t: {
00133 TObject** f = (TObject**)addr;
00134 fObject = *f;
00135 fObjectOwner = kFALSE;
00136 break;
00137 }
00138 }
00139 }
00140
00141 void TGo4ParameterMember::GetValue(char* addr)
00142 {
00143 const char* value = fValue.Data();
00144 switch (fTypeId) {
00145 case kUInt_t: *((UInt_t*)addr) = atoi(value); break;
00146 case kInt_t: *((Int_t*)addr) = atoi(value); break;
00147 case kULong_t: *((ULong_t*)addr) = atoi(value); break;
00148 case kLong_t: *((Long_t*)addr) = atoi(value); break;
00149 case kULong64_t: *((ULong64_t*)addr) = atoi(value); break;
00150 case kLong64_t: *((Long64_t*)addr) = atoi(value); break;
00151 case kUShort_t: *((UShort_t*)addr) = atoi(value); break;
00152 case kShort_t: *((Short_t*)addr) = atoi(value); break;
00153 case kUChar_t: *((UChar_t*)addr) = atoi(value); break;
00154 case kChar_t: *((Char_t*)addr) = atoi(value); break;
00155 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,3,2)
00156 case kBool_t: *((Bool_t*)addr) = atoi(value); break;
00157 #endif
00158 case kFloat_t: *((Float_t*)addr) = atof(value); break;
00159 case kDouble_t: *((Double_t*)addr) = atof(value); break;
00160 case kDouble32_t: *((Double32_t*)addr) = atof(value); break;
00161 case kTString_t: *((TString*)addr) = value; break;
00162 case kTGo4Fitter_t: {
00163 TObject** f = (TObject**)addr;
00164 *f = fObject;
00165 fObjectOwner = kFALSE;
00166 break;
00167 }
00168 }
00169 }
00170
00171