Bug #1358

GModelSky does not write tscalc attribute

Added by Mayer Michael about 10 years ago. Updated about 10 years ago.

Status:ClosedStart date:11/07/2014
Priority:NormalDue date:
Assigned To:Mayer Michael% Done:

100%

Category:-
Target version:00-09-00
Duration:

Description

When saving an instance of type GModels to an XML file via GModels::save(), each model is written to the XML string using GModel::write(GXml& xml).
If a model container is loaded and saved again, the tscalc parameter which steers the TS computation is not written to the new file.
We might want to add the following piece of code around line 763 in GModelSky.cpp:

if (tscalc()) {
    src->attribute("tscalc","1");
}


Recurrence

No recurrence.

History

#1 Updated by Mayer Michael about 10 years ago

  • Target version set to 1.0.0

#2 Updated by Knödlseder Jürgen about 10 years ago

  • Target version changed from 1.0.0 to 00-09-00

This looks like a reasonable workaround, although not 100% satisfactory as tscalc="0" attributes would be dropped which may disturb the user. For the TS value we have a specific m_has_ts flag and it would be cleaner to add a m_has_tscalc flag that basically serves for bookkeeping. It would be sufficient to modify

inline
void GModel::tscalc(const bool& tscalc)
{
    m_tscalc = tscalc;
    m_has_tscalc = true;
    return;
}

and then add
    // If available, set tscalc attribute
    if (m_has_tscalc) {
        std::string tscalc = tscalc() ? "1" : "0";
        src->attribute("tscalc", tscalc);
    }

and make sure that m_has_tscalc is properly initialized and copied in init_members and copy_members. How does this sound?

#3 Updated by Mayer Michael about 10 years ago

I agree that this solution is much cleaner. Code is available on branch 1358-add-has_tscalc-to-GModel

#4 Updated by Mayer Michael about 10 years ago

  • Status changed from New to Pull request

Do we need to add this functionality also to all derived classes of GModelData?

#5 Updated by Knödlseder Jürgen about 10 years ago

  • Status changed from Pull request to Closed
  • Assigned To set to Mayer Michael
  • % Done changed from 0 to 100

Merged into devel branch.

Concerning GModelData, as we do not foresee TS calculation for those I would propose not to add this to GModelData.

Also available in: Atom PDF