Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

portbase.cc

Go to the documentation of this file.
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 <sys/types.h>
00012 #include "component.h"
00013 #include "portbase.h"
00014 #include "fifobase.h"
00015 #include <assert.h>
00016 
00017 PortBase::PortBase(const IdBase& n) : Connector(n)
00018 { }
00019 
00020 Component* PortBase::parentComponent() const
00021 {
00022   return (Component*)parent();
00023 }
00024 
00026 
00027 
00028 InPortBase::InPortBase(const IdBase& n, Connector& c) : PortBase(n)
00029 {
00030   insert(parentComponent(), this);
00031   link(c, *this);
00032 }
00033 
00034 FifoBase* InPortBase::getSrcFifo() const
00035 {
00036   // src might be an InPort or Fifo !!
00037   Connector* c = getSrc();
00038   if (c->isFifo())
00039     return (FifoBase*)c;
00040   else
00041     return 0;
00042 }
00043 
00044 InPortBase* InPortBase::getSrcPort() const
00045 {
00046   // src might be an InPort or Fifo !!
00047   Connector* c = getSrc();
00048   if (c->isFifo())
00049     return 0;
00050   else
00051     return (InPortBase*)c;
00052 }
00053 
00054 InPortBase* InPortBase::getDstPort(unsigned int i) const
00055 {
00056   // dst is Inport or 0
00057   return (InPortBase*)getDst(i);
00058 }
00059 
00060 
00061 
00062 OutPortBase::OutPortBase(const IdBase& n, Connector& c) : PortBase(n)
00063 {
00064   insert(parentComponent(), this);
00065   link(*this, c);
00066 }
00067 
00068 FifoBase* OutPortBase::getDstFifo(unsigned int i) const
00069 {
00070   Connector* c = getDst(i);
00071   if (c->isFifo())
00072     return (FifoBase*)c;
00073   else
00074     return 0;
00075 }
00076 
00077 OutPortBase* OutPortBase::getDstPort(unsigned int i) const
00078 {
00079   Connector* c = getDst(i);
00080   if (c->isFifo())
00081     return 0;
00082   else
00083     return (OutPortBase*)c;
00084 }
00085 
00086 OutPortBase* OutPortBase::getSrcPort() const
00087 {
00088   assert(nrSrc() > 0);
00089   return (OutPortBase*)getSrc();
00090 }
00091 

Generated on Wed Feb 15 14:52:39 2006 for yapi by doxygen 1.3.2