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.1 2003-05-19 23:31:29 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();
|
---|
43 | virtual int getMaxRingIndex();
|
---|
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 |
|
---|
55 | protected:
|
---|
56 | virtual Ring const* getRing(int index, int i); // le ring sera desalloue par le systeme
|
---|
57 | virtual void putRing(int index, int i, Ring const*); // le ring a ete alloue par new, il sera gere
|
---|
58 | // par le systeme.
|
---|
59 |
|
---|
60 | RingPipe* getInputRing(int index);
|
---|
61 | RingPipe* getOutputRing(int index);
|
---|
62 | virtual void wontNeedRingBefore(int i);
|
---|
63 | friend class RingPipe;
|
---|
64 | virtual void getRingRange(int& min, int& max);
|
---|
65 |
|
---|
66 |
|
---|
67 | int ringBegin;
|
---|
68 | int ringEnd;
|
---|
69 | int wontNeedRing;
|
---|
70 |
|
---|
71 | map<string, int> inRingIx;
|
---|
72 | map<string, int> outRingIx;
|
---|
73 |
|
---|
74 | RingPipe** inRings;
|
---|
75 | RingPipe** outRings;
|
---|
76 |
|
---|
77 | string name;
|
---|
78 |
|
---|
79 | pthread_t thread;
|
---|
80 |
|
---|
81 | static void* ThreadStart(void *);
|
---|
82 | };
|
---|
83 | #endif
|
---|