📄 value.cxx
字号:
CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlWizard result = 0; 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) { result = dynamic_cast<CdlWizard>(destination); CYG_ASSERTC(0 != result); } } CYG_REPORT_RETVAL(result); return result;}//}}}//{{{ legal_values property // ----------------------------------------------------------------------------// Syntax: legal_values <list expression>voidCdlValuableBody::legal_values_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest, CdlUpdate change){ CYG_REPORT_FUNCNAME("legal_values_update_handler"); // Loaded and Unloading are of no immediate interest, reference // updating happens in the calling code. // // Any other change can affect the list expression and hence // invalidate the current value. if ((CdlUpdate_Loaded == change) || (CdlUpdate_Unloading == change)) { CYG_REPORT_RETURN(); return; } CdlValuable valuable = dynamic_cast<CdlValuable>(source); CdlProperty_ListExpression lexpr = dynamic_cast<CdlProperty_ListExpression>(prop); CYG_ASSERT_CLASSC(valuable); CYG_ASSERT_CLASSC(lexpr); valuable->check_value(transaction); CYG_UNUSED_PARAM(CdlNode, dest); CYG_UNUSED_PARAM(CdlProperty_ListExpression, lexpr); CYG_REPORT_RETURN();}intCdlValuableBody::parse_legal_values(CdlInterpreter interp, int argc, char** argv){ CYG_REPORT_FUNCNAMETYPE("parse_legal_values", "result %d"); int result = CdlParse::parse_listexpression_property(interp, argc, argv, CdlPropertyId_LegalValues, 0, 0, &legal_values_update_handler); CYG_REPORT_RETVAL(result); return result;}boolCdlValuableBody::has_legal_values() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_legal_values", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_LegalValues); CYG_REPORT_RETVAL(result); return result;}CdlProperty_ListExpressionCdlValuableBody::get_legal_values() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::get_legal_values", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlProperty_ListExpression result = 0; CdlProperty property = get_property(CdlPropertyId_LegalValues); if (0 != property) { result = dynamic_cast<CdlProperty_ListExpression>(property); CYG_ASSERTC(0 != result); } CYG_REPORT_RETVAL(result); return result;}//}}}//{{{ default_value property // ----------------------------------------------------------------------------// syntax: default_value <expr>voidCdlValuableBody::default_value_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest, CdlUpdate change){ CYG_REPORT_FUNCNAME("CdlValuable::default_value_update_handler"); CYG_REPORT_FUNCARG5XV(transaction, source, prop, dest, change); // Loaded and unloading should be ignored. if ((CdlUpdate_Loaded == change) || (CdlUpdate_Unloading == change)) { CYG_REPORT_RETURN(); return; } // Init, Created, Destroyed, ValueChange and ActiveChange should // all result in the expression being re-evaluated and the result // applied. CdlValuable valuable = dynamic_cast<CdlValuable>(source); CYG_ASSERTC(0 != valuable); CdlProperty_Expression expr = dynamic_cast<CdlProperty_Expression>(prop); CYG_ASSERTC(0 != expr); CdlSimpleValue val; try { CdlEvalContext context(transaction, source, prop); expr->eval(context, val); valuable->set(transaction, val, CdlValueSource_Default); } catch(CdlEvalException e) { // An EvalException conflict will have been created, so the // user knows that this default_value is not kosher. It is // still a good idea to make sure that the object retains a // sensible value. val = (cdl_int) 0; valuable->set(transaction, val, CdlValueSource_Default); } CYG_UNUSED_PARAM(CdlNode, dest); CYG_REPORT_RETURN();}intCdlValuableBody::parse_default_value(CdlInterpreter interp, int argc, char** argv){ CYG_REPORT_FUNCNAMETYPE("parse_default_value", "result %d"); int result = CdlParse::parse_expression_property(interp, argc, argv, CdlPropertyId_DefaultValue, 0, 0, &default_value_update_handler); CYG_REPORT_RETVAL(result); return result;}boolCdlValuableBody::has_default_value_expression() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_default_value_expression", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_DefaultValue); CYG_REPORT_RETVAL(result); return result;}CdlProperty_ExpressionCdlValuableBody::get_default_value_expression() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::get_default_value_expression", "result %"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlProperty_Expression result = 0; CdlProperty property = get_property(CdlPropertyId_DefaultValue); if (0 != property) { result = dynamic_cast<CdlProperty_Expression>(property); CYG_ASSERTC(0 != result); } CYG_REPORT_RETVAL(result); return result;}//}}}//{{{ calculated_property // ----------------------------------------------------------------------------// Syntax: calculated <expression>voidCdlValuableBody::calculated_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest, CdlUpdate change){ CYG_REPORT_FUNCNAME("CdlValuable::default_value_update_handler"); CYG_REPORT_FUNCARG5XV(transaction, source, prop, dest, change); // Loaded and unloading should be ignored. if ((CdlUpdate_Loaded == change) || (CdlUpdate_Unloading == change)) { CYG_REPORT_RETURN(); return; } // Init, Created, Destroyed, ValueChange and ActiveChange should // all result in the expression being re-evaluated and the result // applied. CdlValuable valuable = dynamic_cast<CdlValuable>(source); CYG_ASSERTC(0 != valuable); CdlProperty_Expression expr = dynamic_cast<CdlProperty_Expression>(prop); CYG_ASSERTC(0 != expr); CdlSimpleValue val; try { CdlEvalContext context(transaction, source, prop); expr->eval(context, val); valuable->set(transaction, val, CdlValueSource_Default); } catch(CdlEvalException e) { // An EvalException conflict will have been created, so the // user knows that this default_value is not kosher. It is // still a good idea to make sure that the object retains a // sensible value. val = (cdl_int) 0; valuable->set(transaction, val, CdlValueSource_Default); } CYG_UNUSED_PARAM(CdlNode, dest); CYG_REPORT_RETURN();}// FIXME: check for flavor none?intCdlValuableBody::parse_calculated(CdlInterpreter interp, int argc, char** argv){ CYG_REPORT_FUNCNAMETYPE("parse_calculated", "result %d"); int result = CdlParse::parse_expression_property(interp, argc, argv, CdlPropertyId_Calculated, 0, 0, &calculated_update_handler); CYG_REPORT_RETVAL(result); return result;}boolCdlValuableBody::has_calculated_expression() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_calculated_expression", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_Calculated); CYG_REPORT_RETVAL(result); return result;}CdlProperty_ExpressionCdlValuableBody::get_calculated_expression() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::get_calculated_expression", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlProperty_Expression result = 0; CdlProperty property = get_property(CdlPropertyId_Calculated); if (0 != property) { result = dynamic_cast<CdlProperty_Expression>(property); CYG_ASSERTC(0 != result); } CYG_REPORT_RETVAL(result); return result;}//}}}//{{{ active_if property // ----------------------------------------------------------------------------// Syntax:// active_if <goal expression>voidCdlValuableBody::active_if_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest, CdlUpdate change){ CYG_REPORT_FUNCNAME("CdlValuable::active_if_update_handler"); CYG_REPORT_FUNCARG5XV(transaction, source, prop, dest, change); CYG_PRECONDITION_CLASSC(transaction); CYG_PRECONDITION_CLASSC(source); CYG_PRECONDITION_CLASSC(prop); // Loaded should be ignored here, the world is still getting sorted out. // Unloading is of no interest, the source is disappearing anyway. if ((CdlUpdate_Loaded == change) || (CdlUpdate_Unloading == change)) { CYG_REPORT_RETURN(); return; } // Any other change warrants re-evaluating the active status of the source. // This can be achieved via a test_active() call, although that may do // more work than is strictly necessary e.g. it may re-evaluate other // is_active properties. In practice it is unlikely that there will // be enough other constraints to warrant more efficient processing. bool old_state = transaction->is_active(source); bool new_state = source->test_active(transaction); if (old_state != new_state) { transaction->set_active(source, new_state); } CYG_UNUSED_PARAM(CdlNode, dest); CYG_REPORT_RETURN();}intCdlValuableBody::parse_active_if(CdlInterpreter interp, int argc, char** argv){ CYG_REPORT_FUNCNAMETYPE("parse_active_if", "result %d"); int result = CdlParse::parse_goalexpression_property(interp, argc, argv, CdlPropertyId_ActiveIf, 0, 0, &active_if_update_handler); CYG_REPORT_RETVAL(result); return result;}boolCdlValuableBody::has_active_if_conditions() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_active_if_conditions", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_ActiveIf); CYG_REPORT_RETVAL(result); return result;}voidCdlValuableBody::get_active_if_conditions(std::vector<CdlProperty_GoalExpression>& result) const{ CYG_REPORT_FUNCNAME("CdlValuable::get_active_if_conditions"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); std::vector<CdlProperty> properties; get_properties(CdlPropertyId_ActiveIf, properties); std::vector<CdlProperty>::const_iterator i; for (i = properties.begin(); i != properties.end(); i++) { CdlProperty_GoalExpression goal = dynamic_cast<CdlProperty_GoalExpression>(*i); CYG_ASSERTC(0 != goal); result.push_back(goal); } CYG_REPORT_RETURN();}//}}}//{{{ requires property // ----------------------------------------------------------------------------// Syntax: requires <goal expression>voidCdlValuableBody::requires_update_handler(CdlTransaction transaction, CdlNode source, CdlProperty prop, CdlNode dest, CdlUpdate change){ CYG_REPORT_FUNCNAME("CdlValuable::requires_update_handler"); CYG_REPORT_FUNCARG5XV(transaction, source, prop, dest, change); CYG_PRECONDITION_CLASSC(transaction); // Loaded and Unloading are not of interest. if ((CdlUpdate_Loaded == change) || (CdlUpdate_Unloading == change)) { CYG_REPORT_RETURN(); return; } // Any other change should cause normal handling. This happens in // a separate function because "requires" properties also need to // be checked when e.g. the source becomes inactive. CdlValuable valuable = dynamic_cast<CdlValuable>(source); CdlProperty_GoalExpression gexpr = dynamic_cast<CdlProperty_GoalExpression>(prop); CYG_ASSERT_CLASSC(valuable); CYG_ASSERT_CLASSC(gexpr); valuable->check_requires(transaction, gexpr); CYG_UNUSED_PARAM(CdlNode, dest); CYG_REPORT_RETURN();}intCdlValuableBody::parse_requires(CdlInterpreter interp, int argc, char** argv){ CYG_REPORT_FUNCNAMETYPE("parse_requires", "result %d"); int result = CdlParse::parse_goalexpression_property(interp, argc, argv, CdlPropertyId_Requires, 0, 0, &requires_update_handler); CYG_REPORT_RETVAL(result); return result;}boolCdlValuableBody::has_requires_goals() const{ CYG_REPORT_FUNCNAMETYPE("CdlValuable::has_requires_goals", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_Requires); CYG_REPORT_RETVAL(result); return result;}voidCdlValuableBody
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -