//{{{ Banner
|
//{{{ Banner
|
|
|
//============================================================================
|
//============================================================================
|
//
|
//
|
// transaction.cxx
|
// transaction.cxx
|
//
|
//
|
// Implementation of the CdlTransaction class
|
// Implementation of the CdlTransaction class
|
//
|
//
|
//============================================================================
|
//============================================================================
|
//####COPYRIGHTBEGIN####
|
//####COPYRIGHTBEGIN####
|
//
|
//
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
|
//
|
//
|
// This file is part of the eCos host tools.
|
// This file is part of the eCos host tools.
|
//
|
//
|
// This program is free software; you can redistribute it and/or modify it
|
// This program is free software; you can redistribute it and/or modify it
|
// under the terms of the GNU General Public License as published by the Free
|
// under the terms of the GNU General Public License as published by the Free
|
// Software Foundation; either version 2 of the License, or (at your option)
|
// Software Foundation; either version 2 of the License, or (at your option)
|
// any later version.
|
// any later version.
|
//
|
//
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
// more details.
|
// more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along with
|
// You should have received a copy of the GNU General Public License along with
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
//
|
//
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
//
|
//
|
//####COPYRIGHTEND####
|
//####COPYRIGHTEND####
|
//============================================================================
|
//============================================================================
|
//#####DESCRIPTIONBEGIN####
|
//#####DESCRIPTIONBEGIN####
|
//
|
//
|
// Author(s): bartv
|
// Author(s): bartv
|
// Contact(s): bartv
|
// Contact(s): bartv
|
// Date: 1999/07/16
|
// Date: 1999/07/16
|
// Version: 0.01
|
// Version: 0.01
|
//
|
//
|
//####DESCRIPTIONEND####
|
//####DESCRIPTIONEND####
|
//============================================================================
|
//============================================================================
|
|
|
//}}}
|
//}}}
|
//{{{ #include's
|
//{{{ #include's
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
#include "cdlconfig.h"
|
#include "cdlconfig.h"
|
|
|
// Get the infrastructure types, assertions, tracing and similar
|
// Get the infrastructure types, assertions, tracing and similar
|
// facilities.
|
// facilities.
|
#include <cyg/infra/cyg_ass.h>
|
#include <cyg/infra/cyg_ass.h>
|
#include <cyg/infra/cyg_trac.h>
|
#include <cyg/infra/cyg_trac.h>
|
|
|
// <cdlcore.hxx> defines everything implemented in this module.
|
// <cdlcore.hxx> defines everything implemented in this module.
|
// It implicitly supplies <string>, <vector> and <map> because
|
// It implicitly supplies <string>, <vector> and <map> because
|
// the class definitions rely on these headers.
|
// the class definitions rely on these headers.
|
#include <cdlcore.hxx>
|
#include <cdlcore.hxx>
|
|
|
//}}}
|
//}}}
|
|
|
//{{{ CdlTransactionCallback class
|
//{{{ CdlTransactionCallback class
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// The callback class is very straightforward. The hard work is done in
|
// The callback class is very straightforward. The hard work is done in
|
// the transaction class.
|
// the transaction class.
|
|
|
CdlTransactionCallback::CdlTransactionCallback(CdlTransaction transact_arg)
|
CdlTransactionCallback::CdlTransactionCallback(CdlTransaction transact_arg)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransactionCallback:: constructor");
|
CYG_REPORT_FUNCNAME("CdlTransactionCallback:: constructor");
|
CYG_REPORT_FUNCARG2XV(this, transact_arg);
|
CYG_REPORT_FUNCARG2XV(this, transact_arg);
|
CYG_PRECONDITION_CLASSC(transact_arg);
|
CYG_PRECONDITION_CLASSC(transact_arg);
|
|
|
// The vectors etc. will take care of themselves.
|
// The vectors etc. will take care of themselves.
|
transact = transact_arg;
|
transact = transact_arg;
|
cdltransactioncallback_cookie = CdlTransactionCallback_Magic;
|
cdltransactioncallback_cookie = CdlTransactionCallback_Magic;
|
|
|
CYG_POSTCONDITION_THISC();
|
CYG_POSTCONDITION_THISC();
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
CdlTransactionCallback::~CdlTransactionCallback()
|
CdlTransactionCallback::~CdlTransactionCallback()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransactionCallback:: destructor");
|
CYG_REPORT_FUNCNAME("CdlTransactionCallback:: destructor");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
cdltransactioncallback_cookie = CdlTransactionCallback_Invalid;
|
cdltransactioncallback_cookie = CdlTransactionCallback_Invalid;
|
transact = 0;
|
transact = 0;
|
value_changes.clear();
|
value_changes.clear();
|
active_changes.clear();
|
active_changes.clear();
|
legal_values_changes.clear();
|
legal_values_changes.clear();
|
value_source_changes.clear();
|
value_source_changes.clear();
|
new_conflicts.clear();
|
new_conflicts.clear();
|
new_structural_conflicts.clear();
|
new_structural_conflicts.clear();
|
nodes_with_resolved_conflicts.clear();
|
nodes_with_resolved_conflicts.clear();
|
nodes_with_resolved_structural_conflicts.clear();
|
nodes_with_resolved_structural_conflicts.clear();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionCallback::set_callback_fn(void (*fn)(const CdlTransactionCallback&))
|
CdlTransactionCallback::set_callback_fn(void (*fn)(const CdlTransactionCallback&))
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransactionCallback::set_callback_fn");
|
CYG_REPORT_FUNCNAME("CdlTransactionCallback::set_callback_fn");
|
CYG_REPORT_FUNCARG1XV(fn);
|
CYG_REPORT_FUNCARG1XV(fn);
|
|
|
CdlTransactionBody::set_callback_fn(fn);
|
CdlTransactionBody::set_callback_fn(fn);
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void (*CdlTransactionCallback::get_callback_fn())(const CdlTransactionCallback&)
|
void (*CdlTransactionCallback::get_callback_fn())(const CdlTransactionCallback&)
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_callback_fn", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_callback_fn", "result %p");
|
|
|
void (*result)(const CdlTransactionCallback&) = CdlTransactionBody::get_callback_fn();
|
void (*result)(const CdlTransactionCallback&) = CdlTransactionBody::get_callback_fn();
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlTransaction
|
CdlTransaction
|
CdlTransactionCallback::get_transaction() const
|
CdlTransactionCallback::get_transaction() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_transaction", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_transaction", "result %p");
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlTransaction result = transact;
|
CdlTransaction result = transact;
|
CYG_POSTCONDITION_CLASSC(result);
|
CYG_POSTCONDITION_CLASSC(result);
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlToplevel
|
CdlToplevel
|
CdlTransactionCallback::get_toplevel() const
|
CdlTransactionCallback::get_toplevel() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_toplevel", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_toplevel", "result %p");
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlToplevel result = transact->get_toplevel();
|
CdlToplevel result = transact->get_toplevel();
|
CYG_POSTCONDITION_CLASSC(result);
|
CYG_POSTCONDITION_CLASSC(result);
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
bool
|
bool
|
CdlTransactionCallback::check_this(cyg_assert_class_zeal zeal) const
|
CdlTransactionCallback::check_this(cyg_assert_class_zeal zeal) const
|
{
|
{
|
if (CdlTransactionCallback_Magic != cdltransactioncallback_cookie) {
|
if (CdlTransactionCallback_Magic != cdltransactioncallback_cookie) {
|
return false;
|
return false;
|
}
|
}
|
return true;
|
return true;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ CdlTransaction statics
|
//{{{ CdlTransaction statics
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
void (*CdlTransactionBody::callback_fn)(const CdlTransactionCallback&) = 0;
|
void (*CdlTransactionBody::callback_fn)(const CdlTransactionCallback&) = 0;
|
CdlInferenceCallback CdlTransactionBody::inference_callback = 0;
|
CdlInferenceCallback CdlTransactionBody::inference_callback = 0;
|
bool CdlTransactionBody::inference_enabled = true;
|
bool CdlTransactionBody::inference_enabled = true;
|
int CdlTransactionBody::inference_recursion_limit = 3;
|
int CdlTransactionBody::inference_recursion_limit = 3;
|
CdlValueSource CdlTransactionBody::inference_override = CdlValueSource_Inferred;
|
CdlValueSource CdlTransactionBody::inference_override = CdlValueSource_Inferred;
|
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlTransactionBody);
|
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlTransactionBody);
|
|
|
//}}}
|
//}}}
|
//{{{ Transaction creation and destruction
|
//{{{ Transaction creation and destruction
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
CdlTransaction
|
CdlTransaction
|
CdlTransactionBody::make(CdlToplevel toplevel)
|
CdlTransactionBody::make(CdlToplevel toplevel)
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::make", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::make", "result %p");
|
CYG_REPORT_FUNCARG1XV(toplevel);
|
CYG_REPORT_FUNCARG1XV(toplevel);
|
CYG_PRECONDITION_CLASSC(toplevel);
|
CYG_PRECONDITION_CLASSC(toplevel);
|
CYG_PRECONDITIONC(0 == toplevel->transaction);
|
CYG_PRECONDITIONC(0 == toplevel->transaction);
|
|
|
CdlTransaction result = new CdlTransactionBody(toplevel, 0, 0);
|
CdlTransaction result = new CdlTransactionBody(toplevel, 0, 0);
|
toplevel->transaction = result;
|
toplevel->transaction = result;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlTransaction
|
CdlTransaction
|
CdlTransactionBody::make(CdlConflict conflict)
|
CdlTransactionBody::make(CdlConflict conflict)
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::make (sub-transaction)", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::make (sub-transaction)", "result %p");
|
CYG_REPORT_FUNCARG2XV(this, conflict);
|
CYG_REPORT_FUNCARG2XV(this, conflict);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_ZERO_OR_CLASSC(conflict);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(conflict);
|
|
|
CdlTransaction result = new CdlTransactionBody(0, this, conflict);
|
CdlTransaction result = new CdlTransactionBody(0, this, conflict);
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlTransactionBody::CdlTransactionBody(CdlToplevel toplevel_arg, CdlTransaction parent_arg, CdlConflict conflict_arg)
|
CdlTransactionBody::CdlTransactionBody(CdlToplevel toplevel_arg, CdlTransaction parent_arg, CdlConflict conflict_arg)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction:: constructor");
|
CYG_REPORT_FUNCNAME("CdlTransaction:: constructor");
|
CYG_REPORT_FUNCARG4XV(this, toplevel_arg, parent_arg, conflict_arg);
|
CYG_REPORT_FUNCARG4XV(this, toplevel_arg, parent_arg, conflict_arg);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(toplevel_arg);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(toplevel_arg);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(parent_arg);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(parent_arg);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(conflict_arg);
|
CYG_PRECONDITION_ZERO_OR_CLASSC(conflict_arg);
|
CYG_PRECONDITIONC( ((0 == toplevel_arg) && (0 != parent_arg)) || ((0 == parent_arg) && (0 != toplevel_arg)));
|
CYG_PRECONDITIONC( ((0 == toplevel_arg) && (0 != parent_arg)) || ((0 == parent_arg) && (0 != toplevel_arg)));
|
|
|
// The containers will take care of themselves, as will all_changes
|
// The containers will take care of themselves, as will all_changes
|
toplevel = toplevel_arg;
|
toplevel = toplevel_arg;
|
parent = parent_arg;
|
parent = parent_arg;
|
conflict = conflict_arg;
|
conflict = conflict_arg;
|
dirty = false;
|
dirty = false;
|
cdltransactionbody_cookie = CdlTransactionBody_Magic;
|
cdltransactionbody_cookie = CdlTransactionBody_Magic;
|
CYGDBG_MEMLEAK_CONSTRUCTOR();
|
CYGDBG_MEMLEAK_CONSTRUCTOR();
|
|
|
CYG_POSTCONDITION_THISC();
|
CYG_POSTCONDITION_THISC();
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
CdlTransactionBody::~CdlTransactionBody()
|
CdlTransactionBody::~CdlTransactionBody()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction:: destructor");
|
CYG_REPORT_FUNCNAME("CdlTransaction:: destructor");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
// The transaction must have been either committed or cancelled.
|
// The transaction must have been either committed or cancelled.
|
// This means that various of the STL containers should be empty
|
// This means that various of the STL containers should be empty
|
CYG_ASSERTC(0 == commit_cancel_ops.size());
|
CYG_ASSERTC(0 == commit_cancel_ops.size());
|
CYG_ASSERTC(0 == changes.size());
|
CYG_ASSERTC(0 == changes.size());
|
CYG_ASSERTC(0 == deleted_conflicts.size());
|
CYG_ASSERTC(0 == deleted_conflicts.size());
|
CYG_ASSERTC(0 == deleted_structural_conflicts.size());
|
CYG_ASSERTC(0 == deleted_structural_conflicts.size());
|
CYG_ASSERTC(0 == new_conflicts.size());
|
CYG_ASSERTC(0 == new_conflicts.size());
|
CYG_ASSERTC(0 == new_structural_conflicts.size());
|
CYG_ASSERTC(0 == new_structural_conflicts.size());
|
CYG_ASSERTC(0 == resolved_conflicts.size());
|
CYG_ASSERTC(0 == resolved_conflicts.size());
|
CYG_ASSERTC(0 == global_conflicts_with_solutions.size());
|
CYG_ASSERTC(0 == global_conflicts_with_solutions.size());
|
CYG_ASSERTC(0 == activated.size());
|
CYG_ASSERTC(0 == activated.size());
|
CYG_ASSERTC(0 == deactivated.size());
|
CYG_ASSERTC(0 == deactivated.size());
|
CYG_ASSERTC(0 == legal_values_changes.size());
|
CYG_ASSERTC(0 == legal_values_changes.size());
|
CYG_ASSERTC(0 == value_changes.size());
|
CYG_ASSERTC(0 == value_changes.size());
|
CYG_ASSERTC(0 == active_changes.size());
|
CYG_ASSERTC(0 == active_changes.size());
|
|
|
// If this was a toplevel transaction, the toplevel knows
|
// If this was a toplevel transaction, the toplevel knows
|
// about the transaction.
|
// about the transaction.
|
if (0 != toplevel) {
|
if (0 != toplevel) {
|
CYG_ASSERTC(toplevel->transaction == this);
|
CYG_ASSERTC(toplevel->transaction == this);
|
toplevel->transaction = 0;
|
toplevel->transaction = 0;
|
}
|
}
|
cdltransactionbody_cookie = CdlTransactionBody_Invalid;
|
cdltransactionbody_cookie = CdlTransactionBody_Invalid;
|
toplevel = 0;
|
toplevel = 0;
|
parent = 0;
|
parent = 0;
|
conflict = 0;
|
conflict = 0;
|
dirty = false;
|
dirty = false;
|
|
|
CYGDBG_MEMLEAK_DESTRUCTOR();
|
CYGDBG_MEMLEAK_DESTRUCTOR();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ check_this()
|
//{{{ check_this()
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
|
|
bool
|
bool
|
CdlTransactionBody::check_this(cyg_assert_class_zeal zeal) const
|
CdlTransactionBody::check_this(cyg_assert_class_zeal zeal) const
|
{
|
{
|
if (CdlTransactionBody_Magic != cdltransactionbody_cookie) {
|
if (CdlTransactionBody_Magic != cdltransactionbody_cookie) {
|
return false;
|
return false;
|
}
|
}
|
CYGDBG_MEMLEAK_CHECKTHIS();
|
CYGDBG_MEMLEAK_CHECKTHIS();
|
|
|
//zeal = cyg_extreme;
|
//zeal = cyg_extreme;
|
switch(zeal) {
|
switch(zeal) {
|
case cyg_system_test:
|
case cyg_system_test:
|
case cyg_extreme :
|
case cyg_extreme :
|
{
|
{
|
std::map<CdlValuable,CdlValue>::const_iterator map_i;
|
std::map<CdlValuable,CdlValue>::const_iterator map_i;
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
if (!map_i->first->check_this(cyg_quick) || !map_i->second.check_this(cyg_quick)) {
|
if (!map_i->first->check_this(cyg_quick) || !map_i->second.check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
|
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
if (!(*conf_i)->check_this(cyg_quick)) {
|
if (!(*conf_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
if (!(*conf_i)->check_this(cyg_quick)) {
|
if (!(*conf_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
|
|
std::vector<CdlConflict>::const_iterator conf_i2;
|
std::vector<CdlConflict>::const_iterator conf_i2;
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
if (!(*conf_i2)->check_this(cyg_quick)) {
|
if (!(*conf_i2)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
for (conf_i2 = resolved_conflicts.begin(); conf_i2 != resolved_conflicts.end(); conf_i2++) {
|
for (conf_i2 = resolved_conflicts.begin(); conf_i2 != resolved_conflicts.end(); conf_i2++) {
|
if (!(*conf_i2)->check_this(cyg_quick)) {
|
if (!(*conf_i2)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
if (!(*conf_i2)->check_this(cyg_quick)) {
|
if (!(*conf_i2)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
for (conf_i = global_conflicts_with_solutions.begin(); conf_i != global_conflicts_with_solutions.end(); conf_i++) {
|
for (conf_i = global_conflicts_with_solutions.begin(); conf_i != global_conflicts_with_solutions.end(); conf_i++) {
|
if (!(*conf_i)->check_this(cyg_quick)) {
|
if (!(*conf_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
if (0 != (*conf_i)->transaction) {
|
if (0 != (*conf_i)->transaction) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
|
|
// Nodes cannot have been both activated and deactivated in one transaction
|
// Nodes cannot have been both activated and deactivated in one transaction
|
std::set<CdlNode>::const_iterator node_i;
|
std::set<CdlNode>::const_iterator node_i;
|
for (node_i = activated.begin(); node_i != activated.end(); node_i++) {
|
for (node_i = activated.begin(); node_i != activated.end(); node_i++) {
|
if (!(*node_i)->check_this(cyg_quick)) {
|
if (!(*node_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
if (deactivated.end() != deactivated.find(*node_i)) {
|
if (deactivated.end() != deactivated.find(*node_i)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
for (node_i = deactivated.begin(); node_i != deactivated.end(); node_i++) {
|
for (node_i = deactivated.begin(); node_i != deactivated.end(); node_i++) {
|
if (!(*node_i)->check_this(cyg_quick)) {
|
if (!(*node_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
if (activated.end() != activated.find(*node_i)) {
|
if (activated.end() != activated.find(*node_i)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
std::set<CdlValuable>::const_iterator val_i;
|
std::set<CdlValuable>::const_iterator val_i;
|
for (val_i = legal_values_changes.begin(); val_i != legal_values_changes.end(); val_i++) {
|
for (val_i = legal_values_changes.begin(); val_i != legal_values_changes.end(); val_i++) {
|
if (!(*val_i)->check_this(cyg_quick)) {
|
if (!(*val_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
|
|
std::deque<CdlValuable>::const_iterator val_i2;
|
std::deque<CdlValuable>::const_iterator val_i2;
|
for (val_i2 = value_changes.begin(); val_i2 != value_changes.end(); val_i2++) {
|
for (val_i2 = value_changes.begin(); val_i2 != value_changes.end(); val_i2++) {
|
if (!(*val_i2)->check_this(cyg_quick)) {
|
if (!(*val_i2)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
|
|
std::deque<CdlNode>::const_iterator active_i;
|
std::deque<CdlNode>::const_iterator active_i;
|
for (active_i = active_changes.begin(); active_i != active_changes.end(); active_i++) {
|
for (active_i = active_changes.begin(); active_i != active_changes.end(); active_i++) {
|
if (!(*active_i)->check_this(cyg_quick)) {
|
if (!(*active_i)->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
}
|
}
|
}
|
}
|
case cyg_thorough:
|
case cyg_thorough:
|
if ((0 != toplevel) && !toplevel->check_this(cyg_quick)) {
|
if ((0 != toplevel) && !toplevel->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
if ((0 != parent) && !parent->check_this(cyg_quick)) {
|
if ((0 != parent) && !parent->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
if ((0 != conflict) && !conflict->check_this(cyg_quick)) {
|
if ((0 != conflict) && !conflict->check_this(cyg_quick)) {
|
return false;
|
return false;
|
}
|
}
|
|
|
case cyg_quick:
|
case cyg_quick:
|
case cyg_trivial :
|
case cyg_trivial :
|
if ((0 == toplevel) && (0 == parent)) {
|
if ((0 == toplevel) && (0 == parent)) {
|
return false;
|
return false;
|
}
|
}
|
if (this == parent) {
|
if (this == parent) {
|
return false;
|
return false;
|
}
|
}
|
|
|
case cyg_none :
|
case cyg_none :
|
break;
|
break;
|
}
|
}
|
|
|
return true;
|
return true;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Misc
|
//{{{ Misc
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
CdlToplevel
|
CdlToplevel
|
CdlTransactionBody::get_toplevel() const
|
CdlTransactionBody::get_toplevel() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_toplevel", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_toplevel", "result %p");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlToplevel result = toplevel;
|
CdlToplevel result = toplevel;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlTransaction
|
CdlTransaction
|
CdlTransactionBody::get_parent() const
|
CdlTransactionBody::get_parent() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_parent", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_parent", "result %p");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlTransaction result = parent;
|
CdlTransaction result = parent;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlConflict
|
CdlConflict
|
CdlTransactionBody::get_conflict() const
|
CdlTransactionBody::get_conflict() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_conflict", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_conflict", "result %p");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlConflict result = conflict;
|
CdlConflict result = conflict;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
void (*CdlTransactionBody::get_callback_fn())(const CdlTransactionCallback&)
|
void (*CdlTransactionBody::get_callback_fn())(const CdlTransactionCallback&)
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_callback_fn", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_callback_fn", "result %p");
|
|
|
void (*result)(const CdlTransactionCallback&) = callback_fn;
|
void (*result)(const CdlTransactionCallback&) = callback_fn;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::set_callback_fn(void (*fn)(const CdlTransactionCallback&))
|
CdlTransactionBody::set_callback_fn(void (*fn)(const CdlTransactionCallback&))
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_callback_fn");
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_callback_fn");
|
CYG_REPORT_FUNCARG1XV(fn);
|
CYG_REPORT_FUNCARG1XV(fn);
|
|
|
callback_fn = fn;
|
callback_fn = fn;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
CdlInferenceCallback
|
CdlInferenceCallback
|
CdlTransactionBody::get_inference_callback_fn()
|
CdlTransactionBody::get_inference_callback_fn()
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_inference_callback_fn", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_inference_callback_fn", "result %p");
|
|
|
CdlInferenceCallback result = inference_callback;
|
CdlInferenceCallback result = inference_callback;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::set_inference_callback_fn(CdlInferenceCallback fn)
|
CdlTransactionBody::set_inference_callback_fn(CdlInferenceCallback fn)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_inference_callback");
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_inference_callback");
|
CYG_REPORT_FUNCARG1XV(fn);
|
CYG_REPORT_FUNCARG1XV(fn);
|
|
|
inference_callback = fn;
|
inference_callback = fn;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::enable_automatic_inference()
|
CdlTransactionBody::enable_automatic_inference()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::enable_automatic_inference");
|
CYG_REPORT_FUNCNAME("CdlTransaction::enable_automatic_inference");
|
|
|
inference_enabled = true;
|
inference_enabled = true;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::disable_automatic_inference()
|
CdlTransactionBody::disable_automatic_inference()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::disable_automatic_inference");
|
CYG_REPORT_FUNCNAME("CdlTransaction::disable_automatic_inference");
|
|
|
inference_enabled = false;
|
inference_enabled = false;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
bool
|
bool
|
CdlTransactionBody::is_automatic_inference_enabled()
|
CdlTransactionBody::is_automatic_inference_enabled()
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::is_automatic_inference_enabled", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::is_automatic_inference_enabled", "result %d");
|
|
|
bool result = inference_enabled;
|
bool result = inference_enabled;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::set_inference_recursion_limit(int limit)
|
CdlTransactionBody::set_inference_recursion_limit(int limit)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_inference_recursion_limit");
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_inference_recursion_limit");
|
CYG_REPORT_FUNCARG1XV(limit);
|
CYG_REPORT_FUNCARG1XV(limit);
|
CYG_PRECONDITIONC(0 < limit);
|
CYG_PRECONDITIONC(0 < limit);
|
CYG_PRECONDITIONC(limit < 16); // arbitrary number
|
CYG_PRECONDITIONC(limit < 16); // arbitrary number
|
|
|
inference_recursion_limit = limit;
|
inference_recursion_limit = limit;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
int
|
int
|
CdlTransactionBody::get_inference_recursion_limit()
|
CdlTransactionBody::get_inference_recursion_limit()
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_inference_recursion_limit", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_inference_recursion_limit", "result %d");
|
|
|
int result = inference_recursion_limit;
|
int result = inference_recursion_limit;
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::set_inference_override(CdlValueSource source)
|
CdlTransactionBody::set_inference_override(CdlValueSource source)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_inference_override");
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_inference_override");
|
CYG_REPORT_FUNCARG1XV(source);
|
CYG_REPORT_FUNCARG1XV(source);
|
CYG_PRECONDITIONC((CdlValueSource_Invalid == source) || Cdl::is_valid_value_source(source));
|
CYG_PRECONDITIONC((CdlValueSource_Invalid == source) || Cdl::is_valid_value_source(source));
|
|
|
inference_override = source;
|
inference_override = source;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
CdlValueSource
|
CdlValueSource
|
CdlTransactionBody::get_inference_override()
|
CdlTransactionBody::get_inference_override()
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_inference_override", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_inference_override", "result %d");
|
|
|
CdlValueSource result = inference_override;
|
CdlValueSource result = inference_override;
|
|
|
CYG_REPORT_RETVAL((int) result);
|
CYG_REPORT_RETVAL((int) result);
|
return result;
|
return result;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Value access and updates
|
//{{{ Value access and updates
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
const CdlValue&
|
const CdlValue&
|
CdlTransactionBody::get_whole_value(CdlConstValuable valuable_arg) const
|
CdlTransactionBody::get_whole_value(CdlConstValuable valuable_arg) const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_whole_value", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_whole_value", "result %p");
|
CYG_REPORT_FUNCARG2XV(this, valuable_arg);
|
CYG_REPORT_FUNCARG2XV(this, valuable_arg);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(valuable_arg);
|
CYG_PRECONDITION_CLASSC(valuable_arg);
|
|
|
// Unfortunately I need a valuable rather than a const-valuable when
|
// Unfortunately I need a valuable rather than a const-valuable when
|
// accessing the STL containers.
|
// accessing the STL containers.
|
CdlValuable valuable = const_cast<CdlValuable>(valuable_arg);
|
CdlValuable valuable = const_cast<CdlValuable>(valuable_arg);
|
|
|
// If we are trying to find a solution, keep track of all valuables
|
// If we are trying to find a solution, keep track of all valuables
|
// that were accessed.
|
// that were accessed.
|
const CdlValue* result = 0;
|
const CdlValue* result = 0;
|
if (0 != conflict) {
|
if (0 != conflict) {
|
conflict->solution_references.insert(valuable);
|
conflict->solution_references.insert(valuable);
|
}
|
}
|
|
|
std::map<CdlValuable,CdlValue>::const_iterator val_i;
|
std::map<CdlValuable,CdlValue>::const_iterator val_i;
|
val_i = changes.find(valuable);
|
val_i = changes.find(valuable);
|
if (val_i != changes.end()) {
|
if (val_i != changes.end()) {
|
result = &(val_i->second);
|
result = &(val_i->second);
|
} else if (0 != parent) {
|
} else if (0 != parent) {
|
result = &(parent->get_whole_value(valuable));
|
result = &(parent->get_whole_value(valuable));
|
} else {
|
} else {
|
result = &(valuable->get_whole_value());
|
result = &(valuable->get_whole_value());
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return *result;
|
return *result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::set_whole_value(CdlValuable valuable, const CdlValue& old_value, const CdlValue& new_value)
|
CdlTransactionBody::set_whole_value(CdlValuable valuable, const CdlValue& old_value, const CdlValue& new_value)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_whole_value");
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_whole_value");
|
CYG_REPORT_FUNCARG3XV(this, valuable, &new_value);
|
CYG_REPORT_FUNCARG3XV(this, valuable, &new_value);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(valuable);
|
CYG_PRECONDITION_CLASSC(valuable);
|
CYG_PRECONDITION_CLASSOC(old_value);
|
CYG_PRECONDITION_CLASSOC(old_value);
|
CYG_PRECONDITION_CLASSOC(new_value);
|
CYG_PRECONDITION_CLASSOC(new_value);
|
CYG_PRECONDITIONC(&old_value != &new_value);
|
CYG_PRECONDITIONC(&old_value != &new_value);
|
|
|
CdlValueFlavor flavor = old_value.get_flavor();
|
CdlValueFlavor flavor = old_value.get_flavor();
|
CYG_ASSERTC(flavor == new_value.get_flavor());
|
CYG_ASSERTC(flavor == new_value.get_flavor());
|
CYG_ASSERTC(CdlValueFlavor_None != flavor);
|
CYG_ASSERTC(CdlValueFlavor_None != flavor);
|
|
|
bool value_changed = false;
|
bool value_changed = false;
|
bool bool_changed = false;
|
bool bool_changed = false;
|
|
|
if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) {
|
if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) {
|
if (old_value.is_enabled() != new_value.is_enabled()) {
|
if (old_value.is_enabled() != new_value.is_enabled()) {
|
value_changed = true;
|
value_changed = true;
|
bool_changed = true;
|
bool_changed = true;
|
}
|
}
|
}
|
}
|
if (!value_changed && ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor))) {
|
if (!value_changed && ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor))) {
|
if (old_value.get_simple_value() != new_value.get_simple_value()) {
|
if (old_value.get_simple_value() != new_value.get_simple_value()) {
|
value_changed = true;
|
value_changed = true;
|
}
|
}
|
}
|
}
|
if (value_changed) {
|
if (value_changed) {
|
std::deque<CdlValuable>::const_iterator change_i;
|
std::deque<CdlValuable>::const_iterator change_i;
|
change_i = std::find(value_changes.begin(), value_changes.end(), valuable);
|
change_i = std::find(value_changes.begin(), value_changes.end(), valuable);
|
if (change_i == value_changes.end()) {
|
if (change_i == value_changes.end()) {
|
value_changes.push_back(valuable);
|
value_changes.push_back(valuable);
|
}
|
}
|
}
|
}
|
|
|
// Actually do the update. This may modify old_value, so has to be
|
// Actually do the update. This may modify old_value, so has to be
|
// left to the end.
|
// left to the end.
|
changes[valuable] = new_value;
|
changes[valuable] = new_value;
|
|
|
// If there was a change to the boolean part of the value and the valuable
|
// If there was a change to the boolean part of the value and the valuable
|
// implements an interface, the interface value needs to be recalculated.
|
// implements an interface, the interface value needs to be recalculated.
|
if (bool_changed && valuable->has_property(CdlPropertyId_Implements)) {
|
if (bool_changed && valuable->has_property(CdlPropertyId_Implements)) {
|
std::vector<CdlInterface> interfaces;
|
std::vector<CdlInterface> interfaces;
|
std::vector<CdlInterface>::const_iterator interface_i;
|
std::vector<CdlInterface>::const_iterator interface_i;
|
valuable->get_implemented_interfaces(interfaces);
|
valuable->get_implemented_interfaces(interfaces);
|
for (interface_i = interfaces.begin(); interface_i != interfaces.end(); interface_i++) {
|
for (interface_i = interfaces.begin(); interface_i != interfaces.end(); interface_i++) {
|
(*interface_i)->recalculate(this);
|
(*interface_i)->recalculate(this);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
const std::map<CdlValuable, CdlValue>&
|
const std::map<CdlValuable, CdlValue>&
|
CdlTransactionBody::get_changes() const
|
CdlTransactionBody::get_changes() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_changes");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_changes");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return changes;
|
return changes;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Active access and updates
|
//{{{ Active access and updates
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Nodes can become active or inactive during transactions, and this affects
|
// Nodes can become active or inactive during transactions, and this affects
|
// propagation and expression evaluation
|
// propagation and expression evaluation
|
|
|
bool
|
bool
|
CdlTransactionBody::is_active(CdlNode node) const
|
CdlTransactionBody::is_active(CdlNode node) const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::is_active", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::is_active", "result %d");
|
CYG_REPORT_FUNCARG2XV(this, node);
|
CYG_REPORT_FUNCARG2XV(this, node);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
bool result = false;
|
bool result = false;
|
if (activated.end() != activated.find(node)) {
|
if (activated.end() != activated.find(node)) {
|
result = true;
|
result = true;
|
} else if (deactivated.end() != deactivated.find(node)) {
|
} else if (deactivated.end() != deactivated.find(node)) {
|
result = false;
|
result = false;
|
} else if (0 != parent) {
|
} else if (0 != parent) {
|
result = parent->is_active(node);
|
result = parent->is_active(node);
|
} else {
|
} else {
|
result = node->is_active();
|
result = node->is_active();
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::set_active(CdlNode node, bool state)
|
CdlTransactionBody::set_active(CdlNode node, bool state)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_active");
|
CYG_REPORT_FUNCNAME("CdlTransaction::set_active");
|
CYG_REPORT_FUNCARG3XV(this, node, state);
|
CYG_REPORT_FUNCARG3XV(this, node, state);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
if (state) {
|
if (state) {
|
activated.insert(node);
|
activated.insert(node);
|
std::set<CdlNode>::iterator node_i = deactivated.find(node);
|
std::set<CdlNode>::iterator node_i = deactivated.find(node);
|
if (deactivated.end() != node_i) {
|
if (deactivated.end() != node_i) {
|
deactivated.erase(node_i);
|
deactivated.erase(node_i);
|
}
|
}
|
} else {
|
} else {
|
deactivated.insert(node);
|
deactivated.insert(node);
|
std::set<CdlNode>::iterator node_i = activated.find(node);
|
std::set<CdlNode>::iterator node_i = activated.find(node);
|
if (activated.end() != node_i) {
|
if (activated.end() != node_i) {
|
activated.erase(node_i);
|
activated.erase(node_i);
|
}
|
}
|
}
|
}
|
active_changes.push_back(node);
|
active_changes.push_back(node);
|
|
|
CdlValuable valuable = dynamic_cast<CdlValuable>(node);
|
CdlValuable valuable = dynamic_cast<CdlValuable>(node);
|
if ((0 != valuable) && valuable->has_property(CdlPropertyId_Implements)) {
|
if ((0 != valuable) && valuable->has_property(CdlPropertyId_Implements)) {
|
std::vector<CdlInterface> interfaces;
|
std::vector<CdlInterface> interfaces;
|
std::vector<CdlInterface>::const_iterator interface_i;
|
std::vector<CdlInterface>::const_iterator interface_i;
|
valuable->get_implemented_interfaces(interfaces);
|
valuable->get_implemented_interfaces(interfaces);
|
for (interface_i = interfaces.begin(); interface_i != interfaces.end(); interface_i++) {
|
for (interface_i = interfaces.begin(); interface_i != interfaces.end(); interface_i++) {
|
(*interface_i)->recalculate(this);
|
(*interface_i)->recalculate(this);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Conflict access and updates
|
//{{{ Conflict access and updates
|
|
|
//{{{ get_conflict() etc.
|
//{{{ get_conflict() etc.
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
bool
|
bool
|
CdlTransactionBody::has_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::has_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_conflict", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_conflict", "result %d");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
// Because it is necessary to check whether or not any given
|
// Because it is necessary to check whether or not any given
|
// conflict has been cleared in the current transaction or any
|
// conflict has been cleared in the current transaction or any
|
// parent transaction, recursion into the parent is not
|
// parent transaction, recursion into the parent is not
|
// appropriate.
|
// appropriate.
|
bool result = false;
|
bool result = false;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin();
|
for (conf_i = current_transaction->new_conflicts.begin();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) &&
|
if ((node == (*conf_i)->get_node()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (!result && (0 != current_transaction));
|
} while (!result && (0 != current_transaction));
|
|
|
if (!result) {
|
if (!result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlConflict
|
CdlConflict
|
CdlTransactionBody::get_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::get_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_conflict", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_conflict", "result %p");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
CdlConflict result = 0;
|
CdlConflict result = 0;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin();
|
for (conf_i = current_transaction->new_conflicts.begin();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) &&
|
if ((node == (*conf_i)->get_node()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while ((0 == result) && (0 != current_transaction));
|
} while ((0 == result) && (0 != current_transaction));
|
|
|
if (0 == result) {
|
if (0 == result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::get_conflicts(CdlNode node, bool (*pFn)(CdlConflict), std::vector<CdlConflict>& result)
|
CdlTransactionBody::get_conflicts(CdlNode node, bool (*pFn)(CdlConflict), std::vector<CdlConflict>& result)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_conflicts");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin();
|
for (conf_i = current_transaction->new_conflicts.begin();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) &&
|
if ((node == (*conf_i)->get_node()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
bool
|
bool
|
CdlTransactionBody::has_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::has_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_conflict", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_conflict", "result %d");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(prop);
|
CYG_PRECONDITION_CLASSC(prop);
|
|
|
bool result = false;
|
bool result = false;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin();
|
for (conf_i = current_transaction->new_conflicts.begin();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (!result && (0 != current_transaction));
|
} while (!result && (0 != current_transaction));
|
|
|
if (!result) {
|
if (!result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlConflict
|
CdlConflict
|
CdlTransactionBody::get_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::get_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_conflict", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_conflict", "result %p");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(prop);
|
CYG_PRECONDITION_CLASSC(prop);
|
|
|
CdlConflict result = 0;
|
CdlConflict result = 0;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin();
|
for (conf_i = current_transaction->new_conflicts.begin();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while ((0 == result) && (0 != current_transaction));
|
} while ((0 == result) && (0 != current_transaction));
|
|
|
if (0 == result) {
|
if (0 == result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::get_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict), std::vector<CdlConflict>& result)
|
CdlTransactionBody::get_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict), std::vector<CdlConflict>& result)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_conflict");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_conflict");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(prop);
|
CYG_PRECONDITION_CLASSC(prop);
|
|
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin();
|
for (conf_i = current_transaction->new_conflicts.begin();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i != current_transaction->new_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ get_structural_conflict() etc
|
//{{{ get_structural_conflict() etc
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
bool
|
bool
|
CdlTransactionBody::has_structural_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::has_structural_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_structural_conflict", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_structural_conflict", "result %d");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
// Because it is necessary to check whether or not any given
|
// Because it is necessary to check whether or not any given
|
// conflict has been cleared in the current transaction or any
|
// conflict has been cleared in the current transaction or any
|
// parent transaction, recursion into the parent is not
|
// parent transaction, recursion into the parent is not
|
// appropriate.
|
// appropriate.
|
bool result = false;
|
bool result = false;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) &&
|
if ((node == (*conf_i)->get_node()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (!result && (0 != current_transaction));
|
} while (!result && (0 != current_transaction));
|
|
|
if (!result) {
|
if (!result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlConflict
|
CdlConflict
|
CdlTransactionBody::get_structural_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::get_structural_conflict(CdlNode node, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_structural_conflict", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_structural_conflict", "result %p");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
CdlConflict result = 0;
|
CdlConflict result = 0;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) &&
|
if ((node == (*conf_i)->get_node()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while ((0 == result) && (0 != current_transaction));
|
} while ((0 == result) && (0 != current_transaction));
|
|
|
if (0 == result) {
|
if (0 == result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::get_structural_conflicts(CdlNode node, bool (*pFn)(CdlConflict), std::vector<CdlConflict>& result)
|
CdlTransactionBody::get_structural_conflicts(CdlNode node, bool (*pFn)(CdlConflict), std::vector<CdlConflict>& result)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_structural_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_structural_conflicts");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) &&
|
if ((node == (*conf_i)->get_node()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
if ((node == (*conf_i)->get_node()) && !(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
bool
|
bool
|
CdlTransactionBody::has_structural_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::has_structural_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_structural_conflict", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_structural_conflict", "result %d");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(prop);
|
CYG_PRECONDITION_CLASSC(prop);
|
|
|
bool result = false;
|
bool result = false;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (!result && (0 != current_transaction));
|
} while (!result && (0 != current_transaction));
|
|
|
if (!result) {
|
if (!result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
CdlConflict
|
CdlConflict
|
CdlTransactionBody::get_structural_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::get_structural_conflict(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_structural_conflict", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_structural_conflict", "result %p");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(prop);
|
CYG_PRECONDITION_CLASSC(prop);
|
|
|
CdlConflict result = 0;
|
CdlConflict result = 0;
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while ((0 == result) && (0 != current_transaction));
|
} while ((0 == result) && (0 != current_transaction));
|
|
|
if (0 == result) {
|
if (0 == result) {
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result = *conf_i;
|
result = *conf_i;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::get_structural_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict),
|
CdlTransactionBody::get_structural_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict),
|
std::vector<CdlConflict>& result)
|
std::vector<CdlConflict>& result)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_structural_conflict");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_structural_conflict");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(prop);
|
CYG_PRECONDITION_CLASSC(prop);
|
|
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); conf_i++) {
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
if ((node == (*conf_i)->get_node()) && (prop == (*conf_i)->get_property()) &&
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
!(this->has_conflict_been_cleared(*conf_i)) && (*pFn)(*conf_i)) {
|
|
|
result.push_back(*conf_i);
|
result.push_back(*conf_i);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ clear_conflicts()
|
//{{{ clear_conflicts()
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Clearing a conflict. This can only happen in the context of a
|
// Clearing a conflict. This can only happen in the context of a
|
// transaction.
|
// transaction.
|
void
|
void
|
CdlTransactionBody::clear_conflicts(CdlNode node, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::clear_conflicts(CdlNode node, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_conflicts");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
// Recursing into the parent is the wrong thing to do here, it
|
// Recursing into the parent is the wrong thing to do here, it
|
// would result in the conflict being cleared in the parent rather
|
// would result in the conflict being cleared in the parent rather
|
// than in the current transaction.
|
// than in the current transaction.
|
std::list<CdlConflict>::iterator conf_i;
|
std::list<CdlConflict>::iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin(); conf_i != current_transaction->new_conflicts.end(); ) {
|
for (conf_i = current_transaction->new_conflicts.begin(); conf_i != current_transaction->new_conflicts.end(); ) {
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); ) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); ) {
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::clear_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::clear_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_conflicts");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
std::list<CdlConflict>::iterator conf_i;
|
std::list<CdlConflict>::iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_conflicts.begin(); conf_i != current_transaction->new_conflicts.end(); ) {
|
for (conf_i = current_transaction->new_conflicts.begin(); conf_i != current_transaction->new_conflicts.end(); ) {
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); ) {
|
for (conf_i = toplevel->conflicts.begin(); conf_i != toplevel->conflicts.end(); ) {
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::clear_structural_conflicts(CdlNode node, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::clear_structural_conflicts(CdlNode node, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_structural_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_structural_conflicts");
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_REPORT_FUNCARG3XV(this, node, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
std::list<CdlConflict>::iterator conf_i;
|
std::list<CdlConflict>::iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
) {
|
) {
|
|
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); ) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); ) {
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
if ((node == conflict->get_node()) && !(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::clear_structural_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
CdlTransactionBody::clear_structural_conflicts(CdlNode node, CdlProperty prop, bool (*pFn)(CdlConflict))
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_structural_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_structural_conflicts");
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_REPORT_FUNCARG4XV(this, node, prop, pFn);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(node);
|
CYG_PRECONDITION_CLASSC(node);
|
|
|
std::list<CdlConflict>::iterator conf_i;
|
std::list<CdlConflict>::iterator conf_i;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
CdlToplevel toplevel = this->toplevel;
|
CdlToplevel toplevel = this->toplevel;
|
do {
|
do {
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
CYG_LOOP_INVARIANT_CLASSC(current_transaction);
|
|
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
for (conf_i = current_transaction->new_structural_conflicts.begin();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
conf_i != current_transaction->new_structural_conflicts.end();
|
) {
|
) {
|
|
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
|
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
toplevel = current_transaction->toplevel;
|
toplevel = current_transaction->toplevel;
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (0 != current_transaction);
|
} while (0 != current_transaction);
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); ) {
|
for (conf_i = toplevel->structural_conflicts.begin(); conf_i != toplevel->structural_conflicts.end(); ) {
|
CdlConflict conflict = *conf_i++;
|
CdlConflict conflict = *conf_i++;
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
if ((node == conflict->get_node()) && (prop == conflict->get_property()) &&
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
!(this->has_conflict_been_cleared(conflict)) && (*pFn)(conflict)) {
|
this->clear_conflict(conflict);
|
this->clear_conflict(conflict);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ clear_conflict()
|
//{{{ clear_conflict()
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
void
|
void
|
CdlTransactionBody::clear_conflict(CdlConflict conflict)
|
CdlTransactionBody::clear_conflict(CdlConflict conflict)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_conflict");
|
CYG_REPORT_FUNCNAME("CdlTransaction::clear_conflict");
|
CYG_REPORT_FUNCARG2XV(this, conflict);
|
CYG_REPORT_FUNCARG2XV(this, conflict);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(conflict);
|
CYG_PRECONDITION_CLASSC(conflict);
|
|
|
// If this conflict was created during the transaction, it should
|
// If this conflict was created during the transaction, it should
|
// be on the new_conflicts or new_structural_conflicts container
|
// be on the new_conflicts or new_structural_conflicts container
|
if (this == conflict->transaction) {
|
if (this == conflict->transaction) {
|
// The conflict should be on one of the two new_conflicts deques.
|
// The conflict should be on one of the two new_conflicts deques.
|
if (conflict->structural) {
|
if (conflict->structural) {
|
std::list<CdlConflict>::iterator conf_i = std::find(new_structural_conflicts.begin(),
|
std::list<CdlConflict>::iterator conf_i = std::find(new_structural_conflicts.begin(),
|
new_structural_conflicts.end(), conflict);
|
new_structural_conflicts.end(), conflict);
|
CYG_ASSERTC(conf_i != new_structural_conflicts.end());
|
CYG_ASSERTC(conf_i != new_structural_conflicts.end());
|
new_structural_conflicts.erase(conf_i);
|
new_structural_conflicts.erase(conf_i);
|
} else {
|
} else {
|
std::list<CdlConflict>::iterator conf_i = std::find(new_conflicts.begin(), new_conflicts.end(), conflict);
|
std::list<CdlConflict>::iterator conf_i = std::find(new_conflicts.begin(), new_conflicts.end(), conflict);
|
CYG_ASSERTC(conf_i != new_conflicts.end());
|
CYG_ASSERTC(conf_i != new_conflicts.end());
|
new_conflicts.erase(conf_i);
|
new_conflicts.erase(conf_i);
|
}
|
}
|
delete conflict;
|
delete conflict;
|
|
|
} else {
|
} else {
|
if (conflict->structural) {
|
if (conflict->structural) {
|
deleted_structural_conflicts.push_back(conflict);
|
deleted_structural_conflicts.push_back(conflict);
|
} else {
|
} else {
|
deleted_conflicts.push_back(conflict);
|
deleted_conflicts.push_back(conflict);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
bool
|
bool
|
CdlTransactionBody::has_conflict_been_cleared(CdlConflict conf)
|
CdlTransactionBody::has_conflict_been_cleared(CdlConflict conf)
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_conflict_been_cleared", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::has_conflict_been_cleared", "result %d");
|
CYG_REPORT_FUNCARG2XV(this, conf);
|
CYG_REPORT_FUNCARG2XV(this, conf);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(conf);
|
CYG_PRECONDITION_CLASSC(conf);
|
|
|
bool result = false;
|
bool result = false;
|
CdlTransaction current_transaction = this;
|
CdlTransaction current_transaction = this;
|
do {
|
do {
|
if (conf->structural) {
|
if (conf->structural) {
|
if (std::find(current_transaction->deleted_structural_conflicts.begin(),
|
if (std::find(current_transaction->deleted_structural_conflicts.begin(),
|
current_transaction->deleted_structural_conflicts.end(), conf) !=
|
current_transaction->deleted_structural_conflicts.end(), conf) !=
|
current_transaction->deleted_structural_conflicts.end()) {
|
current_transaction->deleted_structural_conflicts.end()) {
|
|
|
result = true;
|
result = true;
|
}
|
}
|
} else {
|
} else {
|
if (std::find(current_transaction->deleted_conflicts.begin(), current_transaction->deleted_conflicts.end(),
|
if (std::find(current_transaction->deleted_conflicts.begin(), current_transaction->deleted_conflicts.end(),
|
conf) != current_transaction->deleted_conflicts.end()) {
|
conf) != current_transaction->deleted_conflicts.end()) {
|
result = true;
|
result = true;
|
}
|
}
|
}
|
}
|
|
|
current_transaction = current_transaction->parent;
|
current_transaction = current_transaction->parent;
|
} while (!result && (0 != current_transaction));
|
} while (!result && (0 != current_transaction));
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ per-transaction data
|
//{{{ per-transaction data
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Accessing the per-transaction conflict data.
|
// Accessing the per-transaction conflict data.
|
|
|
const std::list<CdlConflict>&
|
const std::list<CdlConflict>&
|
CdlTransactionBody::get_new_conflicts() const
|
CdlTransactionBody::get_new_conflicts() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_new_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_new_conflicts");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return new_conflicts;
|
return new_conflicts;
|
}
|
}
|
|
|
const std::list<CdlConflict>&
|
const std::list<CdlConflict>&
|
CdlTransactionBody::get_new_structural_conflicts() const
|
CdlTransactionBody::get_new_structural_conflicts() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_new_structural_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_new_structural_conflicts");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return new_structural_conflicts;
|
return new_structural_conflicts;
|
}
|
}
|
|
|
const std::vector<CdlConflict>&
|
const std::vector<CdlConflict>&
|
CdlTransactionBody::get_deleted_conflicts() const
|
CdlTransactionBody::get_deleted_conflicts() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_deleted_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_deleted_conflicts");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return deleted_conflicts;
|
return deleted_conflicts;
|
}
|
}
|
|
|
const std::vector<CdlConflict>&
|
const std::vector<CdlConflict>&
|
CdlTransactionBody::get_deleted_structural_conflicts() const
|
CdlTransactionBody::get_deleted_structural_conflicts() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_deleted_structural_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_deleted_structural_conflicts");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return deleted_structural_conflicts;
|
return deleted_structural_conflicts;
|
}
|
}
|
|
|
const std::vector<CdlConflict>&
|
const std::vector<CdlConflict>&
|
CdlTransactionBody::get_resolved_conflicts() const
|
CdlTransactionBody::get_resolved_conflicts() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_resolved_conflicts");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_resolved_conflicts");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return resolved_conflicts;
|
return resolved_conflicts;
|
}
|
}
|
|
|
const std::list<CdlConflict>&
|
const std::list<CdlConflict>&
|
CdlTransactionBody::get_global_conflicts_with_solutions() const
|
CdlTransactionBody::get_global_conflicts_with_solutions() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_global_conflicts_with_solutions");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_global_conflicts_with_solutions");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return global_conflicts_with_solutions;
|
return global_conflicts_with_solutions;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
|
|
//}}}
|
//}}}
|
//{{{ Commit/cancel operations
|
//{{{ Commit/cancel operations
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
void
|
void
|
CdlTransactionBody::add_commit_cancel_op(CdlTransactionCommitCancelOp* op)
|
CdlTransactionBody::add_commit_cancel_op(CdlTransactionCommitCancelOp* op)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::add_commit_cancel_op");
|
CYG_REPORT_FUNCNAME("CdlTransaction::add_commit_cancel_op");
|
CYG_REPORT_FUNCARG2XV(this, op);
|
CYG_REPORT_FUNCARG2XV(this, op);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITIONC(0 != op);
|
CYG_PRECONDITIONC(0 != op);
|
|
|
commit_cancel_ops.push_back(op);
|
commit_cancel_ops.push_back(op);
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::cancel_last_commit_cancel_op()
|
CdlTransactionBody::cancel_last_commit_cancel_op()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::cancel_last_commit_cancel_op");
|
CYG_REPORT_FUNCNAME("CdlTransaction::cancel_last_commit_cancel_op");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlTransactionCommitCancelOp* op = *(commit_cancel_ops.rbegin());
|
CdlTransactionCommitCancelOp* op = *(commit_cancel_ops.rbegin());
|
commit_cancel_ops.pop_back();
|
commit_cancel_ops.pop_back();
|
op->cancel(this);
|
op->cancel(this);
|
delete op;
|
delete op;
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
CdlTransactionCommitCancelOp*
|
CdlTransactionCommitCancelOp*
|
CdlTransactionBody::get_last_commit_cancel_op() const
|
CdlTransactionBody::get_last_commit_cancel_op() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_last_commit_cancel_op", "result %p");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::get_last_commit_cancel_op", "result %p");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CdlTransactionCommitCancelOp* op = *(commit_cancel_ops.rbegin());
|
CdlTransactionCommitCancelOp* op = *(commit_cancel_ops.rbegin());
|
|
|
CYG_REPORT_RETVAL(op);
|
CYG_REPORT_RETVAL(op);
|
return op;
|
return op;
|
}
|
}
|
|
|
const std::vector<CdlTransactionCommitCancelOp*>&
|
const std::vector<CdlTransactionCommitCancelOp*>&
|
CdlTransactionBody::get_commit_cancel_ops() const
|
CdlTransactionBody::get_commit_cancel_ops() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_commit_cancel_ops");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_commit_cancel_ops");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return commit_cancel_ops;
|
return commit_cancel_ops;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Propagation
|
//{{{ Propagation
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Propagation should happen whenever one or more changes have been applied,
|
// Propagation should happen whenever one or more changes have been applied,
|
// so that the impact of these changes on other parts of the configuration
|
// so that the impact of these changes on other parts of the configuration
|
// can be fully assessed. The transaction keeps track of all the changes
|
// can be fully assessed. The transaction keeps track of all the changes
|
// to date and invokes appropriate node and property update handlers.
|
// to date and invokes appropriate node and property update handlers.
|
|
|
void
|
void
|
CdlTransactionBody::propagate()
|
CdlTransactionBody::propagate()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::propagate");
|
CYG_REPORT_FUNCNAME("CdlTransaction::propagate");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_INVARIANT_THISC(CdlTransactionBody);
|
CYG_INVARIANT_THISC(CdlTransactionBody);
|
|
|
// Now it is time to worry about value and active changes.
|
// Now it is time to worry about value and active changes.
|
// Propagation may result in new entries, so only the
|
// Propagation may result in new entries, so only the
|
// front item of one of the vectors is modified.
|
// front item of one of the vectors is modified.
|
while ((0 < value_changes.size()) || (0 < active_changes.size())) {
|
while ((0 < value_changes.size()) || (0 < active_changes.size())) {
|
|
|
if (0 != value_changes.size()) {
|
if (0 != value_changes.size()) {
|
|
|
CdlValuable valuable = value_changes.front();
|
CdlValuable valuable = value_changes.front();
|
value_changes.pop_front();
|
value_changes.pop_front();
|
|
|
// A value change may invalidate one or more solutions.
|
// A value change may invalidate one or more solutions.
|
// This happens during propagation rather than at the time
|
// This happens during propagation rather than at the time
|
// that the value is actually changed, so that multiple
|
// that the value is actually changed, so that multiple
|
// solutions can be applied in one go.
|
// solutions can be applied in one go.
|
std::list<CdlConflict>::iterator conf_i, conf_j;
|
std::list<CdlConflict>::iterator conf_i, conf_j;
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
(*conf_i)->update_solution_validity(valuable);
|
(*conf_i)->update_solution_validity(valuable);
|
}
|
}
|
for (conf_i = global_conflicts_with_solutions.begin();
|
for (conf_i = global_conflicts_with_solutions.begin();
|
conf_i != global_conflicts_with_solutions.end();
|
conf_i != global_conflicts_with_solutions.end();
|
) {
|
) {
|
|
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
conf_j = conf_i++;
|
conf_j = conf_i++;
|
|
|
(*conf_j)->update_solution_validity(valuable);
|
(*conf_j)->update_solution_validity(valuable);
|
if (!(*conf_j)->has_known_solution()) {
|
if (!(*conf_j)->has_known_solution()) {
|
global_conflicts_with_solutions.erase(conf_j);
|
global_conflicts_with_solutions.erase(conf_j);
|
}
|
}
|
}
|
}
|
|
|
// If the valuable is no longer loaded then there is
|
// If the valuable is no longer loaded then there is
|
// no need to worry about propagation
|
// no need to worry about propagation
|
if (0 != valuable->get_toplevel()) {
|
if (0 != valuable->get_toplevel()) {
|
|
|
// Inform the valuable itself about the update, so that
|
// Inform the valuable itself about the update, so that
|
// e.g. the value can be checked against legal_values
|
// e.g. the value can be checked against legal_values
|
valuable->update(this, CdlUpdate_ValueChange);
|
valuable->update(this, CdlUpdate_ValueChange);
|
|
|
std::vector<CdlReferrer>& referrers = valuable->referrers;
|
std::vector<CdlReferrer>& referrers = valuable->referrers;
|
std::vector<CdlReferrer>::iterator ref_i;
|
std::vector<CdlReferrer>::iterator ref_i;
|
for (ref_i = referrers.begin(); ref_i != referrers.end(); ref_i++) {
|
for (ref_i = referrers.begin(); ref_i != referrers.end(); ref_i++) {
|
ref_i->update(this, valuable, CdlUpdate_ValueChange);
|
ref_i->update(this, valuable, CdlUpdate_ValueChange);
|
}
|
}
|
}
|
}
|
|
|
} else {
|
} else {
|
|
|
CdlNode node = active_changes.front();
|
CdlNode node = active_changes.front();
|
active_changes.pop_front();
|
active_changes.pop_front();
|
|
|
if (0 != node->get_toplevel()) {
|
if (0 != node->get_toplevel()) {
|
node->update(this, CdlUpdate_ActiveChange);
|
node->update(this, CdlUpdate_ActiveChange);
|
|
|
std::vector<CdlReferrer>& referrers = node->referrers;
|
std::vector<CdlReferrer>& referrers = node->referrers;
|
std::vector<CdlReferrer>::iterator ref_i;
|
std::vector<CdlReferrer>::iterator ref_i;
|
for (ref_i = referrers.begin(); ref_i != referrers.end(); ref_i++) {
|
for (ref_i = referrers.begin(); ref_i != referrers.end(); ref_i++) {
|
ref_i->update(this, node, CdlUpdate_ActiveChange);
|
ref_i->update(this, node, CdlUpdate_ActiveChange);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
bool
|
bool
|
CdlTransactionBody::is_propagation_required() const
|
CdlTransactionBody::is_propagation_required() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::is_propagation_required", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::is_propagation_required", "result %d");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
bool result = false;
|
bool result = false;
|
|
|
if ((0 != value_changes.size()) || (0 != active_changes.size())) {
|
if ((0 != value_changes.size()) || (0 != active_changes.size())) {
|
result = true;
|
result = true;
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
void
|
void
|
CdlTransactionBody::add_legal_values_change(CdlValuable valuable)
|
CdlTransactionBody::add_legal_values_change(CdlValuable valuable)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::add_legal_values_change");
|
CYG_REPORT_FUNCNAME("CdlTransaction::add_legal_values_change");
|
CYG_REPORT_FUNCARG2XV(this, valuable);
|
CYG_REPORT_FUNCARG2XV(this, valuable);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(valuable);
|
CYG_PRECONDITION_CLASSC(valuable);
|
|
|
legal_values_changes.insert(valuable);
|
legal_values_changes.insert(valuable);
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
const std::set<CdlValuable>&
|
const std::set<CdlValuable>&
|
CdlTransactionBody::get_legal_values_changes() const
|
CdlTransactionBody::get_legal_values_changes() const
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_legal_values_changes");
|
CYG_REPORT_FUNCNAME("CdlTransaction::get_legal_values_changes");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return legal_values_changes;
|
return legal_values_changes;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Cancel
|
//{{{ Cancel
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Cancellation is straightforward, essentially it just involves clearing
|
// Cancellation is straightforward, essentially it just involves clearing
|
// out all of the STL containers. The transaction object can then be-used,
|
// out all of the STL containers. The transaction object can then be-used,
|
// so fields like parent and toplevel must not change.
|
// so fields like parent and toplevel must not change.
|
void
|
void
|
CdlTransactionBody::cancel()
|
CdlTransactionBody::cancel()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::cancel");
|
CYG_REPORT_FUNCNAME("CdlTransaction::cancel");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_INVARIANT_THISC(CdlTransactionBody);
|
CYG_INVARIANT_THISC(CdlTransactionBody);
|
|
|
// First take care of the cancel ops, if any, in case a cancel op
|
// First take care of the cancel ops, if any, in case a cancel op
|
// depends on some of the other transaction state.
|
// depends on some of the other transaction state.
|
std::vector<CdlTransactionCommitCancelOp*>::reverse_iterator cancel_i;
|
std::vector<CdlTransactionCommitCancelOp*>::reverse_iterator cancel_i;
|
for (cancel_i = commit_cancel_ops.rbegin(); cancel_i != commit_cancel_ops.rend(); cancel_i++) {
|
for (cancel_i = commit_cancel_ops.rbegin(); cancel_i != commit_cancel_ops.rend(); cancel_i++) {
|
(*cancel_i)->cancel(this);
|
(*cancel_i)->cancel(this);
|
delete *cancel_i;
|
delete *cancel_i;
|
*cancel_i = 0;
|
*cancel_i = 0;
|
}
|
}
|
commit_cancel_ops.clear();
|
commit_cancel_ops.clear();
|
|
|
this->changes.clear();
|
this->changes.clear();
|
std::list<CdlConflict>::iterator conf_i;
|
std::list<CdlConflict>::iterator conf_i;
|
for (conf_i = this->new_conflicts.begin(); conf_i != this->new_conflicts.end(); conf_i++) {
|
for (conf_i = this->new_conflicts.begin(); conf_i != this->new_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
delete *conf_i;
|
delete *conf_i;
|
}
|
}
|
this->new_conflicts.clear();
|
this->new_conflicts.clear();
|
for (conf_i = this->new_structural_conflicts.begin(); conf_i != this->new_structural_conflicts.end(); conf_i++) {
|
for (conf_i = this->new_structural_conflicts.begin(); conf_i != this->new_structural_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
delete *conf_i;
|
delete *conf_i;
|
}
|
}
|
this->new_structural_conflicts.clear();
|
this->new_structural_conflicts.clear();
|
|
|
this->deleted_structural_conflicts.clear();
|
this->deleted_structural_conflicts.clear();
|
this->deleted_conflicts.clear();
|
this->deleted_conflicts.clear();
|
|
|
// Any conflicts created and resolved during this transaction will
|
// Any conflicts created and resolved during this transaction will
|
// still be present in resolved_conflicts. Some global conflicts
|
// still be present in resolved_conflicts. Some global conflicts
|
// may be there as well.
|
// may be there as well.
|
std::vector<CdlConflict>::iterator conf_i2;
|
std::vector<CdlConflict>::iterator conf_i2;
|
for (conf_i2 = this->resolved_conflicts.begin(); conf_i2 != this->resolved_conflicts.end(); conf_i2++) {
|
for (conf_i2 = this->resolved_conflicts.begin(); conf_i2 != this->resolved_conflicts.end(); conf_i2++) {
|
if (this == (*conf_i2)->transaction) {
|
if (this == (*conf_i2)->transaction) {
|
delete (*conf_i2);
|
delete (*conf_i2);
|
}
|
}
|
}
|
}
|
this->resolved_conflicts.clear();
|
this->resolved_conflicts.clear();
|
|
|
// Any global conflicts which have been updated with a solution need
|
// Any global conflicts which have been updated with a solution need
|
// to have that solution cleared. Currently no attempt is made to
|
// to have that solution cleared. Currently no attempt is made to
|
// keep solutions valid for global conflicts.
|
// keep solutions valid for global conflicts.
|
for (conf_i = this->global_conflicts_with_solutions.begin();
|
for (conf_i = this->global_conflicts_with_solutions.begin();
|
conf_i != this->global_conflicts_with_solutions.end();
|
conf_i != this->global_conflicts_with_solutions.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
(*conf_i)->clear_solution();
|
(*conf_i)->clear_solution();
|
}
|
}
|
this->global_conflicts_with_solutions.clear();
|
this->global_conflicts_with_solutions.clear();
|
|
|
this->activated.clear();
|
this->activated.clear();
|
this->deactivated.clear();
|
this->deactivated.clear();
|
this->legal_values_changes.clear();
|
this->legal_values_changes.clear();
|
this->value_changes.clear();
|
this->value_changes.clear();
|
this->active_changes.clear();
|
this->active_changes.clear();
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Commit
|
//{{{ Commit
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// The commit operation. There are two main branches for this code. The
|
// The commit operation. There are two main branches for this code. The
|
// first branch deals with sub-transactions, and basically involves
|
// first branch deals with sub-transactions, and basically involves
|
// transferring changes from the sub-transaction to the parent. It is
|
// transferring changes from the sub-transaction to the parent. It is
|
// assumed that the sub-transaction has been fully propagated, so
|
// assumed that the sub-transaction has been fully propagated, so
|
// data can just be transferred from the child to the parent.
|
// data can just be transferred from the child to the parent.
|
//
|
//
|
// The second branch involves committing changes from a transaction to
|
// The second branch involves committing changes from a transaction to
|
// the toplevel, invoking the transaction callback if necessary.
|
// the toplevel, invoking the transaction callback if necessary.
|
|
|
void
|
void
|
CdlTransactionBody::commit()
|
CdlTransactionBody::commit()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::commit");
|
CYG_REPORT_FUNCNAME("CdlTransaction::commit");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_INVARIANT_THISC(CdlTransactionBody);
|
CYG_INVARIANT_THISC(CdlTransactionBody);
|
|
|
std::map<CdlValuable, CdlValue>::iterator map_i;
|
std::map<CdlValuable, CdlValue>::iterator map_i;
|
std::list<CdlConflict>::iterator conf_i, conf_j;
|
std::list<CdlConflict>::iterator conf_i, conf_j;
|
std::vector<CdlConflict>::const_iterator conf_i2, conf_j2;
|
std::vector<CdlConflict>::const_iterator conf_i2, conf_j2;
|
std::set<CdlNode>::iterator set_i, set_j, set_k;
|
std::set<CdlNode>::iterator set_i, set_j, set_k;
|
std::set<CdlValuable>::iterator set_i2, set_j2;
|
std::set<CdlValuable>::iterator set_i2, set_j2;
|
|
|
if (0 != parent) {
|
if (0 != parent) {
|
// Any conflicts that were solved by the inference engine further
|
// Any conflicts that were solved by the inference engine further
|
// down are still resolved.
|
// down are still resolved.
|
// Great care has to be taken with conflict ownership. The following
|
// Great care has to be taken with conflict ownership. The following
|
// cases have to be considered.
|
// cases have to be considered.
|
// 1) the resolved conflict is global, its transaction is zero, this
|
// 1) the resolved conflict is global, its transaction is zero, this
|
// conflict must only be destroyed if the toplevel transaction
|
// conflict must only be destroyed if the toplevel transaction
|
// is committed - at which time time the conflict should appear
|
// is committed - at which time time the conflict should appear
|
// on the deleted_conflicts lists.
|
// on the deleted_conflicts lists.
|
// 2) the conflict belongs to a higher level transaction, we have
|
// 2) the conflict belongs to a higher level transaction, we have
|
// recursed a certain amount trying to resolve it e.g. to explore
|
// recursed a certain amount trying to resolve it e.g. to explore
|
// OR branches of the tree. Again the resolved conflict can only
|
// OR branches of the tree. Again the resolved conflict can only
|
// be destroyed when the appropriate higher-level commit happens,
|
// be destroyed when the appropriate higher-level commit happens,
|
// and should appear on the deleted conflicts list.
|
// and should appear on the deleted conflicts list.
|
// 3) the conflict was created and resolved further down the tree.
|
// 3) the conflict was created and resolved further down the tree.
|
// We are keeping it around for informational purposes only.
|
// We are keeping it around for informational purposes only.
|
// Associating it with this transaction allows the code to
|
// Associating it with this transaction allows the code to
|
// distinguish this case from (1) and (2).
|
// distinguish this case from (1) and (2).
|
for (conf_i2 = resolved_conflicts.begin(); conf_i2 != resolved_conflicts.end(); conf_i2++) {
|
for (conf_i2 = resolved_conflicts.begin(); conf_i2 != resolved_conflicts.end(); conf_i2++) {
|
CdlConflict conf = *conf_i2;
|
CdlConflict conf = *conf_i2;
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
CYG_LOOP_INVARIANTC(parent->resolved_conflicts.end() == \
|
CYG_LOOP_INVARIANTC(parent->resolved_conflicts.end() == \
|
std::find(parent->resolved_conflicts.begin(), \
|
std::find(parent->resolved_conflicts.begin(), \
|
parent->resolved_conflicts.end(), conf));
|
parent->resolved_conflicts.end(), conf));
|
parent->resolved_conflicts.push_back(conf);
|
parent->resolved_conflicts.push_back(conf);
|
parent->dirty = true;
|
parent->dirty = true;
|
if (this == conf->transaction) {
|
if (this == conf->transaction) {
|
conf->transaction = parent;
|
conf->transaction = parent;
|
}
|
}
|
}
|
}
|
resolved_conflicts.clear();
|
resolved_conflicts.clear();
|
|
|
// Any global conflicts for which solutions were found in the
|
// Any global conflicts for which solutions were found in the
|
// sub-transaction still have solutions in the parent.
|
// sub-transaction still have solutions in the parent.
|
for (conf_i = global_conflicts_with_solutions.begin(); conf_i != global_conflicts_with_solutions.end(); conf_i++) {
|
for (conf_i = global_conflicts_with_solutions.begin(); conf_i != global_conflicts_with_solutions.end(); conf_i++) {
|
|
|
CdlConflict conf = *conf_i;
|
CdlConflict conf = *conf_i;
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
|
|
// It is not clear that this search is actually useful, especially
|
// It is not clear that this search is actually useful, especially
|
// given that the solution is currently stored with the conflict
|
// given that the solution is currently stored with the conflict
|
// rather than with the transaction.
|
// rather than with the transaction.
|
conf_j = std::find(parent->global_conflicts_with_solutions.begin(),
|
conf_j = std::find(parent->global_conflicts_with_solutions.begin(),
|
parent->global_conflicts_with_solutions.end(),
|
parent->global_conflicts_with_solutions.end(),
|
conf);
|
conf);
|
if (conf_j == parent->global_conflicts_with_solutions.end()) {
|
if (conf_j == parent->global_conflicts_with_solutions.end()) {
|
parent->global_conflicts_with_solutions.push_back(conf);
|
parent->global_conflicts_with_solutions.push_back(conf);
|
parent->dirty = true;
|
parent->dirty = true;
|
}
|
}
|
}
|
}
|
global_conflicts_with_solutions.clear();
|
global_conflicts_with_solutions.clear();
|
|
|
// Now take care of deleted conflicts.
|
// Now take care of deleted conflicts.
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
CdlConflict conf = *conf_i2;
|
CdlConflict conf = *conf_i2;
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
// Possibilities to consider:
|
// Possibilities to consider:
|
// 1) the conflict may have been local to the parent transaction,
|
// 1) the conflict may have been local to the parent transaction,
|
// in which case it can be deleted.
|
// in which case it can be deleted.
|
// 2) the conflict may have been created in a higher-level
|
// 2) the conflict may have been created in a higher-level
|
// transaction, in which case it has to be moved to the
|
// transaction, in which case it has to be moved to the
|
// parent's deleted_conflicts vector.
|
// parent's deleted_conflicts vector.
|
// 3) the conflict may also have been global, again it needs
|
// 3) the conflict may also have been global, again it needs
|
// to be propagated into the parent's deleted_conflicts vector.
|
// to be propagated into the parent's deleted_conflicts vector.
|
//
|
//
|
// But that is not the whole story. If this sub-transaction was
|
// But that is not the whole story. If this sub-transaction was
|
// created specifically to resolve the conflict then the latter
|
// created specifically to resolve the conflict then the latter
|
// should appear on the resolved vector and not be destroyed
|
// should appear on the resolved vector and not be destroyed
|
// immediately. This is true for both global and per-transaction
|
// immediately. This is true for both global and per-transaction
|
// conflicts.
|
// conflicts.
|
//
|
//
|
// For global conflicts it is also necessary to worry about
|
// For global conflicts it is also necessary to worry about
|
// the global_conflicts_with_solutions list, that has to be
|
// the global_conflicts_with_solutions list, that has to be
|
// kept in synch with the rest of the world.
|
// kept in synch with the rest of the world.
|
conf_i = std::find(parent->new_conflicts.begin(), parent->new_conflicts.end(), conf);
|
conf_i = std::find(parent->new_conflicts.begin(), parent->new_conflicts.end(), conf);
|
bool can_delete = false;
|
bool can_delete = false;
|
if (conf_i != parent->new_conflicts.end()) {
|
if (conf_i != parent->new_conflicts.end()) {
|
parent->new_conflicts.erase(conf_i);
|
parent->new_conflicts.erase(conf_i);
|
can_delete = true;
|
can_delete = true;
|
} else {
|
} else {
|
parent->deleted_conflicts.push_back(conf);
|
parent->deleted_conflicts.push_back(conf);
|
}
|
}
|
if (0 == conf->transaction) {
|
if (0 == conf->transaction) {
|
conf_j = std::find(parent->global_conflicts_with_solutions.begin(),
|
conf_j = std::find(parent->global_conflicts_with_solutions.begin(),
|
parent->global_conflicts_with_solutions.end(),
|
parent->global_conflicts_with_solutions.end(),
|
conf);
|
conf);
|
if (conf_j != parent->global_conflicts_with_solutions.end()) {
|
if (conf_j != parent->global_conflicts_with_solutions.end()) {
|
parent->global_conflicts_with_solutions.erase(conf_j);
|
parent->global_conflicts_with_solutions.erase(conf_j);
|
}
|
}
|
}
|
}
|
if (conf == this->conflict) {
|
if (conf == this->conflict) {
|
// The conflict may have been fortuitously resolved lower down,
|
// The conflict may have been fortuitously resolved lower down,
|
// in which case it will have appeared in this->resolved_conflicts()
|
// in which case it will have appeared in this->resolved_conflicts()
|
// and copied already.
|
// and copied already.
|
conf_j2 = std::find(parent->resolved_conflicts.begin(), parent->resolved_conflicts.end(), conf);
|
conf_j2 = std::find(parent->resolved_conflicts.begin(), parent->resolved_conflicts.end(), conf);
|
if (conf_j2 == parent->resolved_conflicts.end()) {
|
if (conf_j2 == parent->resolved_conflicts.end()) {
|
parent->resolved_conflicts.push_back(conf);
|
parent->resolved_conflicts.push_back(conf);
|
parent->dirty = true;
|
parent->dirty = true;
|
}
|
}
|
} else if (can_delete) {
|
} else if (can_delete) {
|
delete conf;
|
delete conf;
|
}
|
}
|
}
|
}
|
// Unnecessary, but let's keep things clean.
|
// Unnecessary, but let's keep things clean.
|
deleted_conflicts.clear();
|
deleted_conflicts.clear();
|
|
|
// Deleted structural conflicts. For now the inference engine can do nothing with
|
// Deleted structural conflicts. For now the inference engine can do nothing with
|
// these so they are a bit simpler.
|
// these so they are a bit simpler.
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
|
|
CdlConflict conf = *conf_i2;
|
CdlConflict conf = *conf_i2;
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
CYG_LOOP_INVARIANT_CLASSC(conf);
|
conf_i = std::find(parent->new_structural_conflicts.begin(), parent->new_structural_conflicts.end(), conf);
|
conf_i = std::find(parent->new_structural_conflicts.begin(), parent->new_structural_conflicts.end(), conf);
|
if (conf_i != parent->new_structural_conflicts.end()) {
|
if (conf_i != parent->new_structural_conflicts.end()) {
|
parent->new_structural_conflicts.erase(conf_i);
|
parent->new_structural_conflicts.erase(conf_i);
|
delete conf;
|
delete conf;
|
} else {
|
} else {
|
parent->deleted_structural_conflicts.push_back(conf);
|
parent->deleted_structural_conflicts.push_back(conf);
|
}
|
}
|
}
|
}
|
deleted_structural_conflicts.clear();
|
deleted_structural_conflicts.clear();
|
|
|
// All value changes need to be propagated from the child to the parent.
|
// All value changes need to be propagated from the child to the parent.
|
// Also, these value changes may invalidate existing solutions.
|
// Also, these value changes may invalidate existing solutions.
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(map_i->first);
|
CYG_LOOP_INVARIANT_CLASSC(map_i->first);
|
CYG_LOOP_INVARIANT_CLASSOC(map_i->second);
|
CYG_LOOP_INVARIANT_CLASSOC(map_i->second);
|
parent->changes[map_i->first] = map_i->second;
|
parent->changes[map_i->first] = map_i->second;
|
for (conf_i = parent->new_conflicts.begin(); conf_i != parent->new_conflicts.end(); conf_i++) {
|
for (conf_i = parent->new_conflicts.begin(); conf_i != parent->new_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
(*conf_i)->update_solution_validity(map_i->first);
|
(*conf_i)->update_solution_validity(map_i->first);
|
}
|
}
|
for (conf_i = parent->global_conflicts_with_solutions.begin();
|
for (conf_i = parent->global_conflicts_with_solutions.begin();
|
conf_i != parent->global_conflicts_with_solutions.end();
|
conf_i != parent->global_conflicts_with_solutions.end();
|
) {
|
) {
|
|
|
conf_j = conf_i++;
|
conf_j = conf_i++;
|
CYG_LOOP_INVARIANT_CLASSC(*conf_j);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_j);
|
|
|
(*conf_j)->update_solution_validity(map_i->first);
|
(*conf_j)->update_solution_validity(map_i->first);
|
if (!(*conf_j)->has_known_solution()) {
|
if (!(*conf_j)->has_known_solution()) {
|
parent->global_conflicts_with_solutions.erase(conf_j);
|
parent->global_conflicts_with_solutions.erase(conf_j);
|
}
|
}
|
}
|
}
|
}
|
}
|
changes.clear();
|
changes.clear();
|
|
|
// Continue propagating the conflicts.New conflicts can just
|
// Continue propagating the conflicts.New conflicts can just
|
// be added.
|
// be added.
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
parent->new_conflicts.push_back(*conf_i);
|
parent->new_conflicts.push_back(*conf_i);
|
parent->dirty = true;
|
parent->dirty = true;
|
(*conf_i)->transaction = parent;
|
(*conf_i)->transaction = parent;
|
}
|
}
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
parent->new_structural_conflicts.push_back(*conf_i);
|
parent->new_structural_conflicts.push_back(*conf_i);
|
parent->dirty = true;
|
parent->dirty = true;
|
(*conf_i)->transaction = parent;
|
(*conf_i)->transaction = parent;
|
}
|
}
|
// The cancel operation at the end will delete new conflicts, so the
|
// The cancel operation at the end will delete new conflicts, so the
|
// containers had better be cleared here.
|
// containers had better be cleared here.
|
new_conflicts.clear();
|
new_conflicts.clear();
|
new_structural_conflicts.clear();
|
new_structural_conflicts.clear();
|
|
|
|
|
// Also keep track of nodes that have become active or inactive.
|
// Also keep track of nodes that have become active or inactive.
|
set_j = parent->activated.begin();
|
set_j = parent->activated.begin();
|
for (set_i = activated.begin(); set_i != activated.end(); set_i++) {
|
for (set_i = activated.begin(); set_i != activated.end(); set_i++) {
|
set_j = parent->activated.insert(set_j, *set_i);
|
set_j = parent->activated.insert(set_j, *set_i);
|
set_k = parent->deactivated.find(*set_i);
|
set_k = parent->deactivated.find(*set_i);
|
if (set_k != parent->deactivated.end()) {
|
if (set_k != parent->deactivated.end()) {
|
parent->deactivated.erase(set_k);
|
parent->deactivated.erase(set_k);
|
}
|
}
|
}
|
}
|
|
|
set_j = parent->deactivated.begin();
|
set_j = parent->deactivated.begin();
|
for (set_i = deactivated.begin(); set_i != deactivated.end(); set_i++) {
|
for (set_i = deactivated.begin(); set_i != deactivated.end(); set_i++) {
|
set_j = parent->deactivated.insert(set_j, *set_i);
|
set_j = parent->deactivated.insert(set_j, *set_i);
|
set_k = parent->activated.find(*set_i);
|
set_k = parent->activated.find(*set_i);
|
if (set_k != parent->activated.end()) {
|
if (set_k != parent->activated.end()) {
|
parent->activated.erase(set_k);
|
parent->activated.erase(set_k);
|
}
|
}
|
}
|
}
|
activated.clear();
|
activated.clear();
|
deactivated.clear();
|
deactivated.clear();
|
|
|
// Keep track of other property changes.
|
// Keep track of other property changes.
|
set_j2 = parent->legal_values_changes.begin();
|
set_j2 = parent->legal_values_changes.begin();
|
for (set_i2 = legal_values_changes.begin(); set_i2 != legal_values_changes.end(); set_i2++) {
|
for (set_i2 = legal_values_changes.begin(); set_i2 != legal_values_changes.end(); set_i2++) {
|
set_j2 = parent->legal_values_changes.insert(set_j2, *set_i2);
|
set_j2 = parent->legal_values_changes.insert(set_j2, *set_i2);
|
}
|
}
|
legal_values_changes.clear();
|
legal_values_changes.clear();
|
|
|
// Any pending commit/cancel ops needs to be transferred to the parent
|
// Any pending commit/cancel ops needs to be transferred to the parent
|
parent->commit_cancel_ops.insert(parent->commit_cancel_ops.end(),
|
parent->commit_cancel_ops.insert(parent->commit_cancel_ops.end(),
|
this->commit_cancel_ops.begin(), this->commit_cancel_ops.end());
|
this->commit_cancel_ops.begin(), this->commit_cancel_ops.end());
|
this->commit_cancel_ops.clear();
|
this->commit_cancel_ops.clear();
|
|
|
} else {
|
} else {
|
|
|
CYG_ASSERT_CLASSC(toplevel);
|
CYG_ASSERT_CLASSC(toplevel);
|
|
|
// If there is a registered callback function, it is necessary to fill
|
// If there is a registered callback function, it is necessary to fill
|
// in the remaining fields of the all_changes callback structure. This
|
// in the remaining fields of the all_changes callback structure. This
|
// should happen before any conflicts get deleted. The actual callback
|
// should happen before any conflicts get deleted. The actual callback
|
// is invoked at the end, once all the changes have been moved to
|
// is invoked at the end, once all the changes have been moved to
|
// the toplevel.
|
// the toplevel.
|
CdlTransactionCallback all_changes(this);
|
CdlTransactionCallback all_changes(this);
|
if (0 != callback_fn) {
|
if (0 != callback_fn) {
|
|
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
if (0 == map_i->first->get_toplevel()) {
|
if (0 == map_i->first->get_toplevel()) {
|
continue;
|
continue;
|
}
|
}
|
CdlValueFlavor flavor = map_i->second.get_flavor();
|
CdlValueFlavor flavor = map_i->second.get_flavor();
|
const CdlValue& old_value = map_i->first->get_whole_value();
|
const CdlValue& old_value = map_i->first->get_whole_value();
|
CYG_LOOP_INVARIANTC(flavor == old_value.get_flavor());
|
CYG_LOOP_INVARIANTC(flavor == old_value.get_flavor());
|
bool value_changed = false;
|
bool value_changed = false;
|
|
|
if (old_value.get_source() != map_i->second.get_source()) {
|
if (old_value.get_source() != map_i->second.get_source()) {
|
all_changes.value_source_changes.push_back(map_i->first);
|
all_changes.value_source_changes.push_back(map_i->first);
|
}
|
}
|
if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) {
|
if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) {
|
if (old_value.is_enabled() != map_i->second.is_enabled()) {
|
if (old_value.is_enabled() != map_i->second.is_enabled()) {
|
value_changed = true;
|
value_changed = true;
|
}
|
}
|
}
|
}
|
if (!value_changed && ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor))) {
|
if (!value_changed && ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor))) {
|
if (old_value.get_simple_value() != map_i->second.get_simple_value()) {
|
if (old_value.get_simple_value() != map_i->second.get_simple_value()) {
|
value_changed = true;
|
value_changed = true;
|
}
|
}
|
}
|
}
|
if (value_changed) {
|
if (value_changed) {
|
all_changes.value_changes.push_back(map_i->first);
|
all_changes.value_changes.push_back(map_i->first);
|
}
|
}
|
}
|
}
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
all_changes.new_conflicts.push_back(*conf_i);
|
all_changes.new_conflicts.push_back(*conf_i);
|
}
|
}
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
all_changes.new_structural_conflicts.push_back(*conf_i);
|
all_changes.new_structural_conflicts.push_back(*conf_i);
|
}
|
}
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
CdlNode node = (*conf_i2)->get_node();
|
CdlNode node = (*conf_i2)->get_node();
|
CYG_LOOP_INVARIANT_CLASSC(node);
|
CYG_LOOP_INVARIANT_CLASSC(node);
|
|
|
all_changes.nodes_with_resolved_conflicts.push_back(node);
|
all_changes.nodes_with_resolved_conflicts.push_back(node);
|
}
|
}
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
CdlNode node = (*conf_i2)->get_node();
|
CdlNode node = (*conf_i2)->get_node();
|
CYG_LOOP_INVARIANT_CLASSC(node);
|
CYG_LOOP_INVARIANT_CLASSC(node);
|
|
|
all_changes.nodes_with_resolved_structural_conflicts.push_back(node);
|
all_changes.nodes_with_resolved_structural_conflicts.push_back(node);
|
}
|
}
|
for (set_i = activated.begin(); set_i != activated.end(); set_i++) {
|
for (set_i = activated.begin(); set_i != activated.end(); set_i++) {
|
if (0 != (*set_i)->get_toplevel()) {
|
if (0 != (*set_i)->get_toplevel()) {
|
all_changes.active_changes.push_back(*set_i);
|
all_changes.active_changes.push_back(*set_i);
|
}
|
}
|
}
|
}
|
for (set_i = deactivated.begin(); set_i != deactivated.end(); set_i++) {
|
for (set_i = deactivated.begin(); set_i != deactivated.end(); set_i++) {
|
if (0 != (*set_i)->get_toplevel()) {
|
if (0 != (*set_i)->get_toplevel()) {
|
all_changes.active_changes.push_back(*set_i);
|
all_changes.active_changes.push_back(*set_i);
|
}
|
}
|
}
|
}
|
for (set_i2 = legal_values_changes.begin(); set_i2 != legal_values_changes.end(); set_i2++) {
|
for (set_i2 = legal_values_changes.begin(); set_i2 != legal_values_changes.end(); set_i2++) {
|
if (0 != (*set_i)->get_toplevel()) {
|
if (0 != (*set_i)->get_toplevel()) {
|
all_changes.legal_values_changes.push_back(*set_i2);
|
all_changes.legal_values_changes.push_back(*set_i2);
|
}
|
}
|
}
|
}
|
legal_values_changes.clear();
|
legal_values_changes.clear();
|
}
|
}
|
|
|
// All new values need to be installed in the appropriate valuable.
|
// All new values need to be installed in the appropriate valuable.
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(map_i->first);
|
CYG_LOOP_INVARIANT_CLASSC(map_i->first);
|
CYG_LOOP_INVARIANT_CLASSOC(map_i->second);
|
CYG_LOOP_INVARIANT_CLASSOC(map_i->second);
|
map_i->first->value = map_i->second;
|
map_i->first->value = map_i->second;
|
}
|
}
|
changes.clear();
|
changes.clear();
|
|
|
// Sort out the conflicts. New conflicts can just be added, although
|
// Sort out the conflicts. New conflicts can just be added, although
|
// care has to be taken to clear state - currently no attempt is
|
// care has to be taken to clear state - currently no attempt is
|
// made to check solution validity for global conflicts.
|
// made to check solution validity for global conflicts.
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
toplevel->conflicts.push_back(*conf_i);
|
toplevel->conflicts.push_back(*conf_i);
|
(*conf_i)->transaction = 0;
|
(*conf_i)->transaction = 0;
|
(*conf_i)->clear_solution();
|
(*conf_i)->clear_solution();
|
}
|
}
|
new_conflicts.clear();
|
new_conflicts.clear();
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
for (conf_i = new_structural_conflicts.begin(); conf_i != new_structural_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
toplevel->structural_conflicts.push_back(*conf_i);
|
toplevel->structural_conflicts.push_back(*conf_i);
|
(*conf_i)->transaction = 0;
|
(*conf_i)->transaction = 0;
|
(*conf_i)->clear_solution();
|
(*conf_i)->clear_solution();
|
}
|
}
|
new_structural_conflicts.clear();
|
new_structural_conflicts.clear();
|
|
|
// Resolved conflicts can be either global or per-transaction
|
// Resolved conflicts can be either global or per-transaction
|
// ones. If the former then the conflict will also be present
|
// ones. If the former then the conflict will also be present
|
// in deleted_conflicts and will get deleted shortly.
|
// in deleted_conflicts and will get deleted shortly.
|
for (conf_i2 = resolved_conflicts.begin(); conf_i2 != resolved_conflicts.end(); conf_i2++) {
|
for (conf_i2 = resolved_conflicts.begin(); conf_i2 != resolved_conflicts.end(); conf_i2++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i2);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i2);
|
if (0 != (*conf_i2)->transaction) {
|
if (0 != (*conf_i2)->transaction) {
|
delete *conf_i2;
|
delete *conf_i2;
|
}
|
}
|
}
|
}
|
resolved_conflicts.clear();
|
resolved_conflicts.clear();
|
|
|
// Now process conflicts that have gone away. These must actually
|
// Now process conflicts that have gone away. These must actually
|
// be deleted.
|
// be deleted.
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_conflicts.begin(); conf_i2 != deleted_conflicts.end(); conf_i2++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i2);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i2);
|
std::list<CdlConflict>::iterator tmp;
|
std::list<CdlConflict>::iterator tmp;
|
tmp = std::find(toplevel->conflicts.begin(), toplevel->conflicts.end(), *conf_i2);
|
tmp = std::find(toplevel->conflicts.begin(), toplevel->conflicts.end(), *conf_i2);
|
CYG_LOOP_INVARIANTC(tmp != toplevel->conflicts.end());
|
CYG_LOOP_INVARIANTC(tmp != toplevel->conflicts.end());
|
toplevel->conflicts.erase(tmp);
|
toplevel->conflicts.erase(tmp);
|
delete *conf_i2;
|
delete *conf_i2;
|
}
|
}
|
deleted_conflicts.clear();
|
deleted_conflicts.clear();
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
for (conf_i2 = deleted_structural_conflicts.begin(); conf_i2 != deleted_structural_conflicts.end(); conf_i2++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i2);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i2);
|
std::list<CdlConflict>::iterator tmp;
|
std::list<CdlConflict>::iterator tmp;
|
tmp = std::find(toplevel->structural_conflicts.begin(), toplevel->structural_conflicts.end(), *conf_i2);
|
tmp = std::find(toplevel->structural_conflicts.begin(), toplevel->structural_conflicts.end(), *conf_i2);
|
CYG_LOOP_INVARIANTC(tmp != toplevel->structural_conflicts.end());
|
CYG_LOOP_INVARIANTC(tmp != toplevel->structural_conflicts.end());
|
toplevel->structural_conflicts.erase(tmp);
|
toplevel->structural_conflicts.erase(tmp);
|
delete *conf_i2;
|
delete *conf_i2;
|
}
|
}
|
deleted_structural_conflicts.clear();
|
deleted_structural_conflicts.clear();
|
|
|
// Any global conflicts with solutions need to have their solutions cleared,
|
// Any global conflicts with solutions need to have their solutions cleared,
|
// since currently no attempt is made to preserve their accuracy.
|
// since currently no attempt is made to preserve their accuracy.
|
for (conf_i = global_conflicts_with_solutions.begin(); conf_i != global_conflicts_with_solutions.end(); conf_i++) {
|
for (conf_i = global_conflicts_with_solutions.begin(); conf_i != global_conflicts_with_solutions.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
(*conf_i)->clear_solution();
|
(*conf_i)->clear_solution();
|
}
|
}
|
global_conflicts_with_solutions.clear();
|
global_conflicts_with_solutions.clear();
|
|
|
for (set_i = activated.begin(); set_i != activated.end(); set_i++) {
|
for (set_i = activated.begin(); set_i != activated.end(); set_i++) {
|
(*set_i)->active = true;
|
(*set_i)->active = true;
|
}
|
}
|
for (set_i = deactivated.begin(); set_i != deactivated.end(); set_i++) {
|
for (set_i = deactivated.begin(); set_i != deactivated.end(); set_i++) {
|
(*set_i)->active = false;
|
(*set_i)->active = false;
|
}
|
}
|
activated.clear();
|
activated.clear();
|
deactivated.clear();
|
deactivated.clear();
|
|
|
// Invoke all pending commit operations
|
// Invoke all pending commit operations
|
std::vector<CdlTransactionCommitCancelOp*>::iterator commit_i;
|
std::vector<CdlTransactionCommitCancelOp*>::iterator commit_i;
|
for (commit_i = commit_cancel_ops.begin(); commit_i != commit_cancel_ops.end(); commit_i++) {
|
for (commit_i = commit_cancel_ops.begin(); commit_i != commit_cancel_ops.end(); commit_i++) {
|
(*commit_i)->commit(this);
|
(*commit_i)->commit(this);
|
delete *commit_i;
|
delete *commit_i;
|
*commit_i = 0;
|
*commit_i = 0;
|
}
|
}
|
commit_cancel_ops.clear();
|
commit_cancel_ops.clear();
|
|
|
// Finally take care of the callback.
|
// Finally take care of the callback.
|
if (0 != callback_fn) {
|
if (0 != callback_fn) {
|
(*callback_fn)(all_changes);
|
(*callback_fn)(all_changes);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Solution support
|
//{{{ Solution support
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Saving a solution basically involves remembering what changes took place
|
// Saving a solution basically involves remembering what changes took place
|
// in the corresponding sub-transaction. There is no need to worry about
|
// in the corresponding sub-transaction. There is no need to worry about
|
// other data in the sub-transaction such as conflicts, because there
|
// other data in the sub-transaction such as conflicts, because there
|
// are no actual value changes.
|
// are no actual value changes.
|
|
|
void
|
void
|
CdlTransactionBody::save_solution()
|
CdlTransactionBody::save_solution()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::save_solution");
|
CYG_REPORT_FUNCNAME("CdlTransaction::save_solution");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
// Solutions should only be applicable to sub-transactions immediately
|
// Solutions should only be applicable to sub-transactions immediately
|
// below the main transaction, since that is the only level at which
|
// below the main transaction, since that is the only level at which
|
// inference callbacks occur
|
// inference callbacks occur
|
CYG_PRECONDITIONC((0 != parent) && (0 == parent->parent));
|
CYG_PRECONDITIONC((0 != parent) && (0 == parent->parent));
|
|
|
CYG_PRECONDITION_CLASSC(conflict);
|
CYG_PRECONDITION_CLASSC(conflict);
|
CYG_PRECONDITIONC(0 == conflict->solution.size());
|
CYG_PRECONDITIONC(0 == conflict->solution.size());
|
|
|
std::map<CdlValuable, CdlValue>::const_iterator map_i;
|
std::map<CdlValuable, CdlValue>::const_iterator map_i;
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
for (map_i = changes.begin(); map_i != changes.end(); map_i++) {
|
// If the valuable was calculated or is otherwise non-modifiable,
|
// If the valuable was calculated or is otherwise non-modifiable,
|
// there is no point in storing it with the solution since the
|
// there is no point in storing it with the solution since the
|
// information is unlikely to be of interest to the user.
|
// information is unlikely to be of interest to the user.
|
CdlValuable valuable = map_i->first;
|
CdlValuable valuable = map_i->first;
|
if (valuable->is_modifiable()) {
|
if (valuable->is_modifiable()) {
|
conflict->solution.push_back(*map_i);
|
conflict->solution.push_back(*map_i);
|
}
|
}
|
}
|
}
|
|
|
// save_solution() should operate like commit() or cancel(), i.e.
|
// save_solution() should operate like commit() or cancel(), i.e.
|
// it leaves an empty sub-transaction. This sub-transaction cannot
|
// it leaves an empty sub-transaction. This sub-transaction cannot
|
// actually be re-used at present because it still references a
|
// actually be re-used at present because it still references a
|
// conflict for which a solution is now already in place, but that
|
// conflict for which a solution is now already in place, but that
|
// may get cleaned up in future.
|
// may get cleaned up in future.
|
this->cancel();
|
this->cancel();
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Can a solution be applied without e.g. overwriting a user value with
|
// Can a solution be applied without e.g. overwriting a user value with
|
// an inferred value. There is a setting inference_override which controls
|
// an inferred value. There is a setting inference_override which controls
|
// this. Making a previously enabled option inactive also requires
|
// this. Making a previously enabled option inactive also requires
|
// user confirmation, thus preventing the inference engine from disabling
|
// user confirmation, thus preventing the inference engine from disabling
|
// entire components.
|
// entire components.
|
bool
|
bool
|
CdlTransactionBody::user_confirmation_required() const
|
CdlTransactionBody::user_confirmation_required() const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::user_confirmation_required", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::user_confirmation_required", "result %d");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(this->parent);
|
CYG_PRECONDITION_CLASSC(this->parent);
|
|
|
bool result = false;
|
bool result = false;
|
|
|
std::map<CdlValuable, CdlValue>::const_iterator val_i;
|
std::map<CdlValuable, CdlValue>::const_iterator val_i;
|
for (val_i = changes.begin(); val_i != changes.end(); val_i++) {
|
for (val_i = changes.begin(); val_i != changes.end(); val_i++) {
|
const CdlValue& old_value = parent->get_whole_value(val_i->first);
|
const CdlValue& old_value = parent->get_whole_value(val_i->first);
|
if (old_value.get_source() > CdlTransactionBody::inference_override) {
|
if (old_value.get_source() > CdlTransactionBody::inference_override) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
std::set<CdlNode>::const_iterator val_j;
|
std::set<CdlNode>::const_iterator val_j;
|
for (val_j = deactivated.begin(); val_j != deactivated.end(); val_j++) {
|
for (val_j = deactivated.begin(); val_j != deactivated.end(); val_j++) {
|
CdlValuable valuable = dynamic_cast<CdlValuable>(*val_j);
|
CdlValuable valuable = dynamic_cast<CdlValuable>(*val_j);
|
if (0 != valuable) {
|
if (0 != valuable) {
|
const CdlValue& old_value = parent->get_whole_value(valuable);
|
const CdlValue& old_value = parent->get_whole_value(valuable);
|
if ((old_value.get_source() > CdlTransactionBody::inference_override) && old_value.is_enabled()) {
|
if ((old_value.get_source() > CdlTransactionBody::inference_override) && old_value.is_enabled()) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// The inference engine is considering modifying a particular valuable. If
|
// The inference engine is considering modifying a particular valuable. If
|
// the user has explicitly changed this valuable during the transaction then
|
// the user has explicitly changed this valuable during the transaction then
|
// it would be inappropriate to suggest changing it again.
|
// it would be inappropriate to suggest changing it again.
|
bool
|
bool
|
CdlTransactionBody::changed_by_user(CdlValuable valuable) const
|
CdlTransactionBody::changed_by_user(CdlValuable valuable) const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::changed_by_user", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::changed_by_user", "result %d");
|
CYG_REPORT_FUNCARG2XV(this, valuable);
|
CYG_REPORT_FUNCARG2XV(this, valuable);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(valuable);
|
CYG_PRECONDITION_CLASSC(valuable);
|
|
|
bool result = false;
|
bool result = false;
|
std::map<CdlValuable, CdlValue>::const_iterator change_i = changes.find(valuable);
|
std::map<CdlValuable, CdlValue>::const_iterator change_i = changes.find(valuable);
|
if (change_i != changes.end()) {
|
if (change_i != changes.end()) {
|
CdlValueSource source = change_i->second.get_source();
|
CdlValueSource source = change_i->second.get_source();
|
if (CdlValueSource_User == source) {
|
if (CdlValueSource_User == source) {
|
result = true;
|
result = true;
|
}
|
}
|
}
|
}
|
if (!result && (0 != parent)) {
|
if (!result && (0 != parent)) {
|
result = parent->changed_by_user(valuable);
|
result = parent->changed_by_user(valuable);
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// A variant which takes into account the hierarchy: disabling a container
|
// A variant which takes into account the hierarchy: disabling a container
|
// when a sub-node has just been changed by the user is also a no-no.
|
// when a sub-node has just been changed by the user is also a no-no.
|
bool
|
bool
|
CdlTransactionBody::subnode_changed_by_user(CdlContainer container) const
|
CdlTransactionBody::subnode_changed_by_user(CdlContainer container) const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::subnode_changed_by_user", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::subnode_changed_by_user", "result %d");
|
CYG_REPORT_FUNCARG2XV(this, container);
|
CYG_REPORT_FUNCARG2XV(this, container);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(container);
|
CYG_PRECONDITION_CLASSC(container);
|
|
|
bool result = false;
|
bool result = false;
|
|
|
const std::vector<CdlNode>& contents = container->get_contents();
|
const std::vector<CdlNode>& contents = container->get_contents();
|
std::vector<CdlNode>::const_iterator node_i;
|
std::vector<CdlNode>::const_iterator node_i;
|
for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
|
for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
|
CdlValuable valuable = dynamic_cast<CdlValuable>(*node_i);
|
CdlValuable valuable = dynamic_cast<CdlValuable>(*node_i);
|
if ((0 != valuable) && this->changed_by_user(valuable)) {
|
if ((0 != valuable) && this->changed_by_user(valuable)) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
CdlContainer container = dynamic_cast<CdlContainer>(*node_i);
|
CdlContainer container = dynamic_cast<CdlContainer>(*node_i);
|
if ((0 != container) && this->subnode_changed_by_user(container)) {
|
if ((0 != container) && this->subnode_changed_by_user(container)) {
|
result = true;
|
result = true;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Is one solution preferable to another? This code assumes that
|
// Is one solution preferable to another? This code assumes that
|
// user_confirmation_required() and changed_by_user() have already
|
// user_confirmation_required() and changed_by_user() have already
|
// been considered, so the only issue at stake here is the changes
|
// been considered, so the only issue at stake here is the changes
|
// themselves.
|
// themselves.
|
//
|
//
|
// For now a simple metric of the number of changes is used. A more
|
// For now a simple metric of the number of changes is used. A more
|
// intelligent approach would take into account how much of the
|
// intelligent approach would take into account how much of the
|
// hierarchy is affected, e.g. how many other items would end
|
// hierarchy is affected, e.g. how many other items would end
|
// up being disabled. Arguably the calling code should be able to
|
// up being disabled. Arguably the calling code should be able to
|
// supply an additional weighting.
|
// supply an additional weighting.
|
|
|
bool
|
bool
|
CdlTransactionBody::is_preferable_to(CdlTransaction other) const
|
CdlTransactionBody::is_preferable_to(CdlTransaction other) const
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionBody::preferable_to", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransactionBody::preferable_to", "result %d");
|
CYG_REPORT_FUNCARG2XV(this, other);
|
CYG_REPORT_FUNCARG2XV(this, other);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(other);
|
CYG_PRECONDITION_CLASSC(other);
|
CYG_PRECONDITIONC(this != other);
|
CYG_PRECONDITIONC(this != other);
|
|
|
bool result = false;
|
bool result = false;
|
unsigned int this_changes = this->changes.size() + this->activated.size() + this->deactivated.size();
|
unsigned int this_changes = this->changes.size() + this->activated.size() + this->deactivated.size();
|
unsigned int other_changes = other->changes.size() + other->activated.size() + other->deactivated.size();
|
unsigned int other_changes = other->changes.size() + other->activated.size() + other->deactivated.size();
|
|
|
if (this_changes <= other_changes) {
|
if (this_changes <= other_changes) {
|
result = true;
|
result = true;
|
}
|
}
|
|
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Applying solutions. Multiple solutions can be applied in one go. If there
|
// Applying solutions. Multiple solutions can be applied in one go. If there
|
// is any overlap, tough. Propagation needs to happen after solutions are
|
// is any overlap, tough. Propagation needs to happen after solutions are
|
// applied.
|
// applied.
|
|
|
void
|
void
|
CdlTransactionBody::apply_solution(CdlConflict conflict)
|
CdlTransactionBody::apply_solution(CdlConflict conflict)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::apply_solution");
|
CYG_REPORT_FUNCNAME("CdlTransaction::apply_solution");
|
CYG_REPORT_FUNCARG2XV(this, conflict);
|
CYG_REPORT_FUNCARG2XV(this, conflict);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(conflict);
|
CYG_PRECONDITION_CLASSC(conflict);
|
|
|
// The solution can be for either a per-transaction conflict
|
// The solution can be for either a per-transaction conflict
|
// or a global one. There are two lists to search.
|
// or a global one. There are two lists to search.
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
conf_i = std::find(this->new_conflicts.begin(), this->new_conflicts.end(), conflict);
|
conf_i = std::find(this->new_conflicts.begin(), this->new_conflicts.end(), conflict);
|
if (conf_i == this->new_conflicts.end()) {
|
if (conf_i == this->new_conflicts.end()) {
|
conf_i = std::find(this->global_conflicts_with_solutions.begin(),
|
conf_i = std::find(this->global_conflicts_with_solutions.begin(),
|
this->global_conflicts_with_solutions.end(),
|
this->global_conflicts_with_solutions.end(),
|
conflict);
|
conflict);
|
CYG_ASSERTC(conf_i != this->global_conflicts_with_solutions.end());
|
CYG_ASSERTC(conf_i != this->global_conflicts_with_solutions.end());
|
}
|
}
|
|
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
CdlValuable valuable = val_i->first;
|
CdlValuable valuable = val_i->first;
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
|
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::apply_solutions(const std::vector<CdlConflict>& solutions)
|
CdlTransactionBody::apply_solutions(const std::vector<CdlConflict>& solutions)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::apply_solutions");
|
CYG_REPORT_FUNCNAME("CdlTransaction::apply_solutions");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
std::vector<CdlConflict>::const_iterator conf_i;
|
std::vector<CdlConflict>::const_iterator conf_i;
|
for (conf_i = solutions.begin(); conf_i != solutions.end(); conf_i++) {
|
for (conf_i = solutions.begin(); conf_i != solutions.end(); conf_i++) {
|
|
|
std::list<CdlConflict>::const_iterator conf_j;
|
std::list<CdlConflict>::const_iterator conf_j;
|
conf_j = std::find(this->new_conflicts.begin(), this->new_conflicts.end(), conflict);
|
conf_j = std::find(this->new_conflicts.begin(), this->new_conflicts.end(), conflict);
|
if (conf_j == this->new_conflicts.end()) {
|
if (conf_j == this->new_conflicts.end()) {
|
conf_j = std::find(this->global_conflicts_with_solutions.begin(),
|
conf_j = std::find(this->global_conflicts_with_solutions.begin(),
|
this->global_conflicts_with_solutions.end(),
|
this->global_conflicts_with_solutions.end(),
|
conflict);
|
conflict);
|
CYG_ASSERTC(conf_j != this->global_conflicts_with_solutions.end());
|
CYG_ASSERTC(conf_j != this->global_conflicts_with_solutions.end());
|
}
|
}
|
|
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
CdlValuable valuable = val_i->first;
|
CdlValuable valuable = val_i->first;
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
void
|
void
|
CdlTransactionBody::apply_all_solutions()
|
CdlTransactionBody::apply_all_solutions()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::apply_all_solutions");
|
CYG_REPORT_FUNCNAME("CdlTransaction::apply_all_solutions");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
for (conf_i = this->new_conflicts.begin(); conf_i != this->new_conflicts.end(); conf_i++) {
|
for (conf_i = this->new_conflicts.begin(); conf_i != this->new_conflicts.end(); conf_i++) {
|
if ((*conf_i)->has_known_solution()) {
|
if ((*conf_i)->has_known_solution()) {
|
|
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
CdlValuable valuable = val_i->first;
|
CdlValuable valuable = val_i->first;
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
}
|
}
|
}
|
}
|
}
|
}
|
for (conf_i = this->global_conflicts_with_solutions.begin();
|
for (conf_i = this->global_conflicts_with_solutions.begin();
|
conf_i != this->global_conflicts_with_solutions.end();
|
conf_i != this->global_conflicts_with_solutions.end();
|
conf_i++) {
|
conf_i++) {
|
|
|
CYG_ASSERTC((*conf_i)->has_known_solution());
|
CYG_ASSERTC((*conf_i)->has_known_solution());
|
|
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator val_i;
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
for (val_i = conflict->solution.begin(); val_i != conflict->solution.end(); val_i++) {
|
CdlValuable valuable = val_i->first;
|
CdlValuable valuable = val_i->first;
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
CYG_LOOP_INVARIANT_CLASSC(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
const CdlValue& old_value = this->get_whole_value(valuable);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
this->set_whole_value(valuable, old_value, val_i->second);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ Inference
|
//{{{ Inference
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
//{{{ resolve() - all per-transaction conflicts
|
//{{{ resolve() - all per-transaction conflicts
|
|
|
void
|
void
|
CdlTransactionBody::resolve(int level)
|
CdlTransactionBody::resolve(int level)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::resolve");
|
CYG_REPORT_FUNCNAME("CdlTransaction::resolve");
|
CYG_REPORT_FUNCARG2XV(this, level);
|
CYG_REPORT_FUNCARG2XV(this, level);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
while(1) {
|
while(1) {
|
// Resolving one conflict may affect others, so iterating down the list
|
// Resolving one conflict may affect others, so iterating down the list
|
// is not safe. Instead we need to loop as long as there are conflicts
|
// is not safe. Instead we need to loop as long as there are conflicts
|
// to be considered.
|
// to be considered.
|
std::list<CdlConflict>::iterator conf_i;
|
std::list<CdlConflict>::iterator conf_i;
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
for (conf_i = new_conflicts.begin(); conf_i != new_conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
|
|
// Is there any point in attempt to resolve this conflict?
|
// Is there any point in attempt to resolve this conflict?
|
if ((*conf_i)->has_known_solution() ||
|
if ((*conf_i)->has_known_solution() ||
|
(*conf_i)->has_no_solution() ||
|
(*conf_i)->has_no_solution() ||
|
!(*conf_i)->resolution_implemented()) {
|
!(*conf_i)->resolution_implemented()) {
|
continue;
|
continue;
|
}
|
}
|
this->resolve(*conf_i, level);
|
this->resolve(*conf_i, level);
|
break;
|
break;
|
}
|
}
|
if (conf_i == new_conflicts.end()) {
|
if (conf_i == new_conflicts.end()) {
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ resolve() - vector
|
//{{{ resolve() - vector
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
void
|
void
|
CdlTransactionBody::resolve(const std::vector<CdlConflict>& conflicts, int level)
|
CdlTransactionBody::resolve(const std::vector<CdlConflict>& conflicts, int level)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::resolve");
|
CYG_REPORT_FUNCNAME("CdlTransaction::resolve");
|
CYG_REPORT_FUNCARG2XV(this, level);
|
CYG_REPORT_FUNCARG2XV(this, level);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
std::vector<CdlConflict>::const_iterator conf_i;
|
std::vector<CdlConflict>::const_iterator conf_i;
|
for (conf_i = conflicts.begin(); conf_i != conflicts.end(); conf_i++) {
|
for (conf_i = conflicts.begin(); conf_i != conflicts.end(); conf_i++) {
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
CYG_LOOP_INVARIANT_CLASSC(*conf_i);
|
|
|
// Is there any point in attempt to resolve this conflict?
|
// Is there any point in attempt to resolve this conflict?
|
if (!(*conf_i)->has_known_solution() &&
|
if (!(*conf_i)->has_known_solution() &&
|
!(*conf_i)->has_no_solution() &&
|
!(*conf_i)->has_no_solution() &&
|
(*conf_i)->resolution_implemented()) {
|
(*conf_i)->resolution_implemented()) {
|
this->resolve(*conf_i, level);
|
this->resolve(*conf_i, level);
|
}
|
}
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ resolve() - single conflict
|
//{{{ resolve() - single conflict
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// There is a conflict that may have a solution. The resolution
|
// There is a conflict that may have a solution. The resolution
|
// attempt needs to happen in the context of a sub-transaction
|
// attempt needs to happen in the context of a sub-transaction
|
//
|
//
|
// The conflict may have been created during this transaction,
|
// The conflict may have been created during this transaction,
|
// or it may be a global conflict left over from a previous
|
// or it may be a global conflict left over from a previous
|
// transaction. This can be detected using the conflict's
|
// transaction. This can be detected using the conflict's
|
// transaction field. The commit() code, amongst others, needs
|
// transaction field. The commit() code, amongst others, needs
|
// to handle global and per-transaction conflicts differently.
|
// to handle global and per-transaction conflicts differently.
|
|
|
void
|
void
|
CdlTransactionBody::resolve(CdlConflict conflict, int level)
|
CdlTransactionBody::resolve(CdlConflict conflict, int level)
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::resolve");
|
CYG_REPORT_FUNCNAME("CdlTransaction::resolve");
|
CYG_REPORT_FUNCARG3XV(this, conflict, level);
|
CYG_REPORT_FUNCARG3XV(this, conflict, level);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_CLASSC(conflict);
|
CYG_PRECONDITION_CLASSC(conflict);
|
CYG_PRECONDITIONC(0 == conflict->solution.size());
|
CYG_PRECONDITIONC(0 == conflict->solution.size());
|
CYG_PRECONDITIONC((0 <= level) && (level <= inference_recursion_limit));
|
CYG_PRECONDITIONC((0 <= level) && (level <= inference_recursion_limit));
|
|
|
CdlTransaction sub_transaction = this->make(conflict);
|
CdlTransaction sub_transaction = this->make(conflict);
|
CYG_PRECONDITION_CLASSC(sub_transaction);
|
CYG_PRECONDITION_CLASSC(sub_transaction);
|
if (!conflict->inner_resolve(sub_transaction, level)) {
|
if (!conflict->inner_resolve(sub_transaction, level)) {
|
CYG_ASSERTC(0 == sub_transaction->changes.size());
|
CYG_ASSERTC(0 == sub_transaction->changes.size());
|
sub_transaction->cancel();
|
sub_transaction->cancel();
|
delete sub_transaction;
|
delete sub_transaction;
|
conflict->no_solution = true;
|
conflict->no_solution = true;
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return;
|
return;
|
}
|
}
|
// Is the inference engine lying? The conflict should be resolved
|
// Is the inference engine lying? The conflict should be resolved
|
// in the sub-transaction.
|
// in the sub-transaction.
|
if (conflict->is_structural()) {
|
if (conflict->is_structural()) {
|
if (std::find(sub_transaction->deleted_structural_conflicts.begin(),
|
if (std::find(sub_transaction->deleted_structural_conflicts.begin(),
|
sub_transaction->deleted_structural_conflicts.end(),
|
sub_transaction->deleted_structural_conflicts.end(),
|
conflict) == sub_transaction->deleted_structural_conflicts.end()) {
|
conflict) == sub_transaction->deleted_structural_conflicts.end()) {
|
|
|
CYG_FAIL("The inference engine has proved too optimistic.");
|
CYG_FAIL("The inference engine has proved too optimistic.");
|
sub_transaction->cancel();
|
sub_transaction->cancel();
|
delete sub_transaction;
|
delete sub_transaction;
|
conflict->no_solution = true;
|
conflict->no_solution = true;
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return;
|
return;
|
}
|
}
|
} else {
|
} else {
|
if (std::find(sub_transaction->deleted_conflicts.begin(), sub_transaction->deleted_conflicts.end(), conflict)
|
if (std::find(sub_transaction->deleted_conflicts.begin(), sub_transaction->deleted_conflicts.end(), conflict)
|
== sub_transaction->deleted_conflicts.end()) {
|
== sub_transaction->deleted_conflicts.end()) {
|
|
|
CYG_FAIL("The inference engine has proved too optimistic.");
|
CYG_FAIL("The inference engine has proved too optimistic.");
|
sub_transaction->cancel();
|
sub_transaction->cancel();
|
delete sub_transaction;
|
delete sub_transaction;
|
conflict->no_solution = true;
|
conflict->no_solution = true;
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return;
|
return;
|
}
|
}
|
}
|
}
|
|
|
// Even if there is a solution it cannot always be applied
|
// Even if there is a solution it cannot always be applied
|
// automatically because that would affect existing user
|
// automatically because that would affect existing user
|
// values. Instead the solution needs to be saved so that
|
// values. Instead the solution needs to be saved so that
|
// the user can inspect it later. This should only happen
|
// the user can inspect it later. This should only happen
|
// at level 0. If we have recursed into the inference
|
// at level 0. If we have recursed into the inference
|
// engine then we should only worry about this right at
|
// engine then we should only worry about this right at
|
// the end, not at every stage (although internally the
|
// the end, not at every stage (although internally the
|
// inference code may worry about this when choosing
|
// inference code may worry about this when choosing
|
// between alternatives).
|
// between alternatives).
|
if ((0 == level) && sub_transaction->user_confirmation_required()) {
|
if ((0 == level) && sub_transaction->user_confirmation_required()) {
|
sub_transaction->save_solution();
|
sub_transaction->save_solution();
|
sub_transaction->cancel();
|
sub_transaction->cancel();
|
delete sub_transaction;
|
delete sub_transaction;
|
this->dirty = true;
|
this->dirty = true;
|
|
|
if (0 == conflict->transaction) {
|
if (0 == conflict->transaction) {
|
// This is a global conflict, not a per-transaction one.
|
// This is a global conflict, not a per-transaction one.
|
// There is a separate list of these conflicts.
|
// There is a separate list of these conflicts.
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
conf_i = std::find(this->global_conflicts_with_solutions.begin(),
|
conf_i = std::find(this->global_conflicts_with_solutions.begin(),
|
this->global_conflicts_with_solutions.end(),
|
this->global_conflicts_with_solutions.end(),
|
conflict);
|
conflict);
|
if (conf_i == this->global_conflicts_with_solutions.end()) {
|
if (conf_i == this->global_conflicts_with_solutions.end()) {
|
this->global_conflicts_with_solutions.push_back(conflict);
|
this->global_conflicts_with_solutions.push_back(conflict);
|
}
|
}
|
}
|
}
|
} else {
|
} else {
|
|
|
// This sub-transaction is safe, it can be applied
|
// This sub-transaction is safe, it can be applied
|
// immediately. The commit code detects that the
|
// immediately. The commit code detects that the
|
// solution being committed is for a particular
|
// solution being committed is for a particular
|
// resolved conflict and will take care of moving that
|
// resolved conflict and will take care of moving that
|
// conflict to the resolved list.
|
// conflict to the resolved list.
|
conflict->solution_references.clear(); // No point in preserving this information
|
conflict->solution_references.clear(); // No point in preserving this information
|
conflict->no_solution = false; // Redundant
|
conflict->no_solution = false; // Redundant
|
std::map<CdlValuable, CdlValue>::const_iterator soln_i;
|
std::map<CdlValuable, CdlValue>::const_iterator soln_i;
|
for (soln_i = sub_transaction->changes.begin(); soln_i != sub_transaction->changes.end(); soln_i++) {
|
for (soln_i = sub_transaction->changes.begin(); soln_i != sub_transaction->changes.end(); soln_i++) {
|
conflict->solution.push_back(*soln_i);
|
conflict->solution.push_back(*soln_i);
|
}
|
}
|
sub_transaction->commit();
|
sub_transaction->commit();
|
delete sub_transaction;
|
delete sub_transaction;
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
//{{{ resolve_recursion()
|
//{{{ resolve_recursion()
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// resolve_recursion()
|
// resolve_recursion()
|
//
|
//
|
// The inference engine has tried one or more changes in the context of
|
// The inference engine has tried one or more changes in the context of
|
// a sub-transaction. It is now necessary to check whether these changes
|
// a sub-transaction. It is now necessary to check whether these changes
|
// are beneficial, i.e. whether or not any new problems are introduced
|
// are beneficial, i.e. whether or not any new problems are introduced
|
// that cannot be resolved.
|
// that cannot be resolved.
|
bool
|
bool
|
CdlTransactionBody::resolve_recursion(int level)
|
CdlTransactionBody::resolve_recursion(int level)
|
{
|
{
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::resolve_recursion", "result %d");
|
CYG_REPORT_FUNCNAMETYPE("CdlTransaction::resolve_recursion", "result %d");
|
CYG_REPORT_FUNCARG2XV(this, level);
|
CYG_REPORT_FUNCARG2XV(this, level);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
bool result = false;
|
bool result = false;
|
this->propagate();
|
this->propagate();
|
if (0 == new_conflicts.size()) {
|
if (0 == new_conflicts.size()) {
|
result = true;
|
result = true;
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
if (level >= inference_recursion_limit) {
|
if (level >= inference_recursion_limit) {
|
result = false;
|
result = false;
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
// There are new conflicts, but it may be possible to resolve them
|
// There are new conflicts, but it may be possible to resolve them
|
// by a recursive invocation of the inference engine.
|
// by a recursive invocation of the inference engine.
|
bool solutions_possible = false;
|
bool solutions_possible = false;
|
do {
|
do {
|
this->resolve(level + 1);
|
this->resolve(level + 1);
|
std::list<CdlConflict>::const_iterator conf_i;
|
std::list<CdlConflict>::const_iterator conf_i;
|
solutions_possible = false;
|
solutions_possible = false;
|
for (conf_i = this->new_conflicts.begin(); conf_i != this->new_conflicts.end(); conf_i++) {
|
for (conf_i = this->new_conflicts.begin(); conf_i != this->new_conflicts.end(); conf_i++) {
|
if (!(*conf_i)->has_no_solution()) {
|
if (!(*conf_i)->has_no_solution()) {
|
solutions_possible = true;
|
solutions_possible = true;
|
}
|
}
|
}
|
}
|
} while(solutions_possible);
|
} while(solutions_possible);
|
|
|
result = (0 == new_conflicts.size());
|
result = (0 == new_conflicts.size());
|
CYG_REPORT_RETVAL(result);
|
CYG_REPORT_RETVAL(result);
|
return result;
|
return result;
|
}
|
}
|
|
|
//}}}
|
//}}}
|
|
|
//}}}
|
//}}}
|
//{{{ Body
|
//{{{ Body
|
|
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// The majority of transactions involve the same set of steps. First one
|
// The majority of transactions involve the same set of steps. First one
|
// or more values are modified. Then there has to be propagation, inference,
|
// or more values are modified. Then there has to be propagation, inference,
|
// an inference callback, ... There may be a number of iterations. It is
|
// an inference callback, ... There may be a number of iterations. It is
|
// convenient to have a single transaction body function which takes care
|
// convenient to have a single transaction body function which takes care
|
// of all of that.
|
// of all of that.
|
//
|
//
|
// If automatic inference is disabled then life is pretty simple, there
|
// If automatic inference is disabled then life is pretty simple, there
|
// should be one propagate() operation followed by a commit.
|
// should be one propagate() operation followed by a commit.
|
//
|
//
|
// If automatic inference is enabled but there is no inference callback
|
// If automatic inference is enabled but there is no inference callback
|
// then we need a loop consisting of propagation and inference, while
|
// then we need a loop consisting of propagation and inference, while
|
// progress is made. Progress can be detected by value changes.
|
// progress is made. Progress can be detected by value changes.
|
//
|
//
|
// If there is an inference callback then life gets pretty complicated.
|
// If there is an inference callback then life gets pretty complicated.
|
// The problem is figuring out exactly when the inference callback
|
// The problem is figuring out exactly when the inference callback
|
// should be invoked:
|
// should be invoked:
|
//
|
//
|
// 1) any new conflicts should certainly result in a callback, to give
|
// 1) any new conflicts should certainly result in a callback, to give
|
// the user a chance to cancel the changes.
|
// the user a chance to cancel the changes.
|
// 2) any new solutions that have been applied automatically need to
|
// 2) any new solutions that have been applied automatically need to
|
// be shown to the user, again so that it is possible to cancel
|
// be shown to the user, again so that it is possible to cancel
|
// the changes.
|
// the changes.
|
// 3) any existing conflicts with a new solution, albeit one that cannot
|
// 3) any existing conflicts with a new solution, albeit one that cannot
|
// be applied automatically, should result in a callback. This is
|
// be applied automatically, should result in a callback. This is
|
// somewhat problematical since the new solution may in fact be
|
// somewhat problematical since the new solution may in fact be
|
// identical to a previous one that the user has already decided
|
// identical to a previous one that the user has already decided
|
// against committing.
|
// against committing.
|
//
|
//
|
// It is not easy to keep track of when new conflicts or solutions get
|
// It is not easy to keep track of when new conflicts or solutions get
|
// added to a transaction. Simply counting the entries in the
|
// added to a transaction. Simply counting the entries in the
|
// appropriate STL containers is insufficient, as conflicts come and
|
// appropriate STL containers is insufficient, as conflicts come and
|
// go. Instead it is necessary to have a "dirty" flag. Unfortunately
|
// go. Instead it is necessary to have a "dirty" flag. Unfortunately
|
// this too is not fool-proof: a new conflict may have been created,
|
// this too is not fool-proof: a new conflict may have been created,
|
// resulting in the dirty flag being set, and then the conflict may
|
// resulting in the dirty flag being set, and then the conflict may
|
// have disappeared.
|
// have disappeared.
|
|
|
void
|
void
|
CdlTransactionBody::body()
|
CdlTransactionBody::body()
|
{
|
{
|
CYG_REPORT_FUNCNAME("CdlTransaction::body");
|
CYG_REPORT_FUNCNAME("CdlTransaction::body");
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_REPORT_FUNCARG1XV(this);
|
CYG_PRECONDITION_THISC();
|
CYG_PRECONDITION_THISC();
|
|
|
// The Body() member function can only be applied to a toplevel
|
// The Body() member function can only be applied to a toplevel
|
// transaction, it does not really make sense to apply it to
|
// transaction, it does not really make sense to apply it to
|
// a sub-transaction (at least, not yet);
|
// a sub-transaction (at least, not yet);
|
CYG_PRECONDITIONC((0 == parent) && (0 != toplevel));
|
CYG_PRECONDITIONC((0 == parent) && (0 != toplevel));
|
|
|
if (!inference_enabled) {
|
if (!inference_enabled) {
|
this->propagate();
|
this->propagate();
|
this->commit();
|
this->commit();
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return;
|
return;
|
}
|
}
|
|
|
if (0 == inference_callback) {
|
if (0 == inference_callback) {
|
bool progress = false;
|
bool progress = false;
|
do {
|
do {
|
progress = false;
|
progress = false;
|
this->propagate();
|
this->propagate();
|
CYG_LOOP_INVARIANTC(0 == value_changes.size());
|
CYG_LOOP_INVARIANTC(0 == value_changes.size());
|
this->resolve();
|
this->resolve();
|
if (0 != value_changes.size()) {
|
if (0 != value_changes.size()) {
|
progress = true;
|
progress = true;
|
}
|
}
|
} while(progress);
|
} while(progress);
|
|
|
this->commit();
|
this->commit();
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
return;
|
return;
|
}
|
}
|
|
|
bool cancel = false;
|
bool cancel = false;
|
|
|
unsigned int resolved_size = 0;
|
unsigned int resolved_size = 0;
|
unsigned int globals_with_solutions_size = 0;
|
unsigned int globals_with_solutions_size = 0;
|
|
|
do {
|
do {
|
bool progress = false;
|
bool progress = false;
|
do {
|
do {
|
progress = false;
|
progress = false;
|
this->propagate();
|
this->propagate();
|
CYG_LOOP_INVARIANTC(0 == value_changes.size());
|
CYG_LOOP_INVARIANTC(0 == value_changes.size());
|
this->resolve();
|
this->resolve();
|
if (0 != value_changes.size()) {
|
if (0 != value_changes.size()) {
|
progress = true;
|
progress = true;
|
}
|
}
|
} while(progress);
|
} while(progress);
|
|
|
// Sanity check: if there are no conflicts and no new entries in
|
// Sanity check: if there are no conflicts and no new entries in
|
// the resolved vector, then stop here. The user has already seen
|
// the resolved vector, then stop here. The user has already seen
|
// and taken care of everything of interest.
|
// and taken care of everything of interest.
|
if ((0 == new_conflicts.size()) &&
|
if ((0 == new_conflicts.size()) &&
|
(resolved_size == resolved_conflicts.size()) &&
|
(resolved_size == resolved_conflicts.size()) &&
|
(globals_with_solutions_size == global_conflicts_with_solutions.size())) {
|
(globals_with_solutions_size == global_conflicts_with_solutions.size())) {
|
cancel = false;
|
cancel = false;
|
break;
|
break;
|
}
|
}
|
|
|
// Also, if no conflicts have been added, no new solutions
|
// Also, if no conflicts have been added, no new solutions
|
// have been identified, and no new solutions have been applied,
|
// have been identified, and no new solutions have been applied,
|
// then there is no point in asking for user feedback.
|
// then there is no point in asking for user feedback.
|
if (!this->dirty) {
|
if (!this->dirty) {
|
cancel = false;
|
cancel = false;
|
break;
|
break;
|
}
|
}
|
|
|
// Clear state before invoking the callback. If the user does not
|
// Clear state before invoking the callback. If the user does not
|
// change anything else then we should get out of the loop next
|
// change anything else then we should get out of the loop next
|
// time around.
|
// time around.
|
this->dirty = false;
|
this->dirty = false;
|
resolved_size = resolved_conflicts.size();
|
resolved_size = resolved_conflicts.size();
|
globals_with_solutions_size = global_conflicts_with_solutions.size();
|
globals_with_solutions_size = global_conflicts_with_solutions.size();
|
|
|
// Invoke the callback. If the result is cancel, do so. Otherwise
|
// Invoke the callback. If the result is cancel, do so. Otherwise
|
// we need to spin while things are changing.
|
// we need to spin while things are changing.
|
if (CdlInferenceCallbackResult_Cancel == (*inference_callback)(this)) {
|
if (CdlInferenceCallbackResult_Cancel == (*inference_callback)(this)) {
|
cancel = true;
|
cancel = true;
|
}
|
}
|
} while(!cancel);
|
} while(!cancel);
|
|
|
if (cancel) {
|
if (cancel) {
|
this->cancel();
|
this->cancel();
|
} else {
|
} else {
|
this->commit();
|
this->commit();
|
}
|
}
|
|
|
CYG_REPORT_RETURN();
|
CYG_REPORT_RETURN();
|
}
|
}
|
|
|
//}}}
|
//}}}
|
|
|
|
|