14 #include "TObjArray.h"
15 #include "TObjString.h"
16 #include "TStopwatch.h"
89 for (
int i = 0;
i < maxkey;
i++)
95 if ((key >=
lastkey) || (key < -1))
return kFALSE;
98 if (
strings[key][pp] ==
nullptr)
return kFALSE;
104 if ((key >=
lastkey) || (key < -1))
return nullptr;
113 Fatal(
"MakeParamDouble",
"PDATABASE_MAX_DOUBLE_PARAM reached");
117 Warning(
"MakeParamDouble",
"Value %s already exists", paramname);
130 Fatal(
"MakeParamString",
"PDATABASE_MAX_STRING_PARAM reached");
134 Warning(
"MakeParamString",
"Value %s already exists", paramname);
146 Fatal(
"MakeParamInt",
"PDATABASE_MAX_INT_PARAM reached");
150 Warning(
"MakeParamInt",
"Value %s already exists", paramname);
162 Fatal(
"MakeParamTObj",
"PDATABASE_MAX_TOBJ_PARAM reached");
166 Warning(
"MakeParamTObj",
"Value %s already exists", paramname);
211 for (
unsigned int i = 0;
i < strlen(newparamname);
i++) {
212 if (newparamname[
i] ==
':') {
214 Warning(
"ConvertParamKey",
215 "Value %s for key %i not existing",
220 newparamname = newparamname +
i + 1;
230 TString spattern(paramname);
231 TObjArray* array = spattern.Tokenize(TString(
":"));
234 for (
int pat = 0; pat < array->GetEntriesFast(); pat++) {
235 if (done) bla.Append(
"->");
236 TObjString* patoption = (TObjString*) (*array)[pat];
237 char* options = (
char*) patoption->GetString().Data();
255 return (
char*) bla.Data();
259 const char* paramname,
264 const char* newparamname = paramname;
269 paramname = newparamname;
271 if (pp < 0)
return kFALSE;
273 if (
doubles[key][pp] ==
nullptr)
return kFALSE;
281 if (pkey < 0)
return kFALSE;
282 if (
doubles[key][pkey] ==
nullptr)
return kFALSE;
289 const char* paramname,
290 const char** result) {
294 const char* newparamname = paramname;
299 paramname = newparamname;
301 if (pp < 0)
return kFALSE;
303 if (
strings[key][pp] ==
nullptr)
return kFALSE;
311 if (pkey < 0)
return kFALSE;
312 if (
strings[key][pkey] ==
nullptr)
return kFALSE;
318 const char* paramname,
325 const char* newparamname = paramname;
332 paramname = newparamname;
334 if (pp < 0)
return kFALSE;
336 if (
ints[key][pp] ==
nullptr)
return kFALSE;
338 *result =
ints[key][pp];
345 if (pkey < 0)
return kFALSE;
346 if (
ints[key][pkey] ==
nullptr)
return kFALSE;
347 *result =
ints[key][pkey];
356 const char* newparamname = paramname;
361 paramname = newparamname;
363 if (pp < 0)
return kFALSE;
365 if (
tobjs[key][pp] ==
nullptr)
return kFALSE;
367 *result =
tobjs[key][pp];
373 if (pkey < 0)
return kFALSE;
374 if (
tobjs[key][pkey] ==
nullptr)
return kFALSE;
375 *result =
tobjs[key][pkey];
384 cout <<
"PDataBase::SetParamDouble: key " << key <<
" not existing" << endl;
390 cout <<
"PDataBase::SetParamDouble: paramname " << paramname
391 <<
" not existing" << endl;
403 Error(
"SetParamString",
"key %i not existing", key);
409 Error(
"SetParamString",
"paramname %s not existing", paramname);
421 Error(
"SetParamInt",
"key %i not existing", key);
427 Error(
"SetParamInt",
"paramname %s not existing", paramname);
431 ints[key][pp] = result;
439 Error(
"SetParamTObj",
"key %i not existing", key);
445 Error(
"SetParamTObj",
"paramname %s not existing", paramname);
449 tobjs[key][pp] = result;
456 Error(
"SetParamTObj",
"key %i not existing", key);
460 tobjs[key][pp] = result;
467 if (strcmp(name,
strings[
i][0]) == 0)
return i;
477 if (*result == value)
return i;
496 if (*result == value) {
510 if (*result == value)
return i;
518 Warning(
"AddEntry",
"Key %i already existing", key);
522 Warning(
"AddEntry",
"An entry with name %s already exists", name);
542 const char* newname) {
555 Int_t targetkey =
GetEntry(newname);
557 Warning(
"AddListEntry",
"Unable to get entry %s", name);
566 if (targetkey < 0) targetkey =
AddEntry(newname);
568 Warning(
"AddListEntry",
"Unable to name entry %s", newname);
574 i_count =
new Int_t(1);
576 i_link =
new Int_t(targetkey);
578 i_newlink =
new Int_t(key);
582 if (targetkey < 0) targetkey =
AddEntry(newname);
584 Warning(
"AddListEntry",
"Unable to name entry %s", newname);
592 Int_t listkey = -1, lastkey1 = -1;
600 i_newlink =
new Int_t(*i_link);
603 i_link =
new Int_t(targetkey);
618 Int_t *i_count, *loc_listkey_p;
620 if (key == -1)
return kFALSE;
621 if (*listkey == -1) {
624 Warning(
"MakeListIterator",
"count %s not found", count);
629 Warning(
"MakeListIterator",
"link %s not found", link);
633 if (!
GetParamInt(*listkey, link, &loc_listkey_p))
return kFALSE;
636 *listkey = *loc_listkey_p;
637 if (*listkey == key) {
653 Int_t *i_count, *loc_listkey_p;
655 if (key == -1)
return kFALSE;
656 if (*listkey == -1) {
659 Warning(
"MakeListIterator",
"count %i not found", count);
664 Warning(
"MakeListIterator",
"link %i not found", link);
668 if (!
GetParamInt(*listkey, link, &loc_listkey_p))
return kFALSE;
671 *listkey = *loc_listkey_p;
672 if (*listkey == key) {
707 TString spattern(pattern);
708 TObjArray* array = spattern.Tokenize(TString(
","));
710 if (key >= 0) { start = end = key; }
711 for (
int run = 0; run < 2; run++) {
714 for (
int i = start;
i <= end;
i++) {
716 if (run && valid_key[
i] > 0) {
719 if (
i < 10) cout <<
" ";
720 if (
i < 100) cout <<
" ";
721 if (
i < 1000) cout <<
" ";
723 cout <<
"Database key=" <<
i << endl;
725 for (
int pat = 0; pat < array->GetEntriesFast(); pat++) {
729 cout <<
"PDataBase::listEntries: Too many pattern strings" << endl;
732 TObjString* patoption = (TObjString*) (*array)[pat];
733 char* options = (
char*) patoption->GetString().Data();
734 Bool_t checkline = kTRUE;
735 Bool_t invert = kFALSE;
736 if (options[0] ==
'*') {
741 if (options[0] ==
'!') {
748 if (valid_key[
i] > 0) {
751 cout << options <<
"=";
754 printf(
"%f", *result);
763 sprintf(bla,
"%f", *result);
764 sz[
i][pat] = strlen(bla);
765 if (sz[
i][pat] > max_sz[pat]) max_sz[pat] = sz[
i][pat];
766 if (checkline && !invert)
768 else if (invert && checkline)
775 if (valid_key[
i] > 0) {
777 cout << options <<
"=";
780 printf(
"%i", *result3);
789 sprintf(bla,
"%i", *result3);
790 sz[
i][pat] = strlen(bla);
791 if (sz[
i][pat] > max_sz[pat]) max_sz[pat] = sz[
i][pat];
792 if (checkline && !invert)
794 else if (invert && checkline)
801 if (valid_key[
i] > 0) {
803 cout << options <<
"=" << result2;
812 sz[
i][pat] = strlen(result2);
813 if (sz[
i][pat] > max_sz[pat]) max_sz[pat] = sz[
i][pat];
814 if (checkline && !invert)
816 else if (invert && checkline)
823 if (valid_key[
i] > 0) {
826 cout << options <<
"=<yes>";
836 if (sz[
i][pat] > max_sz[pat]) max_sz[pat] = sz[
i][pat];
837 if (checkline && !invert)
839 else if (invert && checkline)
847 if (option && run && valid_key[
i] > 0) {
851 if (!ga) ga -= strlen(options) + 2;
852 for (
int x = ga;
x < max_sz[pat];
x++) {
858 if (run && valid_key[
i] > 0) cout <<
"\n";
870 Int_t mypid = 0, pid_param = 0, *i_result;
871 for (
int r = 0; r < 10000; r++)
872 for (
int i = 0;
i < 50;
i++) {
879 cout << timer.RealTime() << endl;
880 cout << mypid << endl;
885 for (
int r = 0; r < 10000; r++)
886 for (
int i = 0;
i < 50;
i++) {
890 cout <<
"PStaticData::ID: " <<
i <<
" not found" << endl;
895 cout << timer.RealTime() << endl;
896 cout << mypid << endl;