TransformationResult.cpp
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "TransformationResult.h"
namespace TREPS
{
namespace Transformation
{
TransformationResultClass::TransformationResultClass(void) : app(NULL), exportMgr(NULL)
{
this->app = ApplicationClass::getInstance();
//create export manager to write transformation result file
this->exportMgr = new ExportManagerClass();
this->dstFields.clear();
this->dstData.clear();
}
TransformationResultClass::~TransformationResultClass(void)
{
if (this->exportMgr != NULL)
{
delete this->exportMgr;
this->exportMgr = NULL;
}
this->dstFields.clear();
this->dstData.clear();
}
DataRecordListClass *TransformationResultClass::getDstDataRecordList(void) const
{
return const_cast<DataRecordListClass *>(&this->dstData);
}
t_FieldList *TransformationResultClass::getDstFieldList(void) const
{
return const_cast<t_FieldList *>(&this->dstFields);
}
bool TransformationResultClass::init(t_TimeFormat timeFormat, const DataRecordListClass *srcData)
{
//reset result
this->dstFields.clear();
this->dstData.clear();
DataRecordClass *crtRecord = srcData->getFirstRecord();
while (crtRecord != NULL)
{
DataRecordClass *newRecord = this->dstData.addNew();
if (timeFormat != TF_NONE)
newRecord->setTime(crtRecord->getTime());
newRecord->setTag(crtRecord->getTag());
crtRecord = crtRecord->getNextRecord();
}
return true;
}
bool TransformationResultClass::addFieldVector(const char *fieldId, const DataRecordListClass *data,
const char *comp_1, const char *comp_2, const char *comp_3, const char *frame)
{
//add a vector as a field in result data
t_Field vecField = this->exportMgr->initNewFieldVector(fieldId, fieldId, FT_DOUBLE, frame);
return this->exportMgr->addFieldVector(&vecField, data, comp_1, comp_2, comp_3, &(this->dstFields), &(this->dstData));
}
void TransformationResultClass::clone(const t_FieldList *fields, const DataRecordListClass *data, const char *timeFieldId)
{
//clone data in result data
this->dstFields.clear();
this->dstData.clear();
for (t_FieldList::const_iterator field = fields->begin(); field != fields->end(); ++field)
{
// 9639 update starting index copy, escape all time fields
// if (/*((*field).type == FT_TIME) &&*/ ((*field).id.compare(timeFieldId) == 0))
if (/*((*field).type == FT_TIME) &&*/ ( atoi((*field).id.c_str()) <= atoi(timeFieldId) ))
continue;
this->dstFields.push_back((*field));
}
data->clone(&(this->dstData));
}
}
}