iLand
Public Member Functions | Protected Member Functions | List of all members
Output Class Reference

The Output class abstracts output data (database, textbased, ...). More...

#include <output.h>

Inheritance diagram for Output:
ABE::ABEStandDetailsOut ABE::ABEStandOut ABE::ABEStandRemovalOut ABE::UnitOut BITE::BiteCellOutput BITE::BiteOutput BarkBeetleOut CarbonFlowOut CarbonOut DevStageOut DynamicStandOut EcoVizOut FireOut LandscapeOut LandscapeRemovedOut ManagementOut ProductionOut SVDGPPOut SVDIndicatorOut SVDStateOut SVDUniqueStateOut SaplingDetailsOut SaplingOut SoilInputOut StandDeadOut StandOut TreeOut TreeRemovedOut WaterOut WindOut

Public Member Functions

 Output ()
 ctor. Override in derived class to craete columns, etc. More...
 
virtual ~Output ()
 
virtual void setup ()
 setup() is called during project setup and can be ovveridden for specific setup More...
 
void setMode (OutputMode mode)
 
void open ()
 open output connection (create actual db connection, ...) More...
 
bool isOpen () const
 returns true if output is open, i.e. has a open database connection More...
 
void close ()
 shut down the connection. More...
 
bool isEnabled () const
 returns true if output is enabled, i.e. is "turned on" More...
 
void setEnabled (const bool enabled)
 
bool isRowEmpty () const
 returns true if the buffer of the current row is empty More...
 
virtual void exec ()
 main function that executes the output More...
 
const QList< OutputColumngetColumns () const
 
const QString name () const
 descriptive name of the ouptut More...
 
const QString description () const
 description of output More...
 
const QString tableName () const
 internal output name (no spaces allowed) More...
 
QString wikiFormat () const
 return output description in a (tiki)-wiki format More...
 
Outputoperator<< (const double &value)
 
Outputoperator<< (const int value)
 
Outputoperator<< (const QString &value)
 

Protected Member Functions

void setName (const QString &name, const QString tableName)
 
void setDescription (const QString &description)
 
QList< OutputColumn > & columns ()
 
int currentYear () const
 
const XmlHelpersettings () const
 access XML settings (see class description) More...
 
void writeRow ()
 saves the current row/line of data to database/file. Must be called for each row. More...
 
void singleThreadedWriteRow ()
 writeRow() protected by a mutex (if there is a chance that two outputs write at the same time) More...
 
void add (const double &value)
 
void add (const double &value1, const double &value2)
 
void add (const double &value1, const double &value2, const double &value3)
 
void add (const double &value1, const double &value2, const double &value3, const double &value4)
 
void add (const double &value1, const double &value2, const double &value3, const double &value4, const double value5)
 
void add (const int intValue)
 
void add (const QString &stringValue)
 
bool clearColumnsAfter (QString find_name)
 delete all columns after the column 'find_name'. Return true if columns were removed. More...
 
void truncateTable ()
 delete all data from the table More...
 

Detailed Description

The Output class abstracts output data (database, textbased, ...).

To create a new output, create a class derived from Output and perform the following steps:

Example
// (1) Overwrite constructor and set name, description and columns
{
setName("Tree Output", "tree");
setDescription("Output of indivdual trees.");
columns() << OutputColumn("id", "id of the tree", OutInteger)
<< OutputColumn("name", "tree species name", OutString)
<< OutputColumn("v1", "a double value", OutDouble);
}
// (2) optionally: some special settings (here: filter)
{
QString filter = settings().value(".filter","");
if (filter!="")
mFilter = QSharedPointer<Expression>(new Expression(filter));
}
// (3) the execution
{
while (Tree *t=at.next()) {
if (mFilter && !mFilter->execute()) // skip if filter present
continue;
*this << t->id() << t->species()->id() << t->dbh(); // stream operators
writeRow(); // executes DB insert
}
}
// in outputmanager.cpp:
{
...
mOutputs.append(new TreeOut); // add the output
...
}
Definition: model.h:203
An expression engine for mathematical expressions provided as strings.
Definition: expression.h:29
static GlobalSettings * instance()
Definition: globalsettings.h:51
Definition: output.h:36
QList< OutputColumn > & columns()
Definition: output.h:88
void setDescription(const QString &description)
Definition: output.h:86
const XmlHelper & settings() const
access XML settings (see class description)
Definition: output.h:90
void writeRow()
saves the current row/line of data to database/file. Must be called for each row.
Definition: output.cpp:185
void setName(const QString &name, const QString tableName)
Definition: output.h:85
OutputManager()
create all outputs
Definition: outputmanager.cpp:51
A tree is the basic simulation entity of iLand and represents a single tree.
Definition: tree.h:44
Definition: treeout.h:28
virtual void exec()
main function that executes the output
Definition: treeout.cpp:68
TreeOut()
Definition: treeout.cpp:28
virtual void setup()
setup() is called during project setup and can be ovveridden for specific setup
Definition: treeout.cpp:59
QString value(const QString &path, const QString &defaultValue="") const
retrieve value (as string) from node path.
Definition: xmlhelper.cpp:129
@ OutString
Definition: output.h:29
@ OutInteger
Definition: output.h:29
@ OutDouble
Definition: output.h:29

