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

utilbase.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 "utilbase.h"
00013 #include "component.h"
00014 #include "portbase.h"
00015 #include "fifobase.h"
00016 #include "processbase.h"
00017 #include "networkbase.h"
00018 #include <string.h>
00019 
00020 // get fifo that is (indirectly) connected to this port
00021 FifoBase* getFarFifo(const InPortBase* p)
00022 {
00023   FifoBase* f = p->getSrcFifo();
00024   if (f)
00025     return f;
00026   else
00027     return getFarFifo((InPortBase*)p->getSrc());
00028 }
00029 
00030 FifoBase* getFarFifo(const OutPortBase* p)
00031 {
00032   FifoBase* f = p->getDstFifo();
00033   if (f)
00034     return f;
00035   else
00036     return getFarFifo((OutPortBase*)p->getDst());
00037 }
00038 
00039 // get process port that reads/wites fifo f
00040 InPortBase*  getFarInPort(const FifoBase* f)
00041 {
00042   InPortBase* p = f->dstPort();
00043   while (p->nrDst())
00044     p = p->getDstPort();
00045   return p;
00046 }
00047 
00048 OutPortBase* getFarOutPort(const FifoBase* f)
00049 {
00050   OutPortBase* p = f->srcPort();
00051   while (p->nrSrc())
00052     p = p->getSrcPort();
00053   return p;
00054 }
00055 
00056 void getFarInPorts(const FifoBase* f, InPortBases& ports)
00057 {
00058   for(unsigned int i=0; i<f->nrDst(); i++)
00059   {
00060     InPortBase* p = f->dstPort(i);
00061     if (p->nrDst() == 0) 
00062       ports.push_back(p);
00063     else 
00064        getFarInPorts(p, ports);
00065   }
00066 }
00067 
00068 void getFarInPorts(const InPortBase* p, InPortBases& ports)
00069 {
00070   for(unsigned int i=0; i<p->nrDst(); i++)
00071   {
00072     InPortBase* q = p->getDstPort(i);
00073     if (q->nrDst() == 0)
00074       ports.push_back(q);
00075     else
00076        getFarInPorts(q, ports);
00077   }
00078 }
00079 
00080 void getFarOutPorts(const FifoBase* f, OutPortBases& ports)
00081 {
00082   OutPortBase* p = f->srcPort();
00083   if (p->nrSrc() == 0) 
00084     ports.push_back(p);
00085   else 
00086     getFarOutPorts(p->getSrcPort(), ports);
00087 }
00088 
00089 
00090 void getFarOutPorts(const OutPortBase* p, OutPortBases& ports)
00091 {
00092   if (p->nrSrc() == 0)
00093     ports.push_back(p);
00094   else
00095     getFarOutPorts(p->getSrcPort(), ports);
00096 }
00097 
00098 
00099 
00100 InPortBase*  getFarInPort(const InPortBase* p);
00101 OutPortBase* getFarOutPort(const OutPortBase* p);
00102 
00103 
00105 
00106 InPortBase* findInPort(const Component* c, const char* name)
00107 {
00108   for (unsigned int i=0; i<c->nrInPorts(); i++)
00109   {
00110     InPortBase* p = c->getInPort(i);
00111     if (strcmp(name, p->name()) == 0)
00112       return p;
00113   }
00114   return 0;
00115 }
00116 
00117 OutPortBase* findOutPort(const Component* c, const char* name)
00118 {
00119   for (unsigned int i=0; i<c->nrOutPorts(); i++)
00120   {
00121     OutPortBase* p = c->getOutPort(i);
00122     if (strcmp(name, p->name()) == 0)
00123       return p;
00124   }
00125   return 0;
00126 }
00127 
00129 
00130 FifoBase* findFifo(const NetworkBase* n, const char* name)
00131 {
00132   for (unsigned int i=0; i<n->nrFifos(); i++)
00133   {
00134     FifoBase* f = n->getFifo(i);
00135     if (strcmp(name, f->name()) == 0)
00136       return f;
00137   }
00138   return 0;
00139 }
00140 
00141 ProcessBase* findProcess(const NetworkBase* n, const char* name)
00142 {
00143   for (unsigned int i=0; i<n->nrProcesses(); i++)
00144   {
00145     ProcessBase* p = n->getProcess(i);
00146     if (strcmp(name, p->name()) == 0)
00147       return p;
00148   }
00149   return 0;
00150 }
00151 
00152 NetworkBase* findNetwork(const NetworkBase* n, const char* name)
00153 {
00154   for (unsigned int i=0; i<n->nrNetworks(); i++)
00155   {
00156     NetworkBase* w = n->getNetwork(i);
00157     if (strcmp(name, w->name()) == 0)
00158       return w;
00159   }
00160   return 0;
00161 }
00162 
00164 
00165 FifoBase*    recFindFifo   (const NetworkBase* n, const char* name);
00166 FifoBase*    recFindInPort (const NetworkBase* n, const char* name);
00167 FifoBase*    recFindOutPort(const NetworkBase* n, const char* name);
00168 ProcessBase* recFindProcess(const NetworkBase* n, const char* name);
00169 NetworkBase* recFindNetwork(const NetworkBase* n, const char* name);
00170 

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