[1365] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 |
|
---|
[1738] | 3 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 4 | // Eric Aubourg
|
---|
| 5 | // Christophe Magneville
|
---|
| 6 | // Reza Ansari
|
---|
[2133] | 7 | // $Id: toimanager.h,v 1.14 2002-07-26 08:52:43 vfebvre Exp $
|
---|
[1738] | 8 |
|
---|
| 9 |
|
---|
[1365] | 10 | #ifndef TOIMANAGER_H
|
---|
| 11 | #define TOIMANAGER_H
|
---|
| 12 |
|
---|
[1766] | 13 | #include "config.h"
|
---|
[1687] | 14 | #include <string>
|
---|
[1766] | 15 | #include <vector>
|
---|
[1365] | 16 |
|
---|
[2133] | 17 | #include "toiprocessor.h"
|
---|
| 18 |
|
---|
[1410] | 19 | using namespace std;
|
---|
| 20 |
|
---|
[1365] | 21 | class TOIManager {
|
---|
| 22 | public:
|
---|
| 23 | static TOIManager* getManager();
|
---|
[1702] | 24 | void setRequestedSample(int begin, int end);
|
---|
| 25 | int getRequestedBegin();
|
---|
| 26 | int getRequestedEnd();
|
---|
[1365] | 27 |
|
---|
[2133] | 28 | void startAll();
|
---|
| 29 | void waitForAll();
|
---|
| 30 |
|
---|
| 31 | void joinAll(); // deprecated. Use waitForAll();
|
---|
| 32 |
|
---|
[1365] | 33 | protected:
|
---|
| 34 | TOIManager();
|
---|
| 35 | static TOIManager* instance;
|
---|
| 36 | long reqBegin;
|
---|
| 37 | long reqEnd;
|
---|
| 38 |
|
---|
| 39 | vector<pthread_t*> threads;
|
---|
[2133] | 40 | void addThread(pthread_t*);
|
---|
| 41 |
|
---|
| 42 | vector<TOIProcessor*> processors;
|
---|
| 43 | void registerProcessor(TOIProcessor* proc);
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | friend class TOIProcessor;
|
---|
[1365] | 47 | };
|
---|
| 48 |
|
---|
[1687] | 49 | // -----------------------------------------------------------------
|
---|
| 50 | // Classe pour affichage de l'avancement des TOIProcessors
|
---|
| 51 | // Reza 08/2001
|
---|
| 52 | // -----------------------------------------------------------------
|
---|
| 53 |
|
---|
| 54 | class RzProcSampleCounter {
|
---|
| 55 | public:
|
---|
[1702] | 56 | RzProcSampleCounter();
|
---|
[1687] | 57 | virtual ~RzProcSampleCounter();
|
---|
[1702] | 58 | virtual long ProcessedSampleCount() = 0;
|
---|
[1999] | 59 | virtual long SampleBegin() = 0;
|
---|
| 60 | virtual long SampleEnd() = 0;
|
---|
[1687] | 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:
|
---|
[2000] | 72 | ProcSampleCounter(T & t) { _t = &t; }
|
---|
[1702] | 73 | virtual long ProcessedSampleCount()
|
---|
| 74 | { return _t->ProcessedSampleCount(); }
|
---|
[1999] | 75 | virtual long SampleBegin() { return _t->getMinIn(); }
|
---|
| 76 | virtual long SampleEnd() { return _t->getMaxIn(); }
|
---|
[1687] | 77 | protected:
|
---|
[2000] | 78 | T * _t;
|
---|
[1687] | 79 | };
|
---|
| 80 |
|
---|
[1365] | 81 | #endif
|
---|
[1702] | 82 |
|
---|
[2133] | 83 |
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 |
|
---|