Changeset 743


Ignore:
Timestamp:
02/26/18 19:57:44 (6 years ago)
Author:
Maciej Komosinski
Message:

Introduced different function names in C++ instead of overloading (with the same number of arguments) so that javascript is able to discriminate them

Location:
cpp/frams
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f1/conv_f1.cpp

    r732 r743  
    454454        else if ((i = last_f1_neuro->extraProperties().findIdn(begin, colon - begin)) >= 0)
    455455        {
    456                 last_f1_neuro->extraProperties().set(i, colon + 1);
     456                last_f1_neuro->extraProperties().setFromString(i, colon + 1);
    457457        }
    458458        else if (isupper(begin[0]) || strchr("*|@", begin[0]))
  • cpp/frams/genetics/oper_fx.cpp

    r673 r743  
    5050        {
    5151                double _mn = 0, _mx = 1, _def = 0.5;
    52                 defined = p->getMinMax(i, _mn, _mx, _def);
     52                defined = p->getMinMaxDouble(i, _mn, _mx, _def);
    5353                if (defined == 1) _mx = _mn + 1.0;
    5454                if (_mx < _mn && defined == 3) _mn = _mx = _def; //only default was defined, let's assume min=max=default
     
    5959        {
    6060                paInt _mn = 0, _mx = 1, _def = 0;
    61                 defined = p->getMinMax(i, _mn, _mx, _def);
     61                defined = p->getMinMaxInt(i, _mn, _mx, _def);
    6262                if (defined == 1) _mx = _mn + 1;
    6363                if (_mx < _mn && defined == 3) _mn = _mx = _def; //only default was defined, let's assume min=max=default
  • cpp/frams/model/modelparts.cpp

    r726 r743  
    180180                        if (i) t += "\n";
    181181                        t += "   "; t += p.name(i); t += " ("; t += p.id(i); t += ") ";
    182                         t += p.describeType(i);
     182                        t += p.friendlyTypeDescr(i);
    183183                        if (h = p.help(i)) if (*h) { t += " - "; t += h; }
    184184                }
  • cpp/frams/param/param.cpp

    r732 r743  
    7474}
    7575
    76 int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def)
    77 {
    78         return getMinMax(type(prop), minumum, maximum, def);
    79 }
    80 
    81 int ParamInterface::getMinMax(int prop, double& minumum, double& maximum, double& def)
    82 {
    83         return getMinMax(type(prop), minumum, maximum, def);
    84 }
    85 
    86 int ParamInterface::getMinMax(int prop, int& minumum, int& maximum, SString& def)
    87 {
    88         return getMinMax(type(prop), minumum, maximum, def);
    89 }
    90 
    91 int ParamInterface::getMinMax(const char* t, paInt& minumum, paInt& maximum, paInt &def)
     76int ParamInterface::getMinMaxInt(int prop, paInt& minumum, paInt& maximum, paInt &def)
     77{
     78        return getMinMaxIntFromTypeDef(type(prop), minumum, maximum, def);
     79}
     80
     81int ParamInterface::getMinMaxDouble(int prop, double& minumum, double& maximum, double& def)
     82{
     83        return getMinMaxDoubleFromTypeDef(type(prop), minumum, maximum, def);
     84}
     85
     86int ParamInterface::getMinMaxString(int prop, int& minumum, int& maximum, SString& def)
     87{
     88        return getMinMaxStringFromTypeDef(type(prop), minumum, maximum, def);
     89}
     90
     91int ParamInterface::getMinMaxIntFromTypeDef(const char* t, paInt& minumum, paInt& maximum, paInt &def)
    9292{
    9393        while (*t) if (*t == ' ') break; else t++;
     
    9595}
    9696
    97 int ParamInterface::getMinMax(const char* t, double& minumum, double& maximum, double& def)
     97int ParamInterface::getMinMaxDoubleFromTypeDef(const char* t, double& minumum, double& maximum, double& def)
    9898{
    9999        while (*t) if (*t == ' ') break; else t++;
     
    101101}
    102102
    103 int ParamInterface::getMinMax(const char* t, int& minumum, int& maximum, SString& def)
     103int ParamInterface::getMinMaxStringFromTypeDef(const char* t, int& minumum, int& maximum, SString& def)
    104104{
    105105        while (*t) if (*t == ' ') break; else t++;
     
    154154        {
    155155                double mn = 0, mx = 0, def = 0;
    156                 if (getMinMax(t, mn, mx, def) < 3) def = mn;
     156                if (getMinMaxDoubleFromTypeDef(t, mn, mx, def) < 3) def = mn;
    157157                setDouble(i, def);
    158158        }
     
    161161        {
    162162                paInt mn = 0, mx = 0, def = 0;
    163                 if (getMinMax(t, mn, mx, def) < 3) def = mn;
     163                if (getMinMaxIntFromTypeDef(t, mn, mx, def) < 3) def = mn;
    164164                setInt(i, def);
    165165        }
     
    168168        {
    169169                int mn, mx; SString def;
    170                 getMinMax(t, mn, mx, def);
     170                getMinMaxStringFromTypeDef(t, mn, mx, def);
    171171                if (*t == 's')
    172172                        setString(i, def);
     
    191191        {
    192192                double mn = 0, mx = 0, def = 0;
    193                 getMinMax(t, mn, mx, def);
     193                getMinMaxDoubleFromTypeDef(t, mn, mx, def);
    194194                setDouble(i, mn);
    195195        }
     
    198198        {
    199199                paInt mn = 0, mx = 0, def = 0;
    200                 getMinMax(t, mn, mx, def);
     200                getMinMaxIntFromTypeDef(t, mn, mx, def);
    201201                setInt(i, mn);
    202202        }
    203203                break;
    204         default: set(i, "");
     204        default: setFromString(i, "", false);
    205205        }
    206206}
     
    214214        {
    215215                double mn = 0, mx = 0, def = 0;
    216                 getMinMax(t, mn, mx, def);
     216                getMinMaxDoubleFromTypeDef(t, mn, mx, def);
    217217                setDouble(i, mx);
    218218        }
     
    221221        {
    222222                paInt mn = 0, mx = 0, def = 0;
    223                 getMinMax(t, mn, mx, def);
     223                getMinMaxIntFromTypeDef(t, mn, mx, def);
    224224                setInt(i, mx);
    225225        }
    226226                break;
    227         default: set(i, "");
     227        default: setFromString(i, "", false);
    228228        }
    229229}
     
    549549                                        if (options.linenum && (flags(i)&PARAM_LINECOMMENT))
    550550                                                s = SString::sprintf("@file %s\n@line %d\n", f->VgetPath(), *options.linenum + 1) + s;
    551                                         set(i, s.c_str());
     551                                        setFromString(i, s.c_str(), false);
    552552                                        if (options.linenum)
    553553                                                (*options.linenum) += lfcount;
     
    555555                                else
    556556                                {
    557                                         set(i, p0 + p_len + 1);
     557                                        setFromString(i, p0 + p_len + 1, false);
    558558                                }
    559559                                fields_loaded++;
     
    644644}
    645645
    646 int ParamInterface::setInt(int i, const char* str, bool strict)
     646int ParamInterface::setIntFromString(int i, const char* str, bool strict)
    647647{
    648648        paInt value;
     
    650650        {
    651651                paInt mn, mx, def;
    652                 if (getMinMax(i, mn, mx, def) >= 3)
     652                if (getMinMaxInt(i, mn, mx, def) >= 3)
    653653                        return setInt(i, def) | PSET_PARSEFAILED;
    654654                else
     
    659659}
    660660
    661 int ParamInterface::setDouble(int i, const char* str)
     661int ParamInterface::setDoubleFromString(int i, const char* str)
    662662{
    663663        double value;
     
    665665        {
    666666                double mn, mx, def;
    667                 if (getMinMax(i, mn, mx, def) >= 3)
     667                if (getMinMaxDouble(i, mn, mx, def) >= 3)
    668668                        return setDouble(i, def) | PSET_PARSEFAILED;
    669669                else
     
    688688                        }
    689689                        else
    690                                 return setInt(i, v.getString().c_str());
     690                                return setIntFromString(i, v.getString().c_str(), false);
    691691                }
    692692        case 'f':
     
    700700                        }
    701701                        else
    702                                 return setDouble(i, v.getString().c_str());
     702                                return setDoubleFromString(i, v.getString().c_str());
    703703                }
    704704        case 's': { SString t = v.getString(); return setString(i, t); }
     
    715715}
    716716
    717 int ParamInterface::set(int i, const char *v, bool strict)
     717int ParamInterface::setFromString(int i, const char *v, bool strict)
    718718{
    719719        char typ = type(i)[0];
    720720        switch (typ)
    721721        {
    722         case 'd': return setInt(i, v, strict);
    723         case 'f': return setDouble(i, v);
     722        case 'd': return setIntFromString(i, v, strict);
     723        case 'f': return setDoubleFromString(i, v);
    724724        case 's': { SString t(v); return setString(i, t); }
    725725        case 'x': case 'o':
     
    760760                paInt mn, mx, def;
    761761                int value = getInt(i);
    762                 if (getMinMax(t, mn, mx, def) >= 2)
     762                if (getMinMaxIntFromTypeDef(t, mn, mx, def) >= 2)
    763763                {
    764764                        if (value > mx)
     
    801801        {
    802802        case 'd':
    803         {paInt a, b, c; if (getMinMax(t, a, b, c) == 1) return false; }
     803        {paInt a, b, c; if (getMinMaxIntFromTypeDef(t, a, b, c) == 1) return false; }
    804804                break;
    805805        case 'f':
    806         {double a, b, c; if (getMinMax(t, a, b, c) == 1) return false; }
     806        {double a, b, c; if (getMinMaxDoubleFromTypeDef(t, a, b, c) == 1) return false; }
    807807                break;
    808808        }
     
    810810}
    811811
    812 SString ParamInterface::describeType(const char* type)
     812SString ParamInterface::friendlyTypeDescrFromTypeDef(const char* type)
    813813{
    814814        SString t;
     
    816816        {
    817817        case 'd': t += "integer";
    818         {paInt a, b, c; int n = getMinMax(type, a, b, c); if ((n >= 2) && (b >= a)) t += SString::sprintf(" %d..%d", a, b); if (n >= 3) t += SString::sprintf(" (default %d)", c); }
     818        {paInt a, b, c; int n = getMinMaxIntFromTypeDef(type, a, b, c); if ((n >= 2) && (b >= a)) t += SString::sprintf(" %d..%d", a, b); if (n >= 3) t += SString::sprintf(" (default %d)", c); }
    819819                break;
    820820        case 'f': t += "float";
    821         {double a, b, c; int n = getMinMax(type, a, b, c); if ((n >= 2) && (b >= a)) t += SString::sprintf(" %g..%g", a, b); if (n >= 3) t += SString::sprintf(" (default %g)", c); }
     821        {double a, b, c; int n = getMinMaxDoubleFromTypeDef(type, a, b, c); if ((n >= 2) && (b >= a)) t += SString::sprintf(" %g..%g", a, b); if (n >= 3) t += SString::sprintf(" (default %g)", c); }
    822822                break;
    823823        case 's': t += "string";
    824         {int a, b; SString c; int n = getMinMax(type, a, b, c); if ((n >= 2) && (b > 0)) t += SString::sprintf(", max %d chars", b); if (n >= 3) t += SString::sprintf(" (default \"%s\")", c.c_str()); }
     824        {int a, b; SString c; int n = getMinMaxStringFromTypeDef(type, a, b, c); if ((n >= 2) && (b > 0)) t += SString::sprintf(", max %d chars", b); if (n >= 3) t += SString::sprintf(" (default \"%s\")", c.c_str()); }
    825825                break;
    826826        case 'x': t += "untyped value"; break;
     
    980980        paInt mn = 0, mx = 0, de = 0;
    981981        int result = 0;
    982         if (getMinMax(pe->type, mn, mx, de) >= 2)
     982        if (getMinMaxIntFromTypeDef(pe->type, mn, mx, de) >= 2)
    983983                if (mn <= mx) // else if mn>mx then the min/max constraint makes no sense and there is no checking
    984984                {
     
    10141014        double mn = 0, mx = 0, de = 0;
    10151015        int result = 0;
    1016         if (getMinMax(pe->type, mn, mx, de) >= 2)
     1016        if (getMinMaxDoubleFromTypeDef(pe->type, mn, mx, de) >= 2)
    10171017                if (mn <= mx) // else if mn>mx then the min/max constraint makes no sense and there is no checking
    10181018                {
     
    12791279                        remember = *valstop;
    12801280                        *(char*)valstop = 0;
    1281                         ret = set(i, value, true);
     1281                        ret = setFromString(i, value, true);
    12821282                        fields_loaded++;
    12831283                        if (ret&(PSET_HITMAX | PSET_HITMIN))
  • cpp/frams/param/param.h

    r720 r743  
    118118        ExtValue getById(const char* prop);
    119119
    120         int setInt(int i, const char* str, bool strict = false);
    121         int setDouble(int i, const char* str);
     120        int setIntFromString(int i, const char* str, bool strict = false);
     121        int setDoubleFromString(int i, const char* str);
    122122        virtual int setInt(int, paInt) = 0;             ///< set long value, you can only use this for "d" type prop
    123123        virtual int setDouble(int, double) = 0; ///< set double value, you can only use this for "f" type prop
     
    128128        int set(int, const ExtValue &);///< most universal set, can be used for every datatype
    129129
    130         int set(int, const char*, bool strict = false);         ///< oldstyle set, can convert string to long or double
     130        int setFromString(int, const char*, bool strict = false);               ///< oldstyle set, can convert string to long or double
    131131
    132132        int setIntById(const char* prop, paInt);///< set long value, you can only use this for "d" type prop
     
    139139        /** get valid minimum, maximum and default value for property 'prop'
    140140                @return 0 if min/max/def information is not available */
    141         int getMinMax(int prop, paInt& minumum, paInt& maximum, paInt& def);
     141        int getMinMaxInt(int prop, paInt& minumum, paInt& maximum, paInt& def);
    142142        /** get valid minimum, maximum and default value for property 'prop'
    143143                @return 0 if min/max/def information is not available */
    144         int getMinMax(int prop, double& minumum, double& maximum, double& def);
    145         int getMinMax(int prop, int& minumum, int& maximum, SString& def);
    146         static int getMinMax(const char* type, paInt& minumum, paInt& maximum, paInt& def);
    147         static int getMinMax(const char* type, double& minumum, double& maximum, double& def);
    148         static int getMinMax(const char* type, int& minumum, int& maximum, SString& def);
     144        int getMinMaxDouble(int prop, double& minumum, double& maximum, double& def);
     145        int getMinMaxString(int prop, int& minumum, int& maximum, SString& def);
     146        static int getMinMaxIntFromTypeDef(const char* type, paInt& minumum, paInt& maximum, paInt& def);
     147        static int getMinMaxDoubleFromTypeDef(const char* type, double& minumum, double& maximum, double& def);
     148        static int getMinMaxStringFromTypeDef(const char* type, int& minumum, int& maximum, SString& def);
    149149
    150150        virtual void setDefault();
     
    156156
    157157        /** return the human readable description of the given type */
    158         static SString describeType(const char* type);
    159         SString describeType(int i) { return describeType(type(i)); }
     158        static SString friendlyTypeDescrFromTypeDef(const char* type);
     159        SString friendlyTypeDescr(int i) { return friendlyTypeDescrFromTypeDef(type(i)); }
    160160
    161161        /** copy all property values from other ParamInterface object */
Note: See TracChangeset for help on using the changeset viewer.