Skip to content

Random Notes

iwbnwif edited this page May 15, 2017 · 3 revisions

AnyInterpreter

A 'plugable' class that helps a dataset understand the data that it holds.

Members could include:

virtual double GetValue(const wxAny& data, InterpreterOptions options) const
{
    if (data.CheckType<int>())
        return data.As<int>();

    if (data.CheckType<double>())
        return data.As<double>();

    if (data.CheckType<wxDateTime>())
    {
        if (options == AnyInterpreter::DateAsTicks)
            return data.As<wxDateTime>().GetTicks();

        if (options == AnyInterpreter::DateAs)
            return data.As<wxDateTime>().GetJDN();
        // etc.
        wxFAIL_MSG("Unsupported wxDateTime option");
    }

   // etc.
   wxFAIL_MSG("Unsupported wxAny type");
}

virtual wxAny& GetMax(const wxAny& a, const wxAny& b) const
{
    wxASSERT_MSG(a.HasSameType(b), "Cannot compare dissimilar types");

    return GetValue(a) > GetValue(b) ? a : b;
}

virtual InterpretedTypeTrait GetTrait(const wxAny& data)
{
    if (data.CheckType<int>())
        return TypeTraitRatio;

    // etc. Traits are: Nominal, Ordinal, Interval, Ratio.

    // Provide a chance to catch errors before they lead to asserts later.
    return TypeUndefined;
}

TYPES OF DATA & MEASUREMENT SCALES: NOMINAL, ORDINAL, INTERVAL AND RATIO

http://www.mymarketresearchmethods.com/types-of-data-nominal-ordinal-interval-ratio/

Clone this wiki locally