⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 value.cxx

📁 eCos1.31版
💻 CXX
📖 第 1 页 / 共 5 页
字号:
    cdllistvalue_cookie = CdlListValue_Magic;    CYGDBG_MEMLEAK_CONSTRUCTOR();        CYG_POSTCONDITION_THISC();    CYG_REPORT_RETURN();}CdlListValue & CdlListValue::operator=(const CdlListValue& original){    CYG_REPORT_FUNCNAME("CdlListValue:: assignment operator");    CYG_REPORT_FUNCARG2XV(this, &original);    CYG_INVARIANT_CLASSOC(CdlListValue, original);    if (this != &original) {        table.clear();        integer_ranges.clear();        double_ranges.clear();        table          = original.table;        integer_ranges = original.integer_ranges;        double_ranges  = original.double_ranges;    }        CYG_POSTCONDITION_THISC();    CYG_REPORT_RETURN();    return *this;}CdlListValue::~CdlListValue(){    CYG_REPORT_FUNCNAME("CdlListValue:: destructor");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    cdllistvalue_cookie = CdlListValue_Invalid;    table.clear();    integer_ranges.clear();    double_ranges.clear();    CYGDBG_MEMLEAK_DESTRUCTOR();        CYG_REPORT_RETURN();}// ----------------------------------------------------------------------------// Finding out about the current legal values. These routines can be// used by GUI-related code to figure out a sensible widget to be used// for a CDL entity. In nearly all cases life will be simple: either// there will be a fixed set of legal values and the user merely has// to choose one of these; or there will be a simple numerical range.// Occasionally life may be more complicated, if the full generality// of CDL list expressions is being used, and it will be necessary to// use an entry box instead. Note that the entity's flavor may also// affect the user interface.const std::vector<CdlSimpleValue>&CdlListValue::get_table(void) const{    CYG_REPORT_FUNCNAME("CdlListValue::get_table");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return table;}const std::vector<std::pair<cdl_int, cdl_int> >&CdlListValue::get_integer_ranges(void) const{    CYG_REPORT_FUNCNAME("CdlListValue::get_integer_ranges");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return integer_ranges;}const std::vector<std::pair<double, double> >&CdlListValue::get_double_ranges(void) const{    CYG_REPORT_FUNCNAME("CdlListValue::get_double_ranges");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return double_ranges;}// ----------------------------------------------------------------------------// Membership. This can be quite complicated.//// 1) anything which has an integer representation must be checked against//    the integer ranges and the vector of integer constants. It must//    also be checked against the floating point ranges, since calculations//    may have resulted in the fractional part disappearing, assuming that//    the integer has a floating point representation.//// 2) similarly anything which has a floating point representation must//    be checked against the floating point ranges and constant vector.//    In addition it may have an empty fractional part in which case//    integer comparisons have to be attempted as well.//// 3) string data needs to be tested first of all for integer and double//    representations. If these fail then the comparison should be against//    the string vector.//// For floating point data exact comparisons are of course meaningless,// and arguably the vector of floating point constants is useless. The// ranges vector is better, but still not ideal. It may be necessary// to introduce an epsilon fudge factor.boolCdlListValue::is_member(CdlSimpleValue& val) const{    CYG_REPORT_FUNCNAMETYPE("CdlListValue::is_member (CdlSimpleValue)", "result %d");    CYG_REPORT_FUNCARG2XV(this, &val);    CYG_PRECONDITION_THISC();    bool result = false;    if (val.has_integer_value()) {        result = is_member(val.get_integer_value(), false);    }    if (!result && val.has_double_value()) {        result = is_member(val.get_double_value(), false);    }    if (!result) {        result = is_member(val.get_value());    }        CYG_REPORT_RETVAL(result);    return result;}boolCdlListValue::is_member(std::string val, bool allow_conversions) const{    CYG_REPORT_FUNCNAMETYPE("CdlListValue::is_member (string)", "result %d");    CYG_REPORT_FUNCARG3XV(this, &val, allow_conversions);    CYG_PRECONDITION_THISC();    bool        result = false;    if (allow_conversions) {        cdl_int     integer_value;        double      double_value;        if (Cdl::string_to_integer(val, integer_value)) {            result = is_member(integer_value, false);        }        if (!result && Cdl::string_to_double(val, double_value)) {            result = is_member(double_value, false);        }    }    if (!result) {        for (std::vector<CdlSimpleValue>::const_iterator val_i = table.begin(); val_i != table.end(); val_i++) {            if (val_i->get_value() == val) {                result = true;                break;            }        }    }    CYG_REPORT_RETVAL(result);    return result;}boolCdlListValue::is_member(cdl_int val, bool allow_conversions) const{    CYG_REPORT_FUNCNAMETYPE("CdlListValue::is_member (int)", "result %d");    CYG_REPORT_FUNCARG3XV(this, &val, allow_conversions);    CYG_PRECONDITION_THISC();    bool result = false;    for (std::vector<CdlSimpleValue>::const_iterator val_i = table.begin(); val_i != table.end(); val_i++) {        if (val_i->has_integer_value() && (val_i->get_integer_value() == val)) {            result = true;            break;        }    }    if (!result) {        for (std::vector<std::pair<cdl_int,cdl_int> >::const_iterator i = integer_ranges.begin();             i != integer_ranges.end(); i++) {            if ((val >= i->first) && (val <= i->second)) {                result = true;                break;            }        }    }    if (!result && allow_conversions) {        double double_value = Cdl::integer_to_double(val);        result = is_member(double_value, false);    }    CYG_REPORT_RETVAL(result);    return result;}boolCdlListValue::is_member(double val, bool allow_conversions) const{    CYG_REPORT_FUNCNAMETYPE("CdlListValue::is_member (double)", "result %d");    CYG_REPORT_FUNCARG3XV(this, &val, allow_conversions);    CYG_PRECONDITION_THISC();    bool result = false;    for (std::vector<CdlSimpleValue>::const_iterator val_i = table.begin(); val_i != table.end(); val_i++) {        if (val_i->has_double_value() && (val_i->get_double_value() == val)) {            result = true;            break;        }    }    if (!result) {        for (std::vector<std::pair<double,double> >::const_iterator i = double_ranges.begin();             i != double_ranges.end(); i++) {            if ((val >= i->first) && (val <= i->second)) {                result = true;                break;            }        }    }    if (!result && allow_conversions) {        cdl_int integer_value;        if (Cdl::double_to_integer(val, integer_value)) {            result = is_member(integer_value, false);        }    }    CYG_REPORT_RETVAL(result);    return result;}// ----------------------------------------------------------------------------boolCdlListValue::check_this(cyg_assert_class_zeal zeal) const{    if (CdlListValue_Magic != cdllistvalue_cookie) {        return false;    }    CYGDBG_MEMLEAK_CHECKTHIS();    // After construction the various vectors will still be empty, they    // do not get filled in until a list expression is evaluated. No    // further tests are possible here.    return true;}//}}}//{{{  dialog property                  // ----------------------------------------------------------------------------// Syntax: dialog <reference>voidCdlValuableBody::dialog_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest,                                       CdlUpdate change){    CYG_REPORT_FUNCNAME("CdlValuable::dialog_update_handler");    CYG_PRECONDITION_CLASSC(transaction);    CYG_PRECONDITION_CLASSC(source);    CYG_PRECONDITION_CLASSC(prop);        // The main update of interest is Loaded (iff dest != 0), and    // Created. These updates indicate that the destination now exists,    // so it is possible to check that the destination is a dialog.    if (((CdlUpdate_Loaded == change) && (0 != dest)) ||        (CdlUpdate_Created == change)) {        CYG_ASSERT_CLASSC(dest);        CdlDialog dialog = dynamic_cast<CdlDialog>(dest);        if (0 == dialog) {            std::string msg = dest->get_class_name() + " " + dest->get_name() +                " cannot be used in a dialog property, it is not a custom dialog.";            CdlConflict_DataBody::make(transaction, source, prop, msg);        }            } else if (CdlUpdate_Destroyed == change) {        // If there was a data conflict object, it is no longer relevant        transaction->clear_structural_conflicts(source, prop, &CdlConflict_DataBody::test);    }    CYG_REPORT_RETURN();}intCdlValuableBody::parse_dialog(CdlInterpreter interp, int argc, char** argv){    CYG_REPORT_FUNCNAMETYPE("parse_dialog", "result %d");    int result = CdlParse::parse_reference_property(interp, argc, argv, CdlPropertyId_Dialog, 0, 0, &dialog_update_handler);        CYG_REPORT_RETVAL(result);    return result;}boolCdlValuableBody::has_dialog() const{    CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_dialog", "result %d");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    // It is not enough to have the property, the dialog reference must also be    // resolved and go to a dialog.    bool        result          = false;    CdlProperty property        = get_property(CdlPropertyId_Dialog);    if (0 != property) {        CdlProperty_Reference ref_prop = dynamic_cast<CdlProperty_Reference>(property);        CYG_ASSERTC(0 != ref_prop);        CdlNode destination = ref_prop->get_destination();        if (0 != destination) {            CdlDialog dialog = dynamic_cast<CdlDialog>(destination);            if (0 != dialog) {                result = true;            }        }    }    CYG_REPORT_RETVAL(result);    return result;}CdlDialogCdlValuableBody::get_dialog() const{    CYG_REPORT_FUNCNAMETYPE("CdlValuable::get_dialog", "result %p");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CdlDialog   result          = 0;    CdlProperty property        = get_property(CdlPropertyId_Dialog);    if (0 != property) {        CdlProperty_Reference ref_prop = dynamic_cast<CdlProperty_Reference>(property);        CYG_ASSERTC(0 != ref_prop);        CdlNode destination = ref_prop->get_destination();        if (0 != destination) {            result = dynamic_cast<CdlDialog>(destination);        }    }    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  wizard property                  // ----------------------------------------------------------------------------// Syntax: wizard <reference>voidCdlValuableBody::wizard_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest,                                       CdlUpdate change){    CYG_REPORT_FUNCNAME("CdlValuable::wizard_update_handler");    CYG_PRECONDITION_CLASSC(transaction);    CYG_PRECONDITION_CLASSC(source);    CYG_PRECONDITION_CLASSC(prop);        // The main update of interest is Loaded (iff dest != 0), and    // Created. These updates indicate that the destination now exists,    // so it is possible to check that the destination is a dialog.    if (((CdlUpdate_Loaded == change) && (0 != dest)) ||        (CdlUpdate_Created == change)) {        CYG_ASSERT_CLASSC(dest);        CdlWizard wizard = dynamic_cast<CdlWizard>(dest);        if (0 == wizard) {            std::string msg = dest->get_class_name() + " " + dest->get_name() +                " cannot be used in a wizard property, it is not a wizard.";            CdlConflict_DataBody::make(transaction, source, prop, msg);        }            } else if (CdlUpdate_Destroyed == change) {        // If there was a data conflict object, it is no longer relevant        transaction->clear_structural_conflicts(source, prop, &CdlConflict_DataBody::test);    }    CYG_REPORT_RETURN();}intCdlValuableBody::parse_wizard(CdlInterpreter interp, int argc, char** argv){    CYG_REPORT_FUNCNAMETYPE("parse_wizard", "result %d");    int result = CdlParse::parse_reference_property(interp, argc, argv, CdlPropertyId_Wizard, 0, 0, &wizard_update_handler);    CYG_REPORT_RETVAL(result);    return result;}boolCdlValuableBody::has_wizard() const{    CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_wizard", "result %d");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    // It is not enough to have the property, the wizard reference    // must also be resolved to a wizard object.    bool        result          = false;    CdlProperty property        = get_property(CdlPropertyId_Wizard);    if (0 != property) {        CdlProperty_Reference ref_prop = dynamic_cast<CdlProperty_Reference>(property);        CYG_ASSERTC(0 != ref_prop);        CdlNode destination = ref_prop->get_destination();        if (0 != destination) {            CdlWizard wizard = dynamic_cast<CdlWizard>(destination);            CYG_ASSERTC(0 != wizard);            CYG_UNUSED_PARAM(CdlWizard, wizard);            result = true;        }    }    CYG_REPORT_RETVAL(result);    return result;}CdlWizardCdlValuableBody::get_wizard() const{    CYG_REPORT_FUNCNAMETYPE("CdlValuable::get_wizard", "result %p");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -