00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0: 00002 /* 00003 * Copyright (C) 2007, Technical Computer Science Group, 00004 * University of Bonn 00005 * 00006 * This file is part of the ReChannel library. 00007 * 00008 * The ReChannel library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License as 00010 * published by the Free Software Foundation; either version 2 of the 00011 * License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be 00014 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this library; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke. 00024 * {raabe, felke}@cs.uni-bonn.de 00025 */ 00037 #include "rc_abstract_switch.h" 00038 #include "../core/rc_reconfigurable.h" 00039 00040 namespace ReChannel { 00041 00042 rc_abstract_switch_b::rc_abstract_switch_b() 00043 : m_state(UNDEF), m_transaction_count(0), p_lock_owner(NULL) 00044 { } 00045 00046 rc_abstract_switch_b::~rc_abstract_switch_b() 00047 { } 00048 00049 bool rc_abstract_switch_b::set_locked( 00050 rc_reconfigurable& lock_owner, bool lock) 00051 { 00052 if (p_lock_owner == NULL || p_lock_owner == &lock_owner) { 00053 p_lock_owner = (lock ? &lock_owner : NULL); 00054 return true; 00055 } else { 00056 return false; 00057 } 00058 } 00059 00060 void rc_abstract_switch_b::register_reconfigurable( 00061 rc_reconfigurable& module, sc_interface& dyn_if) 00062 { 00063 if (is_registered(module)) { 00064 RC_REPORT_ERROR(RC_ID_SWITCH_BINDING_ERROR_, 00065 "reconfigurable module '" << module.rc_get_name() 00066 << "' already bound (in switch '" 00067 << this->get_switch_name() << "')"); 00068 } 00069 void* dyn_if_ = _rc_dynamic_cast(&dyn_if); 00070 if (dyn_if_ == NULL) { 00071 RC_REPORT_ERROR(RC_ID_SWITCH_BINDING_ERROR_, 00072 "given interface ('" << _rc_get_if_type() 00073 << "' is incompatible (in switch '" 00074 << this->get_switch_name() << "')"); 00075 } else if (p_interface_set.find(dyn_if_) != 00076 p_interface_set.end()) { 00077 RC_REPORT_ERROR(RC_ID_SWITCH_BINDING_ERROR_, 00078 "interface ('" << _rc_get_if_type() 00079 << "' already registered (in switch '" 00080 << this->get_switch_name() << "')"); 00081 } 00082 p_interface_set.insert(dyn_if_); 00083 p_mod_if_map[&module] = dyn_if_; 00084 } 00085 00086 void rc_abstract_switch_b::unregister_reconfigurable( 00087 rc_reconfigurable& module) 00088 { 00089 void* if_ = find_registered_if(&module); 00090 if (if_ != NULL) { 00091 p_interface_set.erase(if_); 00092 p_mod_if_map.erase(&module); 00093 } 00094 } 00095 00096 } // namespace ReChannel 00097 00098 // 00099 // $Id: rc_abstract_switch.cpp,v 1.6 2007/12/20 20:26:39 felke Exp $ 00100 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/rc_abstract_switch.cpp,v $ 00101 //