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 "networkbase.h" 00013 #include "fifobase.h" 00014 #include <assert.h> 00015 00016 NetworkBase::NetworkBase(const IdBase& n) : 00017 Component(n) 00018 { 00019 if (parent()) 00020 insert(parentNetwork(), this); 00021 } 00022 00023 NetworkBase* NetworkBase::parentNetwork() const 00024 { 00025 return (NetworkBase*)parent(); 00026 } 00027 00028 unsigned int NetworkBase::nrFifos() const 00029 { 00030 return fi.size(); 00031 } 00032 00033 unsigned int NetworkBase::nrProcesses() const 00034 { 00035 return pr.size(); 00036 } 00037 00038 unsigned int NetworkBase::nrNetworks() const 00039 { 00040 return nw.size(); 00041 } 00042 00043 FifoBase* NetworkBase::getFifo(unsigned int i) const 00044 { 00045 assert(i < fi.size()); 00046 return fi[i]; 00047 } 00048 00049 ProcessBase* NetworkBase::getProcess(unsigned int i) const 00050 { 00051 assert(i < pr.size()); 00052 return pr[i]; 00053 } 00054 00055 NetworkBase* NetworkBase::getNetwork(unsigned int i) const 00056 { 00057 assert(i < nw.size()); 00058 return nw[i]; 00059 } 00060 00061 00063 00064 void insert(NetworkBase* n, FifoBase* f) 00065 { 00066 n->fi.push_back(f); 00067 } 00068 00069 void insert(NetworkBase* n, ProcessBase* p) 00070 { 00071 n->pr.push_back(p); 00072 } 00073 00074 void insert(NetworkBase* n, NetworkBase* p) 00075 { 00076 n->nw.push_back(p); 00077 }