00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _GEDDEI_DOMPROCESSOR_H
00011 #define _GEDDEI_DOMPROCESSOR_H
00012
00013 #include <qmutex.h>
00014 #include <qptrlist.h>
00015
00016 #ifdef __GEDDEI_BUILD
00017 #include "properties.h"
00018 #include "processor.h"
00019 #include "qfastwaitcondition.h"
00020 #else
00021 #include <qtextra/qfastwaitcondition.h>
00022 #include <geddei/properties.h>
00023 #include <geddei/processor.h>
00024 #endif
00025
00026 namespace Geddei
00027 {
00028
00029 class DSCoupling;
00030 class DxCoupling;
00031 class SubProcessor;
00032
00077 class DomProcessor: public Processor
00078 {
00079
00080 uint theSamplesIn, theSamplesStep, theSamplesOut;
00081
00082
00083 uint theNomChunks, theMaxChunks;
00084 double theWeighting;
00085 bool theAlterBuffer;
00086 uint theOptimalThroughput, theWantSize;
00087
00088
00089 QPtrList<DxCoupling> theWorkers;
00090 QPtrList<DxCoupling>::Iterator theQueuePos;
00091 uint theQueueLen;
00092 QMutex theQueueLock;
00093 QFastWaitCondition theQueueChanged;
00094
00095
00096 bool theStopped;
00097
00098
00099 bool theDebug;
00100
00101
00102 bool theBalanceLoad;
00103 uint theBalanceInterval;
00104 float theLocalFudge;
00105
00106
00107 Properties theProperties;
00108
00113 bool theLimbo;
00114
00115
00116 friend class DxCoupling;
00117 SubProcessor *thePrimary;
00118 DSCoupling *thePrimaryCoupling;
00119
00120
00121 class EaterThread: public QThread
00122 {
00123 DomProcessor *theDomProcessor;
00124 virtual void run();
00125 public:
00126 EaterThread(DomProcessor *d) : theDomProcessor(d) {}
00127 virtual ~EaterThread() {}
00128 } theEaterThread;
00129
00134 void eater();
00135
00142 void checkExitDontLock();
00143
00162 void setupVisual(const uint width = 50, const uint height = 30, const uint redrawPeriod = 0) { Processor::setupVisual(width, height, redrawPeriod); }
00163 friend class SubProcessor;
00164
00165
00166 virtual const bool processorStarted();
00167 virtual void processor();
00168 virtual void wantToStopNow();
00169 virtual void haveStoppedNow();
00170 virtual const bool verifyAndSpecifyTypes(const SignalTypeRefs &inTypes, SignalTypeRefs &outTypes);
00171 virtual PropertiesInfo specifyProperties() const;
00172 virtual void initFromProperties(const Properties &properties);
00173 virtual void specifyInputSpace(QValueVector<uint> &samples);
00174 virtual void specifyOutputSpace(QValueVector<uint> &samples);
00175 virtual void paintProcessor(QPainter &p);
00176
00183 virtual void checkExit();
00184
00194 void addWorker(SubProcessor *worker);
00195
00196 public:
00205 void ratify(DxCoupling *c);
00206
00217 const bool createAndAddWorker();
00218
00228 const bool createAndAddWorker(const QString &host, const uint key);
00229
00237 DomProcessor(SubProcessor *primary);
00238
00245 DomProcessor(const QString &primaryType);
00246
00250 virtual ~DomProcessor();
00251 };
00252
00253 };
00254
00255 #endif