| 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.13 2002-05-14 13:06:57 ansari Exp $ | 
|---|
| 8 |  | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef TOIMANAGER_H | 
|---|
| 11 | #define TOIMANAGER_H | 
|---|
| 12 |  | 
|---|
| 13 | #include "config.h" | 
|---|
| 14 | #include <string> | 
|---|
| 15 | #include <vector> | 
|---|
| 16 |  | 
|---|
| 17 | using namespace std; | 
|---|
| 18 |  | 
|---|
| 19 | class TOIManager { | 
|---|
| 20 | public: | 
|---|
| 21 | static TOIManager* getManager(); | 
|---|
| 22 | void setRequestedSample(int begin, int end); | 
|---|
| 23 | int getRequestedBegin(); | 
|---|
| 24 | int getRequestedEnd(); | 
|---|
| 25 | void addThread(pthread_t*); | 
|---|
| 26 | void joinAll(); | 
|---|
| 27 |  | 
|---|
| 28 | protected: | 
|---|
| 29 | TOIManager(); | 
|---|
| 30 | static TOIManager* instance; | 
|---|
| 31 | long reqBegin; | 
|---|
| 32 | long reqEnd; | 
|---|
| 33 |  | 
|---|
| 34 | vector<pthread_t*> threads; | 
|---|
| 35 | }; | 
|---|
| 36 |  | 
|---|
| 37 | // ----------------------------------------------------------------- | 
|---|
| 38 | //    Classe pour affichage de l'avancement des TOIProcessors | 
|---|
| 39 | //                         Reza 08/2001 | 
|---|
| 40 | // ----------------------------------------------------------------- | 
|---|
| 41 |  | 
|---|
| 42 | class RzProcSampleCounter { | 
|---|
| 43 | public: | 
|---|
| 44 | RzProcSampleCounter(); | 
|---|
| 45 | virtual       ~RzProcSampleCounter(); | 
|---|
| 46 | virtual long  ProcessedSampleCount() = 0; | 
|---|
| 47 | virtual long  SampleBegin() = 0; | 
|---|
| 48 | virtual long  SampleEnd() = 0; | 
|---|
| 49 | virtual long  PrintStats(); | 
|---|
| 50 | inline int &  PrintRate(int pr) { return _rate; } | 
|---|
| 51 | inline string& InfoMessage() { return _msg; } | 
|---|
| 52 | protected: | 
|---|
| 53 | int _rate; | 
|---|
| 54 | string _msg; | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | template <class T> | 
|---|
| 58 | class ProcSampleCounter : public RzProcSampleCounter { | 
|---|
| 59 | public: | 
|---|
| 60 | ProcSampleCounter(T & t) { _t = &t; } | 
|---|
| 61 | virtual long  ProcessedSampleCount() | 
|---|
| 62 | { return _t->ProcessedSampleCount(); } | 
|---|
| 63 | virtual long  SampleBegin() { return _t->getMinIn(); } | 
|---|
| 64 | virtual long  SampleEnd() { return _t->getMaxIn(); } | 
|---|
| 65 | protected: | 
|---|
| 66 | T * _t; | 
|---|
| 67 | }; | 
|---|
| 68 |  | 
|---|
| 69 | #endif | 
|---|
| 70 |  | 
|---|