rc_abstract_accessor.cpp

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  */
00037 #include "rc_abstract_accessor.h"
00038 
00039 namespace ReChannel {
00040 
00041 rc_abstract_accessor_b::rc_abstract_accessor_b()
00042 { }
00043 
00044 void rc_abstract_accessor_b::register_port(
00045     sc_port_base& port_, const char* if_typename_)
00046 {
00047     sc_interface* const target_if = rc_get_target_interface();
00048     rc_interface_wrapper_base* const target_wrapper =
00049         rc_get_target_wrapper_base();
00050     if (target_if != NULL) {
00051         target_if->register_port(port_, if_typename_);
00052     } else if (target_wrapper != NULL) {
00053         target_wrapper->register_port(port_, if_typename_);
00054     }
00055     p_bound_port_vector.push_back(&port_);
00056 }
00057 
00058 int rc_abstract_accessor_b::rc_get_driver_process_index(
00059     sc_object* proc) const
00060 {
00061     if (proc == NULL) {
00062         return 0;
00063     } else {
00064         process_index_map::const_iterator it
00065             = p_process_index_map.find(proc);
00066         return (it != p_process_index_map.end() ? it->second : -1);
00067     }
00068 }
00069 
00070 int rc_abstract_accessor_b::rc_get_nb_driver_process_index(
00071     sc_object* proc) const
00072 {
00073 #ifndef RC_USE_SHARED_METHOD_DRIVER
00074     if (proc == NULL) {
00075         return 0;
00076     } else {
00077         process_index_map::const_iterator it
00078             = p_nb_process_index_map.find(proc);
00079         return (it != p_nb_process_index_map.end() ? it->second : -1);
00080     }
00081 #else // RC_USE_SHARED_METHOD_DRIVER (optimisation)
00082     return 0; // always 0 because it will be the same driver anyway
00083 #endif
00084 }
00085 
00086 int rc_abstract_accessor_b::rc_register_driver_process(
00087     sc_object* proc)
00088 {
00089     if (proc == NULL) {
00090         return 0;
00091     } else if (p_process_index_map.find(proc) == p_process_index_map.end()) {
00092         const int new_index = p_process_index_map.size();
00093         p_process_index_map[proc] = new_index;
00094         return new_index;
00095     } else {
00096         return rc_get_driver_process_index(proc);
00097     }
00098 }
00099 
00100 int rc_abstract_accessor_b::rc_register_nb_driver_process(
00101     sc_object* proc)
00102 {
00103 #ifndef RC_USE_SHARED_METHOD_DRIVER
00104     if (proc == NULL) {
00105         return 0;
00106     } else if (p_nb_process_index_map.find(proc) == p_nb_process_index_map.end()) {
00107         const int new_index = p_nb_process_index_map.size();
00108         p_nb_process_index_map[proc] = new_index;
00109         return new_index;
00110     } else {
00111         return rc_get_nb_driver_process_index(proc);
00112     }
00113 #else // RC_USE_SHARED_METHOD_DRIVER (optimisation)
00114     return 0; // always 0 because it will be the same driver anyway
00115 #endif
00116 }
00117 
00118 } // namespace ReChannel
00119 //
00120 // $Id: rc_abstract_accessor.cpp,v 1.5 2007/12/27 00:24:38 felke Exp $
00121 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/accessors/rc_abstract_accessor.cpp,v $
00122 //

Generated on Tue Jan 1 23:13:29 2008 for ReChannel by  doxygen 1.5.3