source: Sophya/trunk/ArchTOIPipe/Kernel/toimanager.h@ 2389

Last change on this file since 2389 was 2386, checked in by aubourg, 22 years ago

ring pipes

File size: 3.2 KB
Line 
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: toimanager.h,v 1.18 2003-05-20 10:10:09 aubourg Exp $
8
9
10#ifndef TOIMANAGER_H
11#define TOIMANAGER_H
12
13#include "config.h"
14#include <string>
15#include <vector>
16
17#include "toiprocessor.h"
18#include "ringprocessor.h"
19
20
21#include "toi.h"
22#include "ringpipe.h"
23
24#include <typeinfo>
25#include "toiseqbuff.h"
26#include "toisegment.h"
27#include "fitstoiwtr.h"
28
29#ifdef WITH_SOPHYA
30#include "pexceptions.h"
31#else
32#include "apexceptions.h"
33#endif
34
35#include <pthread.h>
36
37
38
39
40using namespace std;
41
42class TOIManager {
43public:
44 static TOIManager* getManager();
45 virtual ~TOIManager() {}
46 void setRequestedSample(int begin, int end);
47 int getRequestedBegin();
48 int getRequestedEnd();
49
50 // ajout vf 25/07/2002
51 void startAll();
52 bool checkSamplesLimits(int pass);
53 void checkRingLimits();
54
55 void waitForAll();
56
57 void joinAll(); // deprecated. Use waitForAll();
58
59
60 // ajout cgt vf 19/08/2002
61
62 void selectTOISegmented(int bufsz=1024, int maxseg=20);
63 void selectTOISeqBuffered(int wsz=8192);
64
65 virtual TOI& connect(TOIProcessor& prout, string out,
66 TOIProcessor& prin, string in, string nom="",
67 int wbsz=0, bool withFlag=false);
68 virtual TOI& connect(TOIProcessor& prout, const char* out,
69 TOIProcessor& prin, const char* in, string nom="",
70 int wbsz=0, bool withFlag=false);
71
72 // fin ajout cgt
73
74 virtual RingPipe& connect(RingProcessor& pout, string out,
75 RingProcessor& pint, string in);
76
77
78protected:
79 TOIManager();
80 static TOIManager* instance;
81 long reqBegin;
82 long reqEnd;
83
84 vector<pthread_t*> threads;
85 void addThread(pthread_t*);
86
87 // ajout vf 25/07/2002
88
89 vector<TOIProcessor*> processors;
90 void registerProcessor(TOIProcessor* proc);
91 vector<RingProcessor*> ringProcessors;
92 void registerProcessor(RingProcessor* proc);
93
94 friend class TOIProcessor;
95 friend class RingProcessor;
96
97 // ajout cgt vf 19/08/2002
98
99 bool fgSegmented; // type de toi
100 int segBuffsz, segMaxseg;
101
102 // fin ajout cgt
103
104};
105
106// -----------------------------------------------------------------
107// Classe pour affichage de l'avancement des TOIProcessors
108// Reza 08/2001
109// -----------------------------------------------------------------
110
111class RzProcSampleCounter {
112public:
113 RzProcSampleCounter();
114 virtual ~RzProcSampleCounter();
115 virtual long ProcessedSampleCount() = 0;
116 virtual long SampleBegin() = 0;
117 virtual long SampleEnd() = 0;
118 virtual long PrintStats();
119 inline int & PrintRate(int pr) { return _rate; }
120 inline string& InfoMessage() { return _msg; }
121protected:
122 int _rate;
123 string _msg;
124};
125
126template <class T>
127class ProcSampleCounter : public RzProcSampleCounter {
128public:
129 ProcSampleCounter(T & t) { _t = &t; }
130 virtual long ProcessedSampleCount()
131 { return _t->ProcessedSampleCount(); }
132 virtual long SampleBegin() { return _t->getMinIn(); }
133 virtual long SampleEnd() { return _t->getMaxIn(); }
134protected:
135 T * _t;
136};
137
138
139
140
141#endif
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
Note: See TracBrowser for help on using the repository browser.