00001 /*-------------------------------------------------------------------- 00002 * 00003 * (C) Copyright Koninklijke Philips Electronics NV 2006. 00004 * All rights reserved. This software is licensed under the terms of 00005 * version 2.1 of the GNU Lesser General Public License as published 00006 * by the Free Software Foundation. For licensing and warranty 00007 * information, see the file COPYING in the main directory. 00008 * 00009 *------------------------------------------------------------------*/ 00010 00011 #include "rteport.h" 00012 #include "rtefifo.h" 00013 #include "portimpl.h" 00014 00015 rteInPort::rteInPort(InPortImpl& i, rteFifo& f) : 00016 base(&i), 00017 fifo(&f) 00018 { 00019 base->impl = this; 00020 fifo->in = this; 00021 } 00022 00023 rteInPort::~rteInPort() 00024 { 00025 base->impl = 0; 00026 fifo->in = 0; 00027 } 00028 00029 const InPortImpl* rteInPort::api() const 00030 { 00031 return base; 00032 } 00033 00034 void rteInPort::read(void* p, unsigned int nitems) 00035 { 00036 fifo->read(p, nitems); 00037 } 00038 00040 00041 rteOutPort::rteOutPort(OutPortImpl& o, rteFifo& f) : 00042 base(&o), 00043 fifo(&f) 00044 { 00045 base->impl.push_back(this); 00046 fifo->out = this; 00047 } 00048 00049 rteOutPort::~rteOutPort() 00050 { 00051 std::vector<rteOutPort*>::iterator i; 00052 for(i = base->impl.begin(); i != base->impl.end(); ++i) 00053 if (*i == this) 00054 break; 00055 if (*i == this) 00056 base->impl.erase(i); 00057 fifo->out = 0; 00058 } 00059 00060 const OutPortImpl* rteOutPort::api() const 00061 { 00062 return base; 00063 } 00064 00065 void rteOutPort::write(const void* p, unsigned int nitems) 00066 { 00067 fifo->write(p, nitems); 00068 }