00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _GEDDEI_SUBPROCESSOR_H
00011 #define _GEDDEI_SUBPROCESSOR_H
00012
00013 #include <qstring.h>
00014 #include <qmutex.h>
00015 #include <qthread.h>
00016 #include <qpainter.h>
00017
00018 #ifdef __GEDDEI_BUILD
00019 #include "qfastwaitcondition.h"
00020 #include "globals.h"
00021 #include "properties.h"
00022 #include "bufferdatas.h"
00023 #include "signaltyperefs.h"
00024 #else
00025 #include <qtextra/qfastwaitcondition.h>
00026 #include <geddei/globals.h>
00027 #include <geddei/properties.h>
00028 #include <geddei/bufferdatas.h>
00029 #include <geddei/signaltyperefs.h>
00030 #endif
00031
00032 namespace Geddei
00033 {
00034
00035 class ProcessorForwarder;
00036 class DomProcessor;
00037 class xSCoupling;
00038
00096 class SubProcessor: public QThread
00097 {
00098 friend class Combination;
00099
00101
00102 QString theType;
00103 uint theNumInputs, theNumOutputs, theIn, theOut, theStep;
00104 MultiplicityType theMulti;
00106
00108
00109 BufferDatas theCurrentIn, theCurrentOut;
00110 SignalTypeRefs theOutTypes;
00111 bool theReturned, theLoaded;
00112 uint theChunks;
00113 mutable QMutex theDataInUse;
00114 mutable QFastWaitCondition theDataChanged;
00116
00118
00119 uint theTimeTaken;
00121
00123
00124 virtual void run();
00126
00130 bool theStopping;
00131
00139 bool theNoMoreTransactions;
00140
00142
00143 DomProcessor *thePrimaryOf;
00144 friend class DomProcessor;
00145
00152 void setPrimaryOf(DomProcessor *primaryOf) { thePrimaryOf = primaryOf; }
00154
00155
00156 xSCoupling *theCoupling;
00157 friend class xSCoupling;
00158
00165 xSCoupling *coupling() { return theCoupling; }
00166 friend class ProcessorForwarder;
00167
00168
00172 void go();
00173
00177 void stop();
00178
00187 void transact(const BufferDatas &i, const uint chunks);
00188
00199 BufferDatas deliverResults(uint *timeTaken = 0);
00200
00207 const bool proxyVSTypes(const SignalTypeRefs &inTypes, SignalTypeRefs &outTypes) { return verifyAndSpecifyTypes(inTypes, outTypes); }
00208
00213 void defineIO(const uint numInputs, const uint numOutputs);
00214
00215 protected:
00229 virtual void processChunk(const BufferDatas &in, BufferDatas &out) const;
00230
00252 virtual void processChunks(const BufferDatas &in, BufferDatas &out, const uint chunks) const;
00253
00260 virtual PropertiesInfo specifyProperties() const;
00261
00287
00288 virtual const bool verifyAndSpecifyTypes(const SignalTypeRefs &inTypes, SignalTypeRefs &outTypes) = 0;
00289
00302 virtual void initFromProperties(const Properties &properties) = 0;
00303
00312 const uint multiplicity() const { return theMulti == In ? theNumInputs : theMulti == Out ? theNumOutputs : Undefined; }
00313
00345 void setupIO(const uint numInputs = 1, const uint numOutputs = 1, const uint samplesIn = 1, const uint samplesStep = 1, const uint samplesOut = 1);
00346
00360 void setupVisual(const uint width = 50, const uint height = 30, const uint redrawPeriod = 0);
00361
00368 virtual void paintProcessor(QPainter &p);
00369
00376 SubProcessor(const QString &type, const MultiplicityType &multi = NotMulti);
00377
00378 public:
00382 virtual ~SubProcessor() { }
00383 };
00384
00385 };
00386
00387 #endif