Commit 4d8da253 authored by Oliver Bock's avatar Oliver Bock
Browse files

- Fixed TABLEDATA processing

- Improved memory management (QPointer)
- Use namespaces properly

git-svn-id: https://svn.origo.ethz.ch/fidelity@20 53d1999f-d1a8-4366-aa61-588fded17473
parent 1a01403d
......@@ -20,12 +20,16 @@
#include "datastorage.h"
Fidelity::Plugin::Component::DataStorage::DataStorage() : AComponent()
namespace Fidelity {
namespace Plugin {
namespace Component {
DataStorage::DataStorage() : AComponent()
{
initAttributes();
}
Fidelity::Plugin::Component::DataStorage::~DataStorage()
DataStorage::~DataStorage()
{
delete m_OutputPath;
delete m_Channel1Label;
......@@ -43,7 +47,7 @@ Fidelity::Plugin::Component::DataStorage::~DataStorage()
delete m_DataStorage2;
}
void Fidelity::Plugin::Component::DataStorage::initAttributes()
void DataStorage::initAttributes()
{
// Set the global attributes
......@@ -171,12 +175,12 @@ void Fidelity::Plugin::Component::DataStorage::initAttributes()
m_DataStorage2 = new QVector<double>;
}
IComponent* Fidelity::Plugin::Component::DataStorage::createInstance() const
IComponent* DataStorage::createInstance() const
{
return(new DataStorage());
}
void Fidelity::Plugin::Component::DataStorage::init(const long& timeStepAmount, const double& timeStepLength, const double& defaultFrequency, const double& speedOfLight)
void DataStorage::init(const long& timeStepAmount, const double& timeStepLength, const double& defaultFrequency, const double& speedOfLight)
{
Q_UNUSED(timeStepLength)
Q_UNUSED(defaultFrequency)
......@@ -204,10 +208,10 @@ void Fidelity::Plugin::Component::DataStorage::init(const long& timeStepAmount,
m_ShowPlot = settings.value("showPlotPreview",true).toBool();
}
void Fidelity::Plugin::Component::DataStorage::pre()
void DataStorage::pre()
{}
void Fidelity::Plugin::Component::DataStorage::step(const long& iteration, const double& t)
void DataStorage::step(const long& iteration, const double& t)
{
const bool channel2Enabled = m_EnableChannel2->Value();
......@@ -220,13 +224,13 @@ void Fidelity::Plugin::Component::DataStorage::step(const long& iteration, const
}
}
void Fidelity::Plugin::Component::DataStorage::post()
void DataStorage::post()
{}
void Fidelity::Plugin::Component::DataStorage::finalise()
void DataStorage::finalise()
{
const bool channel2Enabled = m_EnableChannel2->Value();
VOTableRoot xml;
VOResource resource;
VOTable table;
......@@ -237,14 +241,14 @@ void Fidelity::Plugin::Component::DataStorage::finalise()
VOBinary binary;
VOStream stream;
VOTableData tableData;
VOTR row;
VOTD col1;
VOTD col2;
VOTD col3;
QPointer<VOTR> row;
QPointer<VOTD> col1;
QPointer<VOTD> col2;
QPointer<VOTD> col3;
QString path = m_OutputPath->Value();
path = path.endsWith(QDir::separator()) ? path : path += QDir::separator();
//TODO: file names should use the FSX file name
// TODO: file names should use the FSX file name
QFile fileXml(path + m_Label + ".fdx");
QFile fileData(path + m_Label + ".fdb");
......@@ -305,17 +309,22 @@ void Fidelity::Plugin::Component::DataStorage::finalise()
data.setTableData(&tableData);
for (unsigned long i = 0;i < size; i++) {
col1.setContent(QString::number(m_TimeStorage->at(i), 'E', 8));
col2.setContent(QString::number(m_DataStorage1->at(i), 'E', 8));
row.TDList()->append(&col1);
row.TDList()->append(&col2);
QPointer<VOTR> row = new VOTR();
QPointer<VOTD> col1 = new VOTD();
QPointer<VOTD> col2 = new VOTD();
QPointer<VOTD> col3 = new VOTD();
col1->setContent(QString::number(m_TimeStorage->at(i), 'E', 8));
col2->setContent(QString::number(m_DataStorage1->at(i), 'E', 8));
row->TDList()->append(col1);
row->TDList()->append(col2);
if(channel2Enabled) {
col3.setContent(QString::number(m_DataStorage2->at(i), 'E', 8));
row.TDList()->append(&col3);
col3->setContent(QString::number(m_DataStorage2->at(i), 'E', 8));
row->TDList()->append(col3);
}
(*tableData.TRList())[i] = &row;
(*tableData.TRList())[i] = row;
}
}
else {
......@@ -354,8 +363,13 @@ void Fidelity::Plugin::Component::DataStorage::finalise()
out.setCodec("UTF-8");
out << doc->toString();
out.flush();
fileXml.flush();
fileXml.close();
// FIXME: we need to improve the list handling within votable before delete will work!
// Hints: QPointer / delete list entries in destructor
// delete doc;
}
// Plot the results if requested by the user
......@@ -380,12 +394,14 @@ void Fidelity::Plugin::Component::DataStorage::finalise()
}
}
QDomDocument Fidelity::Plugin::Component::DataStorage::xmlSchema() const
QDomDocument DataStorage::xmlSchema() const
{
return(QDomDocument());
}
void Fidelity::Plugin::Component::DataStorage::optimize()
void DataStorage::optimize()
{}
}}}
Q_EXPORT_PLUGIN2(datastorage, Fidelity::Plugin::Component::DataStorage);
......@@ -26,6 +26,7 @@
#include <QFile>
#include <QTextStream>
#include <QDataStream>
#include <QPointer>
#include <complex>
......@@ -84,7 +85,7 @@ namespace Fidelity {
*/
class DataStorage : public AComponent
{
Q_OBJECT;
Q_OBJECT
Q_INTERFACES(Fidelity::Plugin::Base::IPlugin Fidelity::Plugin::Component::Base::IComponent);
public:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment