// This may look like C code, but it is really -*- C++ -*- // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: toimanager.h,v 1.19 2003-10-13 20:48:37 aubourg Exp $ #ifndef TOIMANAGER_H #define TOIMANAGER_H #include "config.h" #include #include #include "toiprocessor.h" #include "ringprocessor.h" #include "toi.h" #include "ringpipe.h" #include #include "toiseqbuff.h" #include "toisegment.h" //#include "fitstoiwtr.h" #ifdef WITH_SOPHYA #include "pexceptions.h" #else #include "apexceptions.h" #endif #include using namespace std; class TOIManager { public: static TOIManager* getManager(); virtual ~TOIManager() {} void setRequestedSample(long begin, long end); int getRequestedBegin(); int getRequestedEnd(); // ajout vf 25/07/2002 void startAll(); bool checkSamplesLimits(int pass); void checkRingLimits(); void waitForAll(); void joinAll(); // deprecated. Use waitForAll(); // ajout cgt vf 19/08/2002 void selectTOISegmented(int bufsz=1024, int maxseg=20); void selectTOISeqBuffered(int wsz=8192); virtual TOI& connect(TOIProcessor& prout, string out, TOIProcessor& prin, string in, string nom="", int wbsz=0, bool withFlag=false); virtual TOI& connect(TOIProcessor& prout, const char* out, TOIProcessor& prin, const char* in, string nom="", int wbsz=0, bool withFlag=false); // fin ajout cgt virtual RingPipe& connect(RingProcessor& pout, string out, RingProcessor& pint, string in); protected: TOIManager(); static TOIManager* instance; long reqBegin; long reqEnd; vector threads; void addThread(pthread_t*); // ajout vf 25/07/2002 vector processors; void registerProcessor(TOIProcessor* proc); vector ringProcessors; void registerProcessor(RingProcessor* proc); friend class TOIProcessor; friend class RingProcessor; // ajout cgt vf 19/08/2002 bool fgSegmented; // type de toi int segBuffsz, segMaxseg; // fin ajout cgt }; // ----------------------------------------------------------------- // Classe pour affichage de l'avancement des TOIProcessors // Reza 08/2001 // ----------------------------------------------------------------- class RzProcSampleCounter { public: RzProcSampleCounter(); virtual ~RzProcSampleCounter(); virtual long ProcessedSampleCount() = 0; virtual long SampleBegin() = 0; virtual long SampleEnd() = 0; virtual long PrintStats(); inline int & PrintRate(int pr) { return _rate; } inline string& InfoMessage() { return _msg; } protected: int _rate; string _msg; }; template class ProcSampleCounter : public RzProcSampleCounter { public: ProcSampleCounter(T & t) { _t = &t; } virtual long ProcessedSampleCount() { return _t->ProcessedSampleCount(); } virtual long SampleBegin() { return _t->getMinIn(); } virtual long SampleEnd() { return _t->getMaxIn(); } protected: T * _t; }; #endif