[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
|
---|
[2220] | 7 | // $Id: toimanager.h,v 1.16 2002-10-23 21:05:18 aubourg 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 |
|
---|
[2187] | 19 |
|
---|
| 20 | // -----------ajout cgt vf 19/08/2002
|
---|
| 21 |
|
---|
| 22 | #include "toi.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 | // ----------fin ajout cgt
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 |
|
---|
[1410] | 40 | using namespace std;
|
---|
| 41 |
|
---|
[1365] | 42 | class TOIManager {
|
---|
| 43 | public:
|
---|
| 44 | static TOIManager* getManager();
|
---|
[1702] | 45 | void setRequestedSample(int begin, int end);
|
---|
| 46 | int getRequestedBegin();
|
---|
| 47 | int getRequestedEnd();
|
---|
[1365] | 48 |
|
---|
[2187] | 49 | // ajout vf 25/07/2002
|
---|
[2133] | 50 | void startAll();
|
---|
[2187] | 51 | bool checkSamplesLimits(int pass);
|
---|
| 52 |
|
---|
[2133] | 53 | void waitForAll();
|
---|
| 54 |
|
---|
| 55 | void joinAll(); // deprecated. Use waitForAll();
|
---|
| 56 |
|
---|
[2187] | 57 |
|
---|
| 58 | // ajout cgt vf 19/08/2002
|
---|
| 59 |
|
---|
| 60 | void selectTOISegmented(int bufsz=1024, int maxseg=20);
|
---|
| 61 | void selectTOISeqBuffered(int wsz=8192);
|
---|
| 62 |
|
---|
[2220] | 63 | virtual TOI& connect(TOIProcessor& prout, string out,
|
---|
| 64 | TOIProcessor& prin, string in, string nom="",
|
---|
[2187] | 65 | int wbsz=0, bool withFlag=false);
|
---|
| 66 | virtual TOI& connect(TOIProcessor& prout, const char* out,
|
---|
| 67 | TOIProcessor& prin, const char* in, string nom="",
|
---|
| 68 | int wbsz=0, bool withFlag=false);
|
---|
| 69 |
|
---|
| 70 | // fin ajout cgt
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 |
|
---|
[1365] | 75 | protected:
|
---|
| 76 | TOIManager();
|
---|
| 77 | static TOIManager* instance;
|
---|
| 78 | long reqBegin;
|
---|
| 79 | long reqEnd;
|
---|
| 80 |
|
---|
| 81 | vector<pthread_t*> threads;
|
---|
[2133] | 82 | void addThread(pthread_t*);
|
---|
| 83 |
|
---|
[2187] | 84 | // ajout vf 25/07/2002
|
---|
| 85 |
|
---|
[2133] | 86 | vector<TOIProcessor*> processors;
|
---|
| 87 | void registerProcessor(TOIProcessor* proc);
|
---|
| 88 |
|
---|
[2187] | 89 | friend class TOIProcessor;
|
---|
[2133] | 90 |
|
---|
[2187] | 91 | // ajout cgt vf 19/08/2002
|
---|
| 92 |
|
---|
| 93 | bool fgSegmented; // type de toi
|
---|
| 94 | int segBuffsz, segMaxseg;
|
---|
| 95 |
|
---|
| 96 | // fin ajout cgt
|
---|
| 97 |
|
---|
[1365] | 98 | };
|
---|
| 99 |
|
---|
[1687] | 100 | // -----------------------------------------------------------------
|
---|
| 101 | // Classe pour affichage de l'avancement des TOIProcessors
|
---|
| 102 | // Reza 08/2001
|
---|
| 103 | // -----------------------------------------------------------------
|
---|
| 104 |
|
---|
| 105 | class RzProcSampleCounter {
|
---|
| 106 | public:
|
---|
[1702] | 107 | RzProcSampleCounter();
|
---|
[1687] | 108 | virtual ~RzProcSampleCounter();
|
---|
[1702] | 109 | virtual long ProcessedSampleCount() = 0;
|
---|
[1999] | 110 | virtual long SampleBegin() = 0;
|
---|
| 111 | virtual long SampleEnd() = 0;
|
---|
[1687] | 112 | virtual long PrintStats();
|
---|
| 113 | inline int & PrintRate(int pr) { return _rate; }
|
---|
| 114 | inline string& InfoMessage() { return _msg; }
|
---|
| 115 | protected:
|
---|
| 116 | int _rate;
|
---|
| 117 | string _msg;
|
---|
| 118 | };
|
---|
| 119 |
|
---|
| 120 | template <class T>
|
---|
| 121 | class ProcSampleCounter : public RzProcSampleCounter {
|
---|
| 122 | public:
|
---|
[2000] | 123 | ProcSampleCounter(T & t) { _t = &t; }
|
---|
[1702] | 124 | virtual long ProcessedSampleCount()
|
---|
| 125 | { return _t->ProcessedSampleCount(); }
|
---|
[1999] | 126 | virtual long SampleBegin() { return _t->getMinIn(); }
|
---|
| 127 | virtual long SampleEnd() { return _t->getMaxIn(); }
|
---|
[1687] | 128 | protected:
|
---|
[2000] | 129 | T * _t;
|
---|
[1687] | 130 | };
|
---|
| 131 |
|
---|
[2187] | 132 |
|
---|
| 133 |
|
---|
| 134 |
|
---|
[1365] | 135 | #endif
|
---|
[1702] | 136 |
|
---|
[2133] | 137 |
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 |
|
---|