Constructor & Destructor Documentation

◆ Output()

Output::Output ( )

ctor. Override in derived class to craete columns, etc.

◆ ~Output()

Output::~Output ( )
virtual

Member Function Documentation

◆ add() [1/7]

void Output::add ( const double &  value)
inlineprotected

◆ add() [2/7]

void Output::add ( const double &  value1,
const double &  value2 
)
inlineprotected

◆ add() [3/7]

void Output::add ( const double &  value1,
const double &  value2,
const double &  value3 
)
inlineprotected

◆ add() [4/7]

void Output::add ( const double &  value1,
const double &  value2,
const double &  value3,
const double &  value4 
)
inlineprotected

◆ add() [5/7]

void Output::add ( const double &  value1,
const double &  value2,
const double &  value3,
const double &  value4,
const double  value5 
)
inlineprotected

◆ add() [6/7]

void Output::add ( const int  intValue)
inlineprotected

◆ add() [7/7]

void Output::add ( const QString &  stringValue)
inlineprotected

◆ clearColumnsAfter()

bool Output::clearColumnsAfter ( QString  find_name)
protected

delete all columns after the column 'find_name'. Return true if columns were removed.

delete columns that were added after the column 'find_name'

◆ close()

void Output::close ( )

shut down the connection.

◆ columns()

QList< OutputColumn > & Output::columns ( )
inlineprotected

◆ currentYear()

int Output::currentYear ( ) const
inlineprotected

◆ description()

const QString Output::description ( ) const
inline

description of output

◆ exec()

void Output::exec ( )
virtual

◆ getColumns()

const QList< OutputColumn > Output::getColumns ( ) const
inline

◆ isEnabled()

bool Output::isEnabled ( ) const
inline

returns true if output is enabled, i.e. is "turned on"

◆ isOpen()

bool Output::isOpen ( ) const
inline

returns true if output is open, i.e. has a open database connection

◆ isRowEmpty()

bool Output::isRowEmpty ( ) const
inline

returns true if the buffer of the current row is empty

◆ name()

const QString Output::name ( ) const
inline

descriptive name of the ouptut

◆ open()

void Output::open ( )

open output connection (create actual db connection, ...)

◆ operator<<() [1/3]

Output & Output::operator<< ( const double &  value)
inline

◆ operator<<() [2/3]

Output & Output::operator<< ( const int  value)
inline

◆ operator<<() [3/3]

Output & Output::operator<< ( const QString &  value)
inline

◆ setDescription()

void Output::setDescription ( const QString &  description)
inlineprotected

◆ setEnabled()

void Output::setEnabled ( const bool  enabled)
inline

◆ setMode()

void Output::setMode ( OutputMode  mode)
inline

◆ setName()

void Output::setName ( const QString &  name,
const QString  tableName 
)
inlineprotected

◆ settings()

const XmlHelper & Output::settings ( ) const
inlineprotected

access XML settings (see class description)

◆ setup()

void Output::setup ( )
virtual

◆ singleThreadedWriteRow()

void Output::singleThreadedWriteRow ( )
protected

writeRow() protected by a mutex (if there is a chance that two outputs write at the same time)

◆ tableName()

const QString Output::tableName ( ) const
inline

internal output name (no spaces allowed)

◆ truncateTable()

void Output::truncateTable ( )
protected

delete all data from the table

◆ wikiFormat()

QString Output::wikiFormat ( ) const

return output description in a (tiki)-wiki format

◆ writeRow()

void Output::writeRow ( )
protected

saves the current row/line of data to database/file. Must be called for each row.


The documentation for this class was generated from the following files: