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

📄 conflict.cxx

📁 eCos1.31版
💻 CXX
📖 第 1 页 / 共 3 页
字号:
// FIXME: these are not currently implemented. It would be necessary// to store the information in the savefile, which requires an// unambiguous way of identifying a conflict that is likely to// survice package version changes.boolCdlConflictBody::is_enabled() const{    CYG_REPORT_FUNCNAMETYPE("CdlConflict::is_enabled", "result %d");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    bool result = enabled;    CYG_REPORT_RETVAL(result);    return result;}std::stringCdlConflictBody::get_disabled_reason() const{    CYG_REPORT_FUNCNAME("CdlConflict::get_disabled_reason");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    // Possibly there should be a check that the conflict is currently    // disabled, but it might be useful.     CYG_REPORT_RETURN();    return reason;}voidCdlConflictBody::disable(std::string reason_arg){    CYG_REPORT_FUNCNAME("CdlConflict::disable");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    reason      = reason_arg;    enabled     = false;    CYG_REPORT_RETURN();}voidCdlConflictBody::enable(){    CYG_REPORT_FUNCNAME("CdlConflict::enable");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    enabled     = true;    // Leave "reason" alone, it may still be useful        CYG_REPORT_RETURN();}//}}}//{{{  check_this()                             // ----------------------------------------------------------------------------boolCdlConflictBody::check_this(cyg_assert_class_zeal zeal) const{    if (CdlConflictBody_Magic != cdlconflictbody_cookie) {        return false;    }    CYGDBG_MEMLEAK_CHECKTHIS();    if ((0 == node) || (0 == property)) {        return false;    }    switch(zeal) {      case cyg_system_test :      case cyg_extreme :      {          if (!node->check_this(cyg_quick)) {              return false;          }          // Accessing the properties would involve a function call.                    if (0 != transaction) {              if (!transaction->check_this(cyg_quick)) {                  return false;              }              if (structural) {                  // The conflict should exist in the new_structural_conflicts vector                  // deleted_structural_conflicts is for toplevel ones.                  if (std::find(transaction->new_structural_conflicts.begin(),                                transaction->new_structural_conflicts.end(), this) ==                      transaction->new_structural_conflicts.end()) {                      return false;                  }              } else {                  // The conflict may appear on the new_conflicts list                  // or in the resolved_conflicts vector.                  if (std::find(transaction->new_conflicts.begin(), transaction->new_conflicts.end(), this) ==                      transaction->new_conflicts.end()) {                      if (std::find(transaction->resolved_conflicts.begin(), transaction->resolved_conflicts.end(), this) ==                          transaction->resolved_conflicts.end()) {                          return false;                      }                  }              }          }          // Checking the toplevel lists would be good, but involves a          // further function call and hence nested assertions.      }      case cyg_thorough :      {          if (!node->check_this(cyg_quick)) {              return false;          }          if (!property->check_this(cyg_quick)) {              return false;          }      }      case cyg_quick :      {          if (no_solution && (0 != solution.size())) {              return false;          }      }      case cyg_trivial :      case cyg_none :      default:          break;    }        return true;}//}}}//}}}//{{{  CdlConflict_Unresolved           // ----------------------------------------------------------------------------// Unresolved references. Usually unresolved references occur inside// expressions, but other properties that may be affected are parent,// dialog and wizard.//// It is possible for a single expression to have multiple unresolved// references, each of which will result in a separate conflict// object. It is also possible for an expression to refer to the same// unknown entity twice or more, in which case there would also be// separate conflict objects. Unresolved references may also result in// eval exceptions and in failed requires statements. Trying to cope// with the various combinations as a single conflict seems too// error-prone.voidCdlConflict_UnresolvedBody::make(CdlTransaction trans, CdlNode node_arg, CdlProperty prop_arg, std::string name_arg){    CdlConflict_Unresolved tmp = new CdlConflict_UnresolvedBody(trans, node_arg, prop_arg, name_arg);    CYG_UNUSED_PARAM(CdlConflict_Unresolved, tmp);}CdlConflict_UnresolvedBody::CdlConflict_UnresolvedBody(CdlTransaction trans_arg, CdlNode node_arg, CdlProperty prop_arg,                                                       std::string target_name_arg)    : CdlConflictBody(trans_arg, node_arg, prop_arg, true){    CYG_REPORT_FUNCNAME("CdlConflict_Unresolved:: constructor");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITIONC("" != target_name_arg);    target_name = target_name_arg;    cdlconflict_unresolvedbody_cookie = CdlConflict_UnresolvedBody_Magic;    CYGDBG_MEMLEAK_CONSTRUCTOR();        CYG_POSTCONDITION_THISC();    CYG_REPORT_RETURN();}CdlConflict_UnresolvedBody::~CdlConflict_UnresolvedBody(){    CYG_REPORT_FUNCNAME("CdlConflict_Unresolved:: destructor");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    cdlconflict_unresolvedbody_cookie = CdlConflict_UnresolvedBody_Invalid;    target_name = "";    CYGDBG_MEMLEAK_DESTRUCTOR();    CYG_REPORT_RETURN();}std::stringCdlConflict_UnresolvedBody::get_target_name() const{    CYG_REPORT_FUNCNAME("CdlConflict_Unresolved::get_target_name");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return target_name;}// For now, just report the node and property name, a brief text, and the// entity being referenced. //// Eventually we can do clever things like looking up the name in a// database.std::stringCdlConflict_UnresolvedBody::get_explanation() const{    CYG_REPORT_FUNCNAME("CdlConflict_Unresolved::get_explanation");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    std::string result;    result = node->get_name() + ", property " + property->get_property_name() +        ":\nReference to unknown object " + target_name;    CYG_REPORT_RETURN();    return result;}boolCdlConflict_UnresolvedBody::check_this(cyg_assert_class_zeal zeal) const{    if (CdlConflict_UnresolvedBody_Magic != cdlconflict_unresolvedbody_cookie) {        return false;    }    CYGDBG_MEMLEAK_CHECKTHIS();    // There is not a lot of checking that can be done on the name.        return CdlConflictBody::check_this(zeal);}boolCdlConflict_UnresolvedBody::test(CdlConflict conf){    CYG_REPORT_FUNCNAMETYPE("CdlConflict_Unresolved::test", "result %d");    CYG_REPORT_FUNCARG1XV(conf);    CYG_PRECONDITION_CLASSC(conf);    bool result = false;    CdlConflict_Unresolved tmp = dynamic_cast<CdlConflict_Unresolved>(conf);    if (0 != tmp) {        result = true;    }    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  CdlConflict_IllegalValue         // ----------------------------------------------------------------------------// A valuable object has an illegal value. This can happen because the// current value is not within the legal_values list, or because of a// failure of check_proc or entry_proc. In the latter two cases the// Tcl code should supply an explanation as to why the value is illegal.//// Note: if future variants of CDL implement some concept of a value// that does not match the CdlValuable class then that will need a// separate CdlConflict derived class.voidCdlConflict_IllegalValueBody::make(CdlTransaction trans, CdlNode node_arg, CdlProperty prop_arg){    CdlConflict_IllegalValue tmp = new CdlConflict_IllegalValueBody(trans, node_arg, prop_arg);    CYG_UNUSED_PARAM(CdlConflict_IllegalValue, tmp);}CdlConflict_IllegalValueBody::CdlConflict_IllegalValueBody(CdlTransaction trans, CdlNode node_arg, CdlProperty prop_arg)    : CdlConflictBody(trans, node_arg, prop_arg, false){    CYG_REPORT_FUNCNAME("CdlConflict_IllegalValue:: constructor");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITIONC(0 != dynamic_cast<CdlValuable>(node_arg));    explanation = "";    cdlconflict_illegalvaluebody_cookie = CdlConflict_IllegalValueBody_Magic;    CYGDBG_MEMLEAK_CONSTRUCTOR();    CYG_POSTCONDITION_THISC();    CYG_REPORT_RETURN();}CdlConflict_IllegalValueBody::~CdlConflict_IllegalValueBody(){    CYG_REPORT_FUNCNAME("CdlConflict_IllegalValue:: destructor");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    cdlconflict_illegalvaluebody_cookie = CdlConflict_IllegalValueBody_Invalid;    explanation = "";    CYGDBG_MEMLEAK_DESTRUCTOR();    CYG_REPORT_RETURN();}// ----------------------------------------------------------------------------// If the property is legal_values then it should be a list expression// property. Display the current value and the original expression.//// If the property is check_proc or entry_proc, the Tcl code should// have produced an explanation string and stored it in the conflict// object.std::stringCdlConflict_IllegalValueBody::get_explanation() const{    CYG_REPORT_FUNCNAME("CdlConflict_IllegalValue::get_explanation()");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CdlConstValuable valuable = dynamic_cast<CdlConstValuable>(node);    CYG_ASSERTC(0 != valuable);    std::string result = "";    // FIXME: analyse the current value and flavor a bit more    result += "Illegal current value " + valuable->get_value() + "\n";    if (CdlPropertyId_LegalValues == property->get_property_name()) {                CdlConstProperty_ListExpression expr = dynamic_cast<CdlConstProperty_ListExpression>(property);        CYG_ASSERTC(0 != expr);        result += "Legal values are: " + expr->get_original_string();            } else if (explanation != "") {                result += explanation;    } else {        CYG_FAIL("Inexplicable illegal value");    }    CYG_REPORT_RETURN();    return result;}voidCdlConflict_IllegalValueBody::set_explanation(std::string explanation_arg){    CYG_REPORT_FUNCNAME("CdlConflict_IllegalValue::set_explanation");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    explanation = explanation_arg;    CYG_REPORT_RETURN();

⌨️ 快捷键说明

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