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.14 2002-07-26 08:52:43 vfebvre 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 |
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 | class TOIManager {
|
---|
22 | public:
|
---|
23 | static TOIManager* getManager();
|
---|
24 | void setRequestedSample(int begin, int end);
|
---|
25 | int getRequestedBegin();
|
---|
26 | int getRequestedEnd();
|
---|
27 |
|
---|
28 | void startAll();
|
---|
29 | void waitForAll();
|
---|
30 |
|
---|
31 | void joinAll(); // deprecated. Use waitForAll();
|
---|
32 |
|
---|
33 | protected:
|
---|
34 | TOIManager();
|
---|
35 | static TOIManager* instance;
|
---|
36 | long reqBegin;
|
---|
37 | long reqEnd;
|
---|
38 |
|
---|
39 | vector<pthread_t*> threads;
|
---|
40 | void addThread(pthread_t*);
|
---|
41 |
|
---|
42 | vector<TOIProcessor*> processors;
|
---|
43 | void registerProcessor(TOIProcessor* proc);
|
---|
44 |
|
---|
45 |
|
---|
46 | friend class TOIProcessor;
|
---|
47 | };
|
---|
48 |
|
---|
49 | // -----------------------------------------------------------------
|
---|
50 | // Classe pour affichage de l'avancement des TOIProcessors
|
---|
51 | // Reza 08/2001
|
---|
52 | // -----------------------------------------------------------------
|
---|
53 |
|
---|
54 | class RzProcSampleCounter {
|
---|
55 | public:
|
---|
56 | RzProcSampleCounter();
|
---|
57 | virtual ~RzProcSampleCounter();
|
---|
58 | virtual long ProcessedSampleCount() = 0;
|
---|
59 | virtual long SampleBegin() = 0;
|
---|
60 | virtual long SampleEnd() = 0;
|
---|
61 | virtual long PrintStats();
|
---|
62 | inline int & PrintRate(int pr) { return _rate; }
|
---|
63 | inline string& InfoMessage() { return _msg; }
|
---|
64 | protected:
|
---|
65 | int _rate;
|
---|
66 | string _msg;
|
---|
67 | };
|
---|
68 |
|
---|
69 | template <class T>
|
---|
70 | class ProcSampleCounter : public RzProcSampleCounter {
|
---|
71 | public:
|
---|
72 | ProcSampleCounter(T & t) { _t = &t; }
|
---|
73 | virtual long ProcessedSampleCount()
|
---|
74 | { return _t->ProcessedSampleCount(); }
|
---|
75 | virtual long SampleBegin() { return _t->getMinIn(); }
|
---|
76 | virtual long SampleEnd() { return _t->getMaxIn(); }
|
---|
77 | protected:
|
---|
78 | T * _t;
|
---|
79 | };
|
---|
80 |
|
---|
81 | #endif
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|