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_object_handle.h" 00038 00039 namespace ReChannel { 00040 00041 rc_object_handle::rc_object_handle() 00042 : p_object(NULL), p_channel_if(NULL) 00043 { } 00044 00045 rc_object_handle::rc_object_handle(sc_object& obj_) 00046 : p_object(&obj_) 00047 { 00048 p_channel_if = dynamic_cast<sc_interface*>(&obj_); 00049 } 00050 00051 rc_object_handle::rc_object_handle(const rc_port_handle& port_) 00052 : p_object(port_.get_object()), p_channel_if(NULL), p_port(port_) 00053 { } 00054 00055 rc_object_handle::rc_object_handle(const rc_export_handle& export_) 00056 : p_object(export_.get_object()), p_channel_if(NULL), p_export(export_) 00057 { } 00058 00059 rc_object_handle& rc_object_handle::operator=( 00060 sc_object& obj_) 00061 { 00062 p_object = &obj_; 00063 p_channel_if = dynamic_cast<sc_interface*>(&obj_); 00064 p_port.reset(); 00065 p_export.reset(); 00066 return *this; 00067 } 00068 00069 rc_object_handle& rc_object_handle::operator=( 00070 const rc_port_handle& port_) 00071 { 00072 p_object = port_.get_object(); 00073 p_channel_if = NULL; 00074 p_port = port_; 00075 p_export.reset(); 00076 return *this; 00077 } 00078 00079 rc_object_handle& rc_object_handle::operator=( 00080 const rc_export_handle& export_) 00081 { 00082 p_object = export_.get_object(); 00083 p_channel_if = NULL; 00084 p_port.reset(); 00085 p_export = export_; 00086 return *this; 00087 } 00088 00089 sc_interface* rc_object_handle::get_interface() const 00090 { 00091 if (p_channel_if != NULL) { 00092 return p_channel_if; 00093 } else if (p_port.valid()) { 00094 return p_port.get_interface(); 00095 } else if (p_export.valid()) { 00096 return p_export.get_interface(); 00097 } else { 00098 return NULL; 00099 } 00100 } 00101 00102 } // namespace ReChannel 00103 00104 // 00105 // $Id: rc_object_handle.cpp,v 1.3 2007/10/09 00:22:26 felke Exp $ 00106 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/util/rc_object_handle.cpp,v $ 00107 // 00108