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 <cstring>
16#include <iostream>
17
18using namespace std;
19
20PValues::PValues() : TObject(), pointer {0}
21{
22 // pointer=0;
23}
24
25PValues::PValues(const PValues& p) : TObject(p), pointer {p.pointer}
26{
27 // pointer=p.pointer;
28
29 for (int i = 0; i < pointer; i++) {
30 array_id[i] = p.array_id[i];
31 array_val[i] = p.array_val[i];
32 }
33}
34
35bool PValues::SetValue(int id, double val)
36{
37
38 for (int i = 0; i < pointer; i++) {
39 if (array_id[i] == id) {
40 array_val[i] = val;
41 return kTRUE;
42 }
43 }
44 if (pointer == MAX_VALUES) { return kFALSE; }
45
46 array_val[pointer] = val;
47 array_id[pointer] = id;
48
49 pointer++;
50
51 return kTRUE;
52}
53
54bool PValues::GetValue(int id, double* val)
55{
56 for (int i = 0; i < pointer; i++) {
57 if (array_id[i] == id) {
58 *val = array_val[i];
59 return kTRUE;
60 }
61 }
62 return kFALSE;
63}
64
66{
67 if (!strcmp(st, "t")) return T_MATRIX;
68 if (!strcmp(st, "u")) return U_MATRIX;
69 if (!strcmp(st, "tu")) return TU_MATRIX;
70 return -1;
71}
72
73void PValues::Print(const Option_t*) const
74{
75 for (int i = 0; i < pointer; i++) {
76 cout << "Value #" << array_id[i] << " is: " << array_val[i] << endl;
77 }
78}
79
80
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:73
int StringToValueID(char *st)
Definition PValues.cxx:65
bool SetValue(int id, double val)
Definition PValues.cxx:35
int pointer
Definition PValues.h:40
bool GetValue(int id, double *val)
Definition PValues.cxx:54
PValues()
Definition PValues.cxx:20
Hash for CbmL1LinkKey.