C API Documentation
rrRoadRunnerData.h
1 #ifndef rrRoadRunnerDataH
2 #define rrRoadRunnerDataH
3 
4 #ifdef _MSC_VER
5 #pragma warning(disable: 26812)
6 #pragma warning(disable: 26451)
7 #endif
8 #include "rr-libstruct/lsMatrix.h"
9 #ifdef _MSC_VER
10 #pragma warning(disable: 26812)
11 #pragma warning(disable: 26451)
12 #endif
13 
14 #include "rrExporter.h"
15 
16 #include <string>
17 #include <vector>
18 #include <fstream>
19 #include <sstream>
20 
21 namespace rr
22 {
23 
24 using namespace ls;
25 using std::ofstream;
26 using std::stringstream;
27 
28 class RoadRunner;
29 
35 class RR_DECLSPEC RoadRunnerData
36 {
37 
38 public:
39  RoadRunnerData(const int& rSize = 0, const int& cSize = 0);
40 
41  RoadRunnerData(const std::vector<std::string>& colNames,
42  const DoubleMatrix& data);
43 
44  RoadRunnerData(const RoadRunner* rr);
45 
46  ~RoadRunnerData();
47 
48  void allocate(const size_t& cSize, const size_t& rSize);
49 
50  void allocateWeights();
51 
52  bool hasWeights() const;
53 
54  const std::vector<std::string>& getColumnNames() const;
55  std::string getColumnName(const int col) const;
56  std::string getColumnNamesAsString() const;
57  void setColumnNames(const std::vector<std::string>& colNames);
58  std::ptrdiff_t getColumnIndex(const std::string& colName) const;
59  void setTimeDataPrecision(const int& prec);
60  void setDataPrecision(const int& prec);
61  void reSize(int rows, int cols);
62 
63  void clear();
64 
65  int rSize() const;
66 
67  int cSize() const;
68 
69  void setData(const DoubleMatrix& theData);
70 
71  bool loadSimpleFormat(const std::string& fileName);
72 
73  bool writeTo(const std::string& fileName) const;
74 
75  bool readFrom(const std::string& fileName);
76 
77  bool check() const;
78 
79  bool structuredResult;
80 
81  RR_DECLSPEC
82  friend std::ostream& operator <<(std::ostream& ss, const RoadRunnerData& data);
83 
84  RR_DECLSPEC
85  friend std::istream& operator >>(std::istream& ss, RoadRunnerData& data);
86 
87  double& operator()(const unsigned& row, const unsigned& col);
88 
89  double operator()(const unsigned& row, const unsigned& col) const;
90 
91  double getDataElement(int row, int col);
92 
93  void setDataElement(int row, int col, double value);
94 
95  RoadRunnerData& operator=(const RoadRunnerData& rhs);
96 
97  double getWeight(int row, int col) const;
98 
99  void setWeight(int row, int col, double val);
100 
101  void setName(const std::string& name);
102 
103  std::string getName() const;
104 
105  std::pair<int, int> dimension() const;
106 
107  bool append(const RoadRunnerData& data);
108 
109  double getTimeStart() const;
110 
111  double getTimeEnd() const;
112 
113  const DoubleMatrix& getData() const;
114 
115  const DoubleMatrix& getWeights() const;
116 
117 
118 protected:
119 
123  std::vector<std::string> mColumnNames;
124 
128  DoubleMatrix mTheData;
129 
133  DoubleMatrix mWeights;
134 
139 
143  int mDataPrecision; //The precision when saved to file
144 
149  std::string mName; //For debugging purposes mainly..
150 };
151 
152 }
153 
154 #endif
Definition: rrRoadRunnerData.h:36
int mDataPrecision
Integer setting the precision of 'data' double numbers when writing to file.
Definition: rrRoadRunnerData.h:143
DoubleMatrix mWeights
Container holding the data weights.
Definition: rrRoadRunnerData.h:133
std::string mName
String holding the 'name' of the object.
Definition: rrRoadRunnerData.h:149
int mTimePrecision
Integer setting the precision of 'time' double numbers when writing to file.
Definition: rrRoadRunnerData.h:138
DoubleMatrix mTheData
Container holding the actual data.
Definition: rrRoadRunnerData.h:128
std::vector< std::string > mColumnNames
Container holding column names.
Definition: rrRoadRunnerData.h:123
Definition: rrRoadRunner.h:47
C_DECL_SPEC bool rrcCallConv getTimeStart(RRHandle handle, double *timeStart)
Get the value of the current time start.
C_DECL_SPEC bool rrcCallConv getTimeEnd(RRHandle handle, double *timeEnd)
Get the value of the current time end.