| 1 | // This may look like C code, but it is really -*- C++ -*-
|
|---|
| 2 |
|
|---|
| 3 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
|---|
| 4 | // Eric Aubourg
|
|---|
| 5 | // Christophe Magneville
|
|---|
| 6 | // Reza Ansari
|
|---|
| 7 | // $Id: ringprocessor.h,v 1.3 2003-05-28 21:03:19 aubourg Exp $
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | #ifndef RINGPROCESSOR_H
|
|---|
| 12 | #define RINGPROCESSOR_H
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | #include "config.h"
|
|---|
| 16 |
|
|---|
| 17 | #include <pthread.h>
|
|---|
| 18 | #include <string>
|
|---|
| 19 | #include <map>
|
|---|
| 20 |
|
|---|
| 21 | class Ring;
|
|---|
| 22 | class RingPipe;
|
|---|
| 23 |
|
|---|
| 24 | class RingProcessor {
|
|---|
| 25 | public:
|
|---|
| 26 | RingProcessor();
|
|---|
| 27 | virtual ~RingProcessor();
|
|---|
| 28 | virtual void init();
|
|---|
| 29 | protected:
|
|---|
| 30 | int declareRingInput(string ring);
|
|---|
| 31 | int declareRingOutput(string ring);
|
|---|
| 32 |
|
|---|
| 33 | void chkinit() {
|
|---|
| 34 | if (!inited) {init(); afterinit(); inited=true;}
|
|---|
| 35 | }
|
|---|
| 36 | bool inited;
|
|---|
| 37 | virtual void afterinit();
|
|---|
| 38 |
|
|---|
| 39 | public:
|
|---|
| 40 | virtual void run();
|
|---|
| 41 |
|
|---|
| 42 | virtual int getMinRingIndex() {return ringBegin;}
|
|---|
| 43 | virtual int getMaxRingIndex() {return ringEnd;}
|
|---|
| 44 | virtual void setRingRange(int min, int max) {ringBegin=min; ringEnd=max;}
|
|---|
| 45 |
|
|---|
| 46 | virtual void addRingInput(string name, RingPipe* ring);
|
|---|
| 47 | virtual void addRingOutput(string name, RingPipe* ring);
|
|---|
| 48 |
|
|---|
| 49 | virtual void start();
|
|---|
| 50 | virtual void setName(string n) {name=n;}
|
|---|
| 51 |
|
|---|
| 52 | virtual int getWontNeedBefore() {return wontNeedRing;}
|
|---|
| 53 |
|
|---|
| 54 | virtual void setNeededRingHistory(int nrings); // -1 : disable
|
|---|
| 55 |
|
|---|
| 56 | protected:
|
|---|
| 57 | virtual Ring const* getRing(int index, int i); // le ring sera desalloue par le systeme
|
|---|
| 58 | virtual void putRing(int index, int i, Ring const*); // le ring a ete alloue par new, il sera gere
|
|---|
| 59 | // par le systeme.
|
|---|
| 60 |
|
|---|
| 61 | RingPipe* getInputRing(int index);
|
|---|
| 62 | RingPipe* getOutputRing(int index);
|
|---|
| 63 | RingPipe* getOutRing(string out);
|
|---|
| 64 | virtual void wontNeedRingBefore(int i);
|
|---|
| 65 | friend class RingPipe;
|
|---|
| 66 | friend class TOIManager;
|
|---|
| 67 | virtual void getRingRange(int& min, int& max);
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | int ringBegin;
|
|---|
| 71 | int ringEnd;
|
|---|
| 72 | int wontNeedRing;
|
|---|
| 73 | int neededRingHistory;
|
|---|
| 74 |
|
|---|
| 75 | void autoWontNeedRing(int iCur);
|
|---|
| 76 | int lastAWNR;
|
|---|
| 77 |
|
|---|
| 78 | map<string, int> inRingIx;
|
|---|
| 79 | map<string, int> outRingIx;
|
|---|
| 80 |
|
|---|
| 81 | RingPipe** inRings;
|
|---|
| 82 | RingPipe** outRings;
|
|---|
| 83 |
|
|---|
| 84 | string name;
|
|---|
| 85 |
|
|---|
| 86 | pthread_t thread;
|
|---|
| 87 |
|
|---|
| 88 | static void* ThreadStart(void *);
|
|---|
| 89 | };
|
|---|
| 90 | #endif
|
|---|