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 #ifndef COSYSELECT_H 00012 #define COSYSELECT_H 00013 00014 #include "rte.h" 00015 #include "rteselect.h" 00016 #include "semaphoreapi.h" 00017 #ifdef PREEMPTIVE 00018 #include "mutexapi.h" 00019 #endif 00020 00021 #include <vector> 00022 00023 class cosyFifo; 00024 class InPortImpl; 00025 class OutPortImpl; 00026 00027 class cosySelect : public rteSelect 00028 { 00029 public: 00030 cosySelect(SelectImpl& s, cosyRte& r); 00031 ~cosySelect(); 00032 00033 void pushBack(const InPortImpl& p, unsigned int n); 00034 void pushBack(const OutPortImpl& p, unsigned int n); 00035 00036 unsigned int select(); 00037 00038 00039 void signal(); // should be private, 00040 // but is called by cosyFifo::read/write 00041 00042 private: 00043 static bool random; 00044 00045 std::vector<cosyFifo*> f; // the fifos 00046 std::vector<unsigned int> s; // number of items 00047 std::vector<bool> input; // true when select from input 00048 std::vector<unsigned int> r; // return values 00049 00050 unsigned int retvalue; 00051 Semaphore sema; 00052 bool block; 00053 cosyRte* rte; 00054 00055 #ifdef PREEMPTIVE 00056 Mutex mutex; 00057 void lock(); 00058 void unlock(); 00059 #endif 00060 00061 friend class cosyNetwork; 00062 }; 00063 00064 #endif