BCDataPoint.h
1 #ifndef __BCDATAPOINT__H
2 #define __BCDATAPOINT__H
3 
17 /*
18  * Copyright (C) 2007-2018, the BAT core developer team
19  * All rights reserved.
20  *
21  * For the licensing terms see doc/COPYING.
22  * For documentation see http://mpp.mpg.de/bat
23  */
24 
25 // ---------------------------------------------------------
26 
27 #include <string>
28 #include <vector>
29 
30 #include "BCLog.h"
31 
32 // ---------------------------------------------------------
33 
35 {
36 public:
37 
44  BCDataPoint(int nvariables = 0);
45 
49  BCDataPoint(const std::vector<double>& x);
57  double& operator[](unsigned index)
58  { return fData[index]; }
59 
62  const double& operator[](unsigned index) const
63  { return fData[index]; }
64 
74  double GetValue(unsigned index) const
75  { return fData.at(index); }
76 
79  std::vector<double>& GetValues()
80  { return fData; };
81 
84  const std::vector<double>& GetValues() const
85  { return fData; };
86 
89  unsigned int GetNValues() const
90  { return fData.size(); };
91 
101  void SetValue(unsigned index, double value)
102  { fData.at(index) = value; }
103 
107  void SetValues(const std::vector<double>& values);
108 
114  void SetNValues(unsigned n, double val = 0.)
115  { fData.resize(n, val); }
116 
125  void PrintSummary(void (*output)(const std::string&) = BCLog::OutSummary) const;
126 
129 private:
130 
133  std::vector<double> fData;
134 
135 };
136 
137 // ---------------------------------------------------------
138 
139 #endif
A class representing a data point.
Definition: BCDataPoint.h:34
void SetNValues(unsigned n, double val=0.)
Set the number of variables.
Definition: BCDataPoint.h:114
unsigned int GetNValues() const
Returns the number of values.
Definition: BCDataPoint.h:89
void PrintSummary(void(*output)(const std::string &)=BCLog::OutSummary) const
Print summary of data point to the string handler.
Definition: BCDataPoint.cxx:44
void SetValues(const std::vector< double > &values)
Set the values of all variables.
Definition: BCDataPoint.cxx:30
const std::vector< double > & GetValues() const
Definition: BCDataPoint.h:84
double GetValue(unsigned index) const
Safer access, but slower.
Definition: BCDataPoint.h:74
double & operator[](unsigned index)
Raw and fast access.
Definition: BCDataPoint.h:57
const double & operator[](unsigned index) const
Raw and fast access.
Definition: BCDataPoint.h:62
void SetValue(unsigned index, double value)
Safer, but slower, value setting of a variable.
Definition: BCDataPoint.h:101
std::vector< double > & GetValues()
Definition: BCDataPoint.h:79
BCDataPoint(int nvariables=0)
A constructor.
Definition: BCDataPoint.cxx:18