33 using classdesc::shared_ptr;
41 typedef std::vector<std::vector<string>>
Data;
45 vector<AssetClass> m_assetClass{noAssetClass, asset, liability, equity};
48 static void markEdited();
49 void _resize(
unsigned rows,
unsigned cols) {
51 for (std::size_t i=0; i<data.size(); ++i) data[i].resize(cols);
52 data.resize(rows, vector<string>(cols));
53 m_assetClass.resize(cols, noAssetClass);
66 cell(1,0)=initialConditions;
78 const vector<AssetClass>&
_assetClass()
const {
return m_assetClass;}
79 AssetClass _assetClass(std::size_t col)
const;
80 AssetClass _assetClass(std::size_t col, AssetClass cls);
84 bool singleEquity()
const;
96 return doubleEntryCompliant &&
97 (_assetClass(col)==liability || _assetClass(col)==equity);
106 string assetClass(ecolab::TCL_args args);
109 bool initialConditionRow(
unsigned row)
const;
112 bool singularRow(
unsigned row,
unsigned col);
114 std::size_t
rows()
const {
return data.size();}
115 std::size_t
cols()
const {
return data.empty()? 0: data[0].size();}
117 void clear() {data.clear(); m_assetClass.clear(); markEdited();}
118 void resize(
unsigned rows,
unsigned cols){_resize(rows,cols); markEdited();}
128 void insertRow(
unsigned row);
131 void deleteRow(
unsigned row) {data.erase(data.begin()+row);}
133 void insertCol(
unsigned col);
135 void deleteCol(
unsigned col);
138 void moveRow(
int row,
int n);
140 void moveCol(
int col,
int n);
142 void dimension(
unsigned rows,
unsigned cols) {clear(); resize(rows,cols);}
144 string&
cell(
unsigned row,
unsigned col) {
145 if (row>=rows() || col>=cols())
146 _resize(row+1, col+1);
147 if (data[row].size()<=col) data[row].resize(cols());
148 return data[row][col];
150 const string&
cell(
unsigned row,
unsigned col)
const {
151 if (row>=data.size() || col>=data[row].size())
152 throw std::out_of_range(
"Godley table index error");
153 return data[row][col];
156 {
return row>=0 && std::size_t(row)<rows() && col>=0 && std::size_t(col)<cols();}
157 string getCell(
unsigned row,
unsigned col)
const {
158 if (row<rows() && col<cols())
159 return cell(row,col);
163 void setCell(
unsigned row,
unsigned col,
const string& data) {
168 void balanceEquity(
int col);
171 std::vector<std::string> getColumnVariables()
const;
174 std::vector<std::string> getVariables()
const;
180 std::vector<std::string> getColumn(
unsigned col)
const;
183 void setDEmode(
bool doubleEntryCompliant);
185 std::map<std::string,double> rowSumAsMap(
int row)
const;
186 static std::string stringify(
const std::map<std::string,double>&);
189 std::string
rowSum(
int row)
const {
return stringify(rowSumAsMap(row));}
195 void exportToCSV(
const std::string& filename)
const;
198 void orderAssetClasses();
201 void rename(
const std::string& from,
const std::string& to);
203 void renameFlows(
const std::string& from,
const std::string& to);
205 void renameStock(
const std::string& from,
const std::string& to);
210 #include "godleyTable.cd" 211 #include "godleyTable.xcd"
const Data & getData() const
accessor for schema access
bool cellInTable(int row, int col) const
void exportToLaTeX(std::ostream &f, const GodleyTable &g)
vector< AssetClass > m_assetClass
class of each column (used in DE compliant mode)
void deleteRow(unsigned row)
delete row at row
std::string rowSum(int row) const
return the symbolic sum across a row
bool doubleEntryCompliant
string & cell(unsigned row, unsigned col)
string getCell(unsigned row, unsigned col) const
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
void resize(unsigned rows, unsigned cols)
void setCell(unsigned row, unsigned col, const string &data)
#define CLASSDESC_ACCESS(type)
const string & cell(unsigned row, unsigned col) const
GodleyAssetClass::AssetClass AssetClass
const vector< AssetClass > & _assetClass() const
class of each column (used in DE compliant mode)
void dimension(unsigned rows, unsigned cols)
void _resize(unsigned rows, unsigned cols)
std::string savedText
save text in currently highlighted column heading for renaming all variable instances and to enable u...
void exportToCSV(std::ostream &s, const GodleyTable &g)
static const char * initialConditions
bool signConventionReversed(int col) const
The usual mathematical sign convention is reversed in double entry book keeping conventions if the as...
std::vector< std::vector< string > > Data
bool operator==(const GodleyTable &other) const