rc_switch_connector.h

Go to the documentation of this file.
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  */
00049 #ifndef RC_SWITCH_CONNECTOR_H_
00050 #define RC_SWITCH_CONNECTOR_H_
00051 
00052 #include "ReChannel/core/rc_common_header.h"
00053 #include "ReChannel/core/rc_switch.h"
00054 #include "ReChannel/core/rc_report_ids.h"
00055 #include "ReChannel/core/rc_portmap.h"
00056 
00057 #include <boost/type_traits/is_base_of.hpp>
00058 
00059 namespace ReChannel {
00060 
00061 class rc_control;
00062 class rc_reconfigurable;
00063 
00074 class rc_switch_connector_base
00075     : public sc_prim_channel
00076 {
00077 private:
00078     typedef rc_switch_connector_base this_type;
00079 
00080 protected:
00085     rc_switch_connector_base(const char* name)
00086         : sc_prim_channel(name), p_switch_arr(NULL), p_size(0)
00087         { }
00088 
00089 public:
00090 
00097     int size() const
00098         { return p_size; }
00099 
00104     rc_switch& get(int index) const;
00105 
00109     rc_switch& operator[](int index) const
00110         { return this->get(index); }
00111 
00116     virtual bool is_compatible(const rc_portmap_base& portmap) const = 0;
00117 
00121     void bind_static(const rc_portmap_base& portmap);
00122 
00126     void bind_dynamic(const rc_portmap_base& portmap);
00127 
00131     void bind_dynamic(rc_reconfigurable& reconf);
00132 
00133 protected:
00134 
00138     virtual ~rc_switch_connector_base() {}
00139 
00140 protected:
00141 
00142 /* for internal use only */
00143 
00148     void _rc_init(rc_switch* switch_arr[], int size);
00149 
00150 private:
00155     rc_switch** p_switch_arr;
00160     int         p_size;
00161 
00162 private:
00163     // disabled
00165     rc_switch_connector_base(const this_type& other);
00167     this_type& operator=(const this_type& other);
00168 };
00169 
00200 template<class DynPortMap>
00201 class rc_switch_connector
00202     : public rc_switch_connector_base
00203 {
00204 private:
00208     RC_STATIC_ASSERT_T(
00209         portmap_type_check,
00210         (boost::is_base_of<rc_portmap_base, DynPortMap>::value == true));
00211 
00215     RC_STATIC_ASSERT_T(portmap_size_check, DynPortMap::portmap_size > 0);
00216 
00217     typedef rc_switch_connector<DynPortMap> this_type;
00218     typedef rc_switch_connector_base        base_type;
00219 
00223     typedef typename internals::template arg<rc_switch, true>
00224         switch_arg;
00228     typedef typename internals::template arg<rc_switch, false>
00229         undef_arg;
00230 
00231 public:
00235     typedef DynPortMap portmap_type;
00236 
00237 public:
00243     enum { portmap_size = DynPortMap::portmap_size };
00244 
00245 public:
00259     #define _RC_Tmp_arg(i) \
00260         const typename internals::template arg< \
00261                 rc_switch, (bool)(i < portmap_size)>& \
00262             s##i=internals::UNDEF
00263 
00273     inline rc_switch_connector(
00274         const char* name,
00275         rc_switch& s0,   _RC_Tmp_arg(1),  _RC_Tmp_arg(2),  _RC_Tmp_arg(3),
00276         _RC_Tmp_arg(4),  _RC_Tmp_arg(5),  _RC_Tmp_arg(6),  _RC_Tmp_arg(7),
00277         _RC_Tmp_arg(8),  _RC_Tmp_arg(9),  _RC_Tmp_arg(10), _RC_Tmp_arg(11),
00278         _RC_Tmp_arg(12), _RC_Tmp_arg(13), _RC_Tmp_arg(14), _RC_Tmp_arg(15),
00279         _RC_Tmp_arg(16), _RC_Tmp_arg(17), _RC_Tmp_arg(18), _RC_Tmp_arg(19),
00280         _RC_Tmp_arg(20), _RC_Tmp_arg(21), _RC_Tmp_arg(22), _RC_Tmp_arg(23),
00281         _RC_Tmp_arg(24), _RC_Tmp_arg(25), _RC_Tmp_arg(26), _RC_Tmp_arg(27),
00282         _RC_Tmp_arg(28), _RC_Tmp_arg(29), _RC_Tmp_arg(30), _RC_Tmp_arg(31),
00283         _RC_Tmp_arg(32), _RC_Tmp_arg(33), _RC_Tmp_arg(34), _RC_Tmp_arg(35),
00284         _RC_Tmp_arg(36), _RC_Tmp_arg(37), _RC_Tmp_arg(38), _RC_Tmp_arg(39),
00285         _RC_Tmp_arg(40), _RC_Tmp_arg(41), _RC_Tmp_arg(42), _RC_Tmp_arg(43),
00286         _RC_Tmp_arg(44), _RC_Tmp_arg(45), _RC_Tmp_arg(46), _RC_Tmp_arg(47),
00287         _RC_Tmp_arg(48), _RC_Tmp_arg(49), _RC_Tmp_arg(50), _RC_Tmp_arg(51),
00288         _RC_Tmp_arg(52), _RC_Tmp_arg(53), _RC_Tmp_arg(54), _RC_Tmp_arg(55),
00289         _RC_Tmp_arg(56), _RC_Tmp_arg(57), _RC_Tmp_arg(58), _RC_Tmp_arg(59),
00290         _RC_Tmp_arg(60), _RC_Tmp_arg(61), _RC_Tmp_arg(62))
00291         : base_type(name)
00292     {
00293         p_switch_arr[0] = &s0;
00294         // the following initialisation block can be optimised by compilers
00295         this->_rc_set(1,  s1);  this->_rc_set(2,  s2);
00296         this->_rc_set(3,  s3);  this->_rc_set(4,  s4);
00297         this->_rc_set(5,  s5);  this->_rc_set(6,  s6);
00298         this->_rc_set(7,  s7);  this->_rc_set(8,  s8);
00299         this->_rc_set(9,  s9);  this->_rc_set(10, s10);
00300         this->_rc_set(11, s11); this->_rc_set(12, s12);
00301         this->_rc_set(13, s13); this->_rc_set(14, s14);
00302         this->_rc_set(15, s15); this->_rc_set(16, s16);
00303         this->_rc_set(17, s17); this->_rc_set(18, s18);
00304         this->_rc_set(19, s19); this->_rc_set(20, s20);
00305         this->_rc_set(21, s21); this->_rc_set(22, s22);
00306         this->_rc_set(23, s23); this->_rc_set(24, s24);
00307         this->_rc_set(25, s25); this->_rc_set(26, s26);
00308         this->_rc_set(27, s27); this->_rc_set(28, s28);
00309         this->_rc_set(29, s29); this->_rc_set(30, s30);
00310         this->_rc_set(31, s31); this->_rc_set(32, s32);
00311         this->_rc_set(33, s33); this->_rc_set(34, s34);
00312         this->_rc_set(35, s35); this->_rc_set(36, s36);
00313         this->_rc_set(37, s37); this->_rc_set(38, s38);
00314         this->_rc_set(39, s39); this->_rc_set(40, s40);
00315         this->_rc_set(41, s41); this->_rc_set(42, s42);
00316         this->_rc_set(43, s43); this->_rc_set(44, s44);
00317         this->_rc_set(45, s45); this->_rc_set(46, s46);
00318         this->_rc_set(47, s47); this->_rc_set(48, s48);
00319         this->_rc_set(49, s49); this->_rc_set(50, s50);
00320         this->_rc_set(51, s51); this->_rc_set(52, s52);
00321         this->_rc_set(53, s53); this->_rc_set(54, s54);
00322         this->_rc_set(55, s55); this->_rc_set(56, s56);
00323         this->_rc_set(57, s57); this->_rc_set(58, s58);
00324         this->_rc_set(59, s59); this->_rc_set(60, s60);
00325         this->_rc_set(61, s61); this->_rc_set(62, s62);
00326         // init base class
00327         base_type::_rc_init(p_switch_arr, portmap_size);
00328     }
00329     #undef _RC_Tmp_arg
00330 
00334     virtual bool is_compatible(const rc_portmap_base& portmap) const
00335         { return (typeid(portmap) == typeid(DynPortMap)); }
00336 
00337 private:
00338 
00342     inline void _rc_set(int i_, const switch_arg& arg_)
00343         { p_switch_arr[i_] = arg_; }
00344 
00349     inline void _rc_set(int i_, const undef_arg& arg_) const
00350         { }
00351 
00352 private:
00358     rc_switch* p_switch_arr[portmap_size];
00359 };
00360 
00361 } // namespace ReChannel
00362 
00363 #endif // RC_SWITCH_CONNECTOR_H_
00364 
00365 //
00366 // $Id: rc_switch_connector.h,v 1.7 2007/12/06 09:37:47 felke Exp $
00367 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/core/rc_switch_connector.h,v $
00368 //

Generated on Tue Jan 1 23:14:06 2008 for ReChannel by  doxygen 1.5.3