CbmRoot
Loading...
Searching...
No Matches
PValues.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
6// Value container implementation file
7//
8// Just a small container class for user-defined values
9//
11
12
13#include "PValues.h"
14
15#include <iostream>
16
17#include <string.h>
18
19using namespace std;
20
21PValues::PValues() : TObject(), pointer {0}
22{
23 // pointer=0;
24}
25
26PValues::PValues(const PValues& p) : TObject(p), pointer {p.pointer}
27{
28 // pointer=p.pointer;
29
30 for (int i = 0; i < pointer; i++) {
31 array_id[i] = p.array_id[i];
32 array_val[i] = p.array_val[i];
33 }
34}
35
36bool PValues::SetValue(int id, double val)
37{
38
39 for (int i = 0; i < pointer; i++) {
40 if (array_id[i] == id) {
41 array_val[i] = val;
42 return kTRUE;
43 }
44 }
45 if (pointer == MAX_VALUES) { return kFALSE; }
46
47 array_val[pointer] = val;
48 array_id[pointer] = id;
49
50 pointer++;
51
52 return kTRUE;
53}
54
55bool PValues::GetValue(int id, double* val)
56{
57 for (int i = 0; i < pointer; i++) {
58 if (array_id[i] == id) {
59 *val = array_val[i];
60 return kTRUE;
61 }
62 }
63 return kFALSE;
64}
65
67{
68 if (!strcmp(st, "t")) return T_MATRIX;
69 if (!strcmp(st, "u")) return U_MATRIX;
70 if (!strcmp(st, "tu")) return TU_MATRIX;
71 return -1;
72}
73
74void PValues::Print(const Option_t*) const
75{
76 for (int i = 0; i < pointer; i++) {
77 cout << "Value #" << array_id[i] << " is: " << array_val[i] << endl;
78 }
79}
80
81
ClassImp(CbmConverterManager)
#define T_MATRIX
Definition PValues.h:14
#define MAX_VALUES
Definition PValues.h:12
#define U_MATRIX
Definition PValues.h:15
#define TU_MATRIX
Definition PValues.h:16
double array_val[MAX_VALUES]
Definition PValues.h:38
int array_id[MAX_VALUES]
Definition PValues.h:37
void Print(const Option_t *) const
Definition PValues.cxx:74
int StringToValueID(char *st)
Definition PValues.cxx:66
bool SetValue(int id, double val)
Definition PValues.cxx:36
int pointer
Definition PValues.h:40
bool GetValue(int id, double *val)
Definition PValues.cxx:55
PValues()
Definition PValues.cxx:21
Hash for CbmL1LinkKey.