NANDRAD Data Model Library  Version 2.0
NANDRAD
NANDRAD_DataTable.h
1 /* The NANDRAD data model library.
2 
3  Copyright (c) 2012-today, Institut für Bauklimatik, TU Dresden, Germany
4 
5  Primary authors:
6  Andreas Nicolai <andreas.nicolai -[at]- tu-dresden.de>
7  Anne Paepcke <anne.paepcke -[at]- tu-dresden.de>
8 
9  This library is part of SIM-VICUS (https://github.com/ghorwin/SIM-VICUS)
10 
11  This library is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 */
21 
22 #ifndef NANDRAD_DataTableH
23 #define NANDRAD_DataTableH
24 
25 #include <map>
26 #include <vector>
27 #include <string>
28 
29 namespace NANDRAD {
30 
31 /*! A data member for a table with named columns. */
32 class DataTable {
33 public:
34 
35  /*! Inequility operator. */
36  bool operator!=(const DataTable & other) const {
37  return m_values != other.m_values;
38  }
39 
40  /*! Sets content of data table from encoded string.
41  Setting the following string "Col1:1 5 3;Col2:7 2 2" is equivalent to executing
42  the following code:
43  \code
44  m_values["Col1"] = std::vector<double>{1,5,3};
45  m_values["Col2"] = std::vector<double>{7,2,2};
46  \endcode
47  Throws an IBK::Exception, if number of rows in columns mismatches.
48 
49  \note It is possible to use , and a whitespace (space or tab) character as number separator.
50  */
51  void setEncodedString(const std::string & str);
52 
53  /*! Returns content of data table as encoded string using tab a value separator. */
54  std::string encodedString() const;
55 
56  /*! Convenience function that looks up a parameter data vector in the map and returns
57  a const reference to it.
58  Throws an IBK::Exception if the parameter name doesn't exist.
59  */
60  const std::vector<double> & valueVector(const std::string & parameterName) const;
61 
62 
63  /*! The actual data member. */
64  std::map<std::string, std::vector<double> > m_values;
65 };
66 
67 } // namespace NANDRAD
68 
69 #endif // NANDRAD_DataTableH
A data member for a table with named columns.
bool operator!=(const DataTable &other) const
Inequility operator.
const std::vector< double > & valueVector(const std::string &parameterName) const
Convenience function that looks up a parameter data vector in the map and returns a const reference t...
std::map< std::string, std::vector< double > > m_values
The actual data member.
void setEncodedString(const std::string &str)
Sets content of data table from encoded string.
std::string encodedString() const
Returns content of data table as encoded string using tab a value separator.
The namespace NANDRAD contains the data model classes that make up the NANDRAD solver input data...