Subversion Repositories public iLand

Rev

Rev 178 | Rev 181 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1
 
178 werner 2
/** @class OutputManager
3
   Global container that handles data output.
4
 
5
  */
6
 
173 werner 7
#include "global.h"
8
#include "outputmanager.h"
9
#include <QtCore>
10
 
11
// tree outputs
12
#include "treeout.h"
179 werner 13
#include "standout.h"
173 werner 14
 
178 werner 15
 
16
 
173 werner 17
OutputManager::OutputManager()
18
{
19
    // add all the outputs
20
    mOutputs.append(new TreeOut);
179 werner 21
    mOutputs.append(new StandOut);
173 werner 22
}
23
 
24
OutputManager::~OutputManager()
25
{
26
    qDeleteAll(mOutputs);
27
}
28
 
29
void OutputManager::setup()
30
{
31
    XmlHelper &xml = const_cast<XmlHelper&>(GlobalSettings::instance()->settings());
32
    QString nodepath;
33
    foreach(Output *o, mOutputs) {
176 werner 34
        nodepath = QString("output.%1").arg(o->tableName());
173 werner 35
        xml.setCurrentNode(nodepath);
36
        qDebug() << "setup of output" << o->name();
37
        o->setup();
176 werner 38
        o->open();
173 werner 39
    }
40
}
176 werner 41
 
42
Output *OutputManager::find(const QString& tableName)
43
{
44
    foreach(Output* p,mOutputs)
45
        if (p->tableName()==tableName)
46
            return p;
47
    return NULL;
48
}
49
 
50
bool OutputManager::execute(const QString& tableName)
51
{
52
    Output *p = find(tableName);
53
    if (p) {
177 werner 54
        p->startTransaction();
176 werner 55
        p->exec();
177 werner 56
        p->endTransaction();
176 werner 57
        return true;
58
    }
59
    qDebug() << "output" << tableName << "not found!";
60
    return false; // no output found
61
}