CbmRoot
PValues.cxx
Go to the documentation of this file.
1 // Value container implementation file
3 //
4 // Just a small container class for user-defined values
5 //
7 
8 
9 #include "PValues.h"
10 #include <iostream>
11 #include <string.h>
12 
13 using namespace std;
14 
15 PValues::PValues() : TObject(), pointer {0} {
16  // pointer=0;
17 }
18 
19 PValues::PValues(const PValues& p) : TObject(p), pointer {p.pointer} {
20  // pointer=p.pointer;
21 
22  for (int i = 0; i < pointer; i++) {
23  array_id[i] = p.array_id[i];
24  array_val[i] = p.array_val[i];
25  }
26 }
27 
28 bool PValues::SetValue(int id, double val) {
29 
30  for (int i = 0; i < pointer; i++) {
31  if (array_id[i] == id) {
32  array_val[i] = val;
33  return kTRUE;
34  }
35  }
36  if (pointer == MAX_VALUES) { return kFALSE; }
37 
38  array_val[pointer] = val;
39  array_id[pointer] = id;
40 
41  pointer++;
42 
43  return kTRUE;
44 }
45 
46 bool PValues::GetValue(int id, double* val) {
47  for (int i = 0; i < pointer; i++) {
48  if (array_id[i] == id) {
49  *val = array_val[i];
50  return kTRUE;
51  }
52  }
53  return kFALSE;
54 }
55 
56 int PValues::StringToValueID(char* st) {
57  if (!strcmp(st, "t")) return T_MATRIX;
58  if (!strcmp(st, "u")) return U_MATRIX;
59  if (!strcmp(st, "tu")) return TU_MATRIX;
60  return -1;
61 }
62 
63 void PValues::Print(const Option_t*) const {
64  for (int i = 0; i < pointer; i++) {
65  cout << "Value #" << array_id[i] << " is: " << array_val[i] << endl;
66  }
67 }
68 
69 
PValues::Print
void Print(const Option_t *) const
Definition: PValues.cxx:63
PValues::array_val
double array_val[MAX_VALUES]
Definition: PValues.h:37
PValues::pointer
int pointer
Definition: PValues.h:39
PValues
Definition: PValues.h:21
PValues::StringToValueID
int StringToValueID(char *st)
Definition: PValues.cxx:56
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
PValues::GetValue
bool GetValue(int id, double *val)
Definition: PValues.cxx:46
U_MATRIX
#define U_MATRIX
Definition: PValues.h:14
PValues::array_id
int array_id[MAX_VALUES]
Definition: PValues.h:36
TU_MATRIX
#define TU_MATRIX
Definition: PValues.h:15
T_MATRIX
#define T_MATRIX
Definition: PValues.h:13
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
PValues.h
MAX_VALUES
#define MAX_VALUES
Definition: PValues.h:11
PValues::SetValue
bool SetValue(int id, double val)
Definition: PValues.cxx:28
PValues::PValues
PValues()
Definition: PValues.cxx:15