Control2Data.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef _Control2Data_
00023 #define _Control2Data_
00024 
00025 #include "Processing.hxx"
00026 #include "ProcessingData.hxx"
00027 #include "InControlArray.hxx"
00028 
00029 #include <vector>
00030 #include <queue>
00031 
00032 #include "Mutex.hxx"
00033 
00034 namespace CLAM {
00035 
00037 
00042 class Control2DataConfig : public ProcessingConfig
00043 {
00044 public:
00045         DYNAMIC_TYPE_USING_INTERFACE (Control2DataConfig, 3, ProcessingConfig);
00046         DYN_ATTRIBUTE          (0, public, unsigned, NumControls);
00047         DYN_CONTAINER_ATTRIBUTE (1, public, std::vector<TControlData>, MinValues, foo);
00048         DYN_CONTAINER_ATTRIBUTE (2, public, std::vector<TControlData>, MaxValues, foo);
00049 protected:
00051         void DefaultInit(void);
00052         
00053 };
00055 
00065 class Control2Data : public Processing
00066 {
00067 public:
00068         typedef Control2DataConfig Config;
00069         Control2Data(const Config& c=Config());
00070         virtual ~Control2Data (){};
00075         bool Do();
00077         const ProcessingConfig&  GetConfig() const;     
00078 protected:
00079 
00080         //typedefs
00081 
00083         typedef std::queue<TControlData> TQueue;
00085         typedef std::list<int> IdxList;
00086 
00087         //protected methods
00088         
00093         virtual bool GenerateOutputData(int id, TControlData val)=0;
00094 
00098         void BufferQueueInit( int ncontrols );
00103         void EnqueueControl(unsigned id, TControlData data);
00105         TControlData PopControl(unsigned id);
00107         bool Empty(unsigned id);
00109         IdxList GetQueues();
00110 
00116         void ControlCallbackId(int id, TControlData val );
00117 
00119         virtual bool ConcreteConfigure(const ProcessingConfig&);
00121         const char *GetClassName() const {return "Control2Data";}
00122 
00123 protected:
00124 //protected member attributes
00125 
00129         InControlArray mInArray;
00130         
00134         FloatInControl mStop;
00135         
00137         Config mConfig;
00138         
00140         std::vector<TQueue> mDataQueues;
00141         
00143         Mutex mDataMutex;
00145         Mutex mControl2DataDoMutex;
00146 };
00148 }; // namespace CLAM
00149 
00150 #endif // _Control2Data_
00151 
Generated by  doxygen 1.6.3