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_switch_connector.h" 00038 #include "ReChannel/core/rc_reconfigurable.h" 00039 00040 namespace ReChannel { 00041 00042 rc_switch& rc_switch_connector_base::get(int index) const 00043 { 00044 if (index >= 0 && index < p_size) { 00045 return *(p_switch_arr[index]); 00046 } else { 00047 RC_REPORT_ERROR(RC_ID_OUT_OF_BOUNDS_, 00048 "out of bounds (in switch connector '" << this->name() 00049 << "', at index: " << index <<")"); 00050 } 00051 } 00052 00053 void rc_switch_connector_base::bind_static( 00054 const rc_portmap_base& portmap) 00055 { 00056 if (p_size != portmap.size()) { 00057 RC_REPORT_ERROR(RC_ID_SWITCH_CONNECTOR_BINDING_ERROR_, 00058 "static switch binding failed due to incompatible port map" 00059 " (in switch connector '" << this->name() << "')"); 00060 } 00061 for (int i=0; i < p_size; ++i) { 00062 p_switch_arr[i]->bind_static_object(portmap[i]); 00063 } 00064 } 00065 00066 void rc_switch_connector_base::bind_dynamic( 00067 const rc_portmap_base& portmap) 00068 { 00069 if (!this->is_compatible(portmap)) { 00070 RC_REPORT_ERROR(RC_ID_SWITCH_CONNECTOR_BINDING_ERROR_, 00071 "dynamic switch binding failed due to incompatible port map" 00072 " (in switch connector '" << this->name() << "')"); 00073 } 00074 for (int i=0; i < p_size; ++i) { 00075 p_switch_arr[i]->bind_dynamic_object(portmap[i]); 00076 } 00077 } 00078 00079 void rc_switch_connector_base::bind_dynamic(rc_reconfigurable& reconf) 00080 { 00081 reconf.bind(*this); 00082 } 00083 00084 void rc_switch_connector_base::_rc_init(rc_switch* switch_arr[], int size) 00085 { 00086 assert(p_switch_arr == NULL); 00087 assert(switch_arr != NULL && size > 0); 00088 00089 if (switch_arr != NULL && p_switch_arr == NULL) { 00090 p_switch_arr = switch_arr; 00091 p_size = size; 00092 for(int i=0; i < size; ++i) { 00093 rc_switch* const switch_obj = p_switch_arr[i]; 00094 if (switch_obj == NULL) { 00095 RC_REPORT_ERROR(RC_ID_SWITCH_CONNECTOR_INIT_ERROR_, 00096 "switch missing (in switch connector '" 00097 << this->name() << "', at index: " 00098 << i <<")"); 00099 } 00100 } 00101 } 00102 } 00103 00104 } // namespace ReChannel 00105 00106 // 00107 // $Id: rc_switch_connector.cpp,v 1.6 2007/12/06 11:42:43 felke Exp $ 00108 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/core/rc_switch_connector.cpp,v $ 00109 //