URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [libcdl/] [transact.cxx] - Rev 187
Go to most recent revision | Compare with Previous | Blame | View Log
//{{{ Banner //============================================================================ // // transaction.cxx // // Implementation of the CdlTransaction class // //============================================================================ //####COPYRIGHTBEGIN#### // // ---------------------------------------------------------------------------- // Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. // // This file is part of the eCos host tools. // // 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 // Software Foundation; either version 2 of the License, or (at your option) // any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details. // // 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., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // ---------------------------------------------------------------------------- // //####COPYRIGHTEND#### //============================================================================ //#####DESCRIPTIONBEGIN#### // // Author(s): bartv // Contact(s): bartv // Date: 1999/07/16 // Version: 0.01 // //####DESCRIPTIONEND#### //============================================================================ //}}} //{{{ #include's // ---------------------------------------------------------------------------- #include "cdlconfig.h" // Get the infrastructure types, assertions, tracing and similar // facilities. #include <cyg/infra/cyg_ass.h> #include <cyg/infra/cyg_trac.h> // <cdlcore.hxx> defines everything implemented in this module. // It implicitly supplies <string>, <vector> and <map> because // the class definitions rely on these headers. #include <cdlcore.hxx> //}}} //{{{ CdlTransactionCallback class // ---------------------------------------------------------------------------- // The callback class is very straightforward. The hard work is done in // the transaction class. CdlTransactionCallback::CdlTransactionCallback(CdlTransaction transact_arg) { CYG_REPORT_FUNCNAME("CdlTransactionCallback:: constructor"); CYG_REPORT_FUNCARG2XV(this, transact_arg); CYG_PRECONDITION_CLASSC(transact_arg); // The vectors etc. will take care of themselves. transact = transact_arg; cdltransactioncallback_cookie = CdlTransactionCallback_Magic; CYG_POSTCONDITION_THISC(); CYG_REPORT_RETURN(); } CdlTransactionCallback::~CdlTransactionCallback() { CYG_REPORT_FUNCNAME("CdlTransactionCallback:: destructor"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); cdltransactioncallback_cookie = CdlTransactionCallback_Invalid; transact = 0; value_changes.clear(); active_changes.clear(); legal_values_changes.clear(); value_source_changes.clear(); new_conflicts.clear(); new_structural_conflicts.clear(); nodes_with_resolved_conflicts.clear(); nodes_with_resolved_structural_conflicts.clear(); CYG_REPORT_RETURN(); } void CdlTransactionCallback::set_callback_fn(void (*fn)(const CdlTransactionCallback&)) { CYG_REPORT_FUNCNAME("CdlTransactionCallback::set_callback_fn"); CYG_REPORT_FUNCARG1XV(fn); CdlTransactionBody::set_callback_fn(fn); CYG_REPORT_RETURN(); } void (*CdlTransactionCallback::get_callback_fn())(const CdlTransactionCallback&) { CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_callback_fn", "result %p"); void (*result)(const CdlTransactionCallback&) = CdlTransactionBody::get_callback_fn(); CYG_REPORT_RETVAL(result); return result; } CdlTransaction CdlTransactionCallback::get_transaction() const { CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_transaction", "result %p"); CYG_PRECONDITION_THISC(); CdlTransaction result = transact; CYG_POSTCONDITION_CLASSC(result); CYG_REPORT_RETVAL(result); return result; } CdlToplevel CdlTransactionCallback::get_toplevel() const { CYG_REPORT_FUNCNAMETYPE("CdlTransactionCallback::get_toplevel", "result %p"); CYG_PRECONDITION_THISC(); CdlToplevel result = transact->get_toplevel(); CYG_POSTCONDITION_CLASSC(result); CYG_REPORT_RETVAL(result); return result; } bool CdlTransactionCallback::check_this(cyg_assert_class_zeal zeal) const { if (CdlTransactionCallback_Magic != cdltransactioncallback_cookie) { return false; } return true; } //}}} //{{{ CdlTransaction statics // ---------------------------------------------------------------------------- void (*CdlTransactionBody::callback_fn)(const CdlTransactionCallback&) = 0; CdlInferenceCallback CdlTransactionBody::inference_callback = 0; bool CdlTransactionBody::inference_enabled = true; int CdlTransactionBody::inference_recursion_limit = 3; CdlValueSource CdlTransactionBody::inference_override = CdlValueSource_Inferred; CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlTransactionBody); //}}} //{{{ Transaction creation and destruction // ---------------------------------------------------------------------------- CdlTransaction CdlTransactionBody::make(CdlToplevel toplevel) { CYG_REPORT_FUNCNAMETYPE("CdlTransaction::make", "result %p"); CYG_REPORT_FUNCARG1XV(toplevel); CYG_PRECONDITION_CLASSC(toplevel); CYG_PRECONDITIONC(0 == toplevel->transaction); CdlTransaction result = new CdlTransactionBody(toplevel, 0, 0); toplevel->transaction = result; CYG_REPORT_RETVAL(result); return result; } CdlTransaction CdlTransactionBody::make(CdlConflict conflict) { CYG_REPORT_FUNCNAMETYPE("CdlTransaction::make (sub-transaction)", "result %p"); CYG_REPORT_FUNCARG2XV(this, conflict); CYG_PRECONDITION_THISC(); CYG_PRECONDITION_ZERO_OR_CLASSC(conflict); CdlTransaction result = new CdlTransactionBody(0, this, conflict); CYG_REPORT_RETVAL(result); return result; } CdlTransactionBody::CdlTransactionBody(CdlToplevel toplevel_arg, CdlTransaction parent_arg, CdlConflict conflict_arg) { CYG_REPORT_FUNCNAME("CdlTransaction:: constructor"); CYG_REPORT_FUNCARG4XV(this, toplevel_arg, parent_arg, conflict_arg); CYG_PRECONDITION_ZERO_OR_CLASSC(toplevel_arg); CYG_PRECONDITION_ZERO_OR_CLASSC(parent_arg); CYG_PRECONDITION_ZERO_OR_CLASSC(conflict_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 toplevel = toplevel_arg; parent = parent_arg; conflict = conflict_arg; dirty = false; cdltransactionbody_cookie = CdlTransactionBody_Magic; CYGDBG_MEMLEAK_CONSTRUCTOR(); CYG_POSTCONDITION_THISC(); CYG_REPORT_RETURN(); } // ---------------------------------------------------------------------------- CdlTransactionBody::~CdlTransactionBody() { CYG_REPORT_FUNCNAME("CdlTransaction:: destructor"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); // The transaction must have been either committed or cancelled. // This means that various of the STL containers should be empty CYG_ASSERTC(0 == commit_cancel_ops.size()); CYG_ASSERTC(0 == changes.size()); CYG_ASSERTC(0 == deleted_conflicts.size()); CYG_ASSERTC(0 == deleted_structural_conflicts.size()); CYG_ASSERTC(0 == new_conflicts.size()); CYG_ASSERTC(0 == new_structural_conflicts.size()); CYG_ASSERTC(0 == resolved_conflicts.size()); CYG_ASSERTC(0 == global_conflicts_with_solutions.size()); CYG_ASSERTC
Go to most recent revision | Compare with Previous | Blame | View Log