00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __DISPATCHER__
00023 #define __DISPATCHER__
00024
00025 #include "Array.hxx"
00026 #include "Instrument.hxx"
00027
00028 #include <algorithm>
00029
00030 namespace CLAM
00031 {
00032
00033 class DispatcherConfig: public ProcessingConfig
00034 {
00035 public:
00036 DYNAMIC_TYPE_USING_INTERFACE (DispatcherConfig, 2, ProcessingConfig);
00037 DYN_ATTRIBUTE (0, public, Array< Instrument* >, Instruments);
00038 DYN_ATTRIBUTE (1, public, int, NInValues);
00039
00040 protected:
00041 void DefaultInit(void)
00042 {
00043 AddInstruments();
00044 AddNInValues();
00045 UpdateData();
00046 }
00047 };
00048
00049 class Dispatcher:public Processing
00050 {
00051 private:
00052 struct InstrStatus
00053 {
00054 public:
00055 int mNote;
00056 int mVelocity;
00057 int mId;
00058 };
00059
00060 DispatcherConfig mConfig;
00061 Array< Instrument* > mInstruments;
00062 Array< OutControl* > mValuesOut;
00063 InControlTmpl< Dispatcher > mStateIn;
00064 InControlTmpl< Dispatcher > mNoteIn;
00065 InControlTmpl< Dispatcher > mVelocityIn;
00066 int mNInValues;
00067 int mMInstruments;
00068 TControlData mVelocity;
00069 TControlData mNote;
00070 std::list< InstrStatus > mInstrStatusList;
00071
00072 protected:
00073
00074 int UpdateState( TControlData availableInstr );
00075
00076 int UpdateVel( TControlData value )
00077 {
00078
00079 mVelocity = value;
00080
00081 return 0;
00082 }
00083
00084 int UpdateNote( TControlData value )
00085 {
00086
00087 mNote = value;
00088 Dispatch();
00089
00090 return 0;
00091 }
00092
00093 void Dispatch(void);
00094
00095 public:
00096
00097 Dispatcher():
00098 mStateIn("",this,&Dispatcher::UpdateState),
00099 mNoteIn( "Note", this, &Dispatcher::UpdateNote ),
00100 mVelocityIn( "Velocity", this, &Dispatcher::UpdateVel ),
00101 mVelocity( 0 ),
00102 mNote( 0 )
00103 {
00104 DispatcherConfig cfg;
00105
00106 Configure( cfg );
00107 }
00108
00109 Dispatcher( const DispatcherConfig& c):
00110 mStateIn("",this,&Dispatcher::UpdateState),
00111 mNoteIn( "Note", this, &Dispatcher::UpdateNote ),
00112 mVelocityIn( "Velocity", this, &Dispatcher::UpdateVel ),
00113 mVelocity( 0 ),
00114 mNote( 0 )
00115 {
00116 Configure( c );
00117 }
00118
00119 ~Dispatcher(){}
00120
00121 const char * GetClassName() const {return "Dispatcher";}
00122
00123 const ProcessingConfig &GetConfig() const { return mConfig; }
00124
00125 bool ConcreteConfigure( const ProcessingConfig& c );
00126
00127 bool Do(void) { return true; }
00128
00129 };
00130 }
00131
00132 #endif
00133