ControlTrace.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  * Copyright (c) 2007 Superlucidity Services, LLC and Zachary T Welch
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020  *
00021  */
00022 
00023 #ifndef CONTROL_TRACE_HXX
00024 #define CONTROL_TRACE_HXX
00025 
00026 #include "Processing.hxx"
00027 #include "ProcessingConfig.hxx"
00028 #include "InControlArray.hxx"
00029 #include "OutControlArray.hxx"
00030 #include "Filename.hxx"
00031 #include <vector>
00032 
00033 namespace CLAM
00034 {
00035 
00036 class ControlTraceEvent : public Component {
00037 public:
00038         typedef std::vector<TControlData> ValueArray;
00039 
00040         ControlTraceEvent();
00041         ControlTraceEvent(const InControlArray &inputs);
00042         ControlTraceEvent(const ControlTraceEvent &event);
00043         const ControlTraceEvent& operator=( const ControlTraceEvent& );
00044         virtual ~ControlTraceEvent() { }
00045 
00046         const char *GetClassName() const { return "ControlTraceEvent"; }
00047 
00048         void LoadFrom( Storage& storage);
00049         void StoreOn( Storage& storage ) const;
00050 
00051         void WasRepeated() { mRepeats++; }
00052         unsigned int Repeats() const { return mRepeats; }
00053 
00054         size_t Size() const { return mValues.size(); }
00055 
00056         void UpdateControls(OutControlArray &array) const;
00057 
00058         bool ValuesEqual(const ControlTraceEvent &rhs) const;
00059 
00060 private:
00061         unsigned int mRepeats;
00062         ValueArray mValues;
00063 };
00064 
00065 class ControlTraceData : public Component {
00066         static const unsigned int DumpVersion;
00067 public:
00068         typedef std::list<ControlTraceEvent> EventList;
00069         virtual ~ControlTraceData() { }
00070 
00071         ControlTraceData();
00072         ControlTraceData(const ControlTraceData &obj);
00073 
00074         const char *GetClassName() const { return "ControlTraceData"; }
00075 
00076         unsigned int GetVersion() const { return mVersion; }
00077 
00078         void LoadFrom( Storage& storage);
00079         void StoreOn( Storage& storage ) const;
00080 
00081         size_t GetNumberOfControls() const { return mEvents.front().Size(); }
00082 
00083         void Append(const ControlTraceEvent &data);
00084 
00085         EventList::iterator Begin() { return mEvents.begin(); }
00086         EventList::iterator End() { return mEvents.end(); }
00087 
00088         void Clear() { mEvents.clear(); }
00089 
00090 private:
00091         unsigned int mVersion;
00092         EventList mEvents;
00093 };
00094 
00095 
00096 class ControlTraceInFilename : public InFilename
00097 {
00098 public:
00099         ControlTraceInFilename(const std::string & s="") : InFilename(s) {}
00100         ControlTraceInFilename(const char * s) : InFilename(s) {}
00101         const char* TypeFamily() const;
00102         const Filter * Filters() const;
00103 };
00104 CLAM_TYPEINFOGROUP(BasicCTypeInfo, ControlTraceInFilename);
00105 
00106 class ControlTraceReaderConfig  : public ProcessingConfig {
00107         DYNAMIC_TYPE_USING_INTERFACE
00108         ( ControlTraceReaderConfig, 1, ProcessingConfig );
00109 
00110         DYN_ATTRIBUTE( 0, public, ControlTraceInFilename, TraceFile );
00111 
00112 protected:
00113         void DefaultInit();
00114 };
00115 
00116 class ControlTraceReader : public Processing
00117 {
00118 public:
00119         ControlTraceReader();
00120         ControlTraceReader( const ProcessingConfig& cfg );
00121         virtual ~ControlTraceReader();
00122 
00123         const char* GetClassName() const { return "ControlTraceReader"; }
00124         const ProcessingConfig& GetConfig() const { return mConfig; }
00125 
00126         bool Do();
00127 
00128 protected: // methods
00129         bool ConcreteConfigure( const ProcessingConfig& cfgObject );
00130         bool ConcreteStart();
00131         void RemoveOldControls();
00132         
00133 protected: // attributes
00134         ControlTraceReaderConfig mConfig;
00135         ControlTraceData mTrace;
00136         ControlTraceData::EventList::iterator mIterator;
00137         unsigned int mRepeatCounter;
00138         OutControlArray mOutputs;
00139 };
00140 
00141 
00142 class ControlTraceOutFilename : public OutFilename
00143 {
00144 public:
00145         ControlTraceOutFilename(const std::string & s="") : OutFilename(s) {}
00146         ControlTraceOutFilename(const char * s) : OutFilename(s) {}
00147         const char* TypeFamily() const;
00148         const Filter * Filters() const;
00149 };
00150 CLAM_TYPEINFOGROUP(BasicCTypeInfo, ControlTraceOutFilename);
00151 
00152 class ControlTraceWriterConfig  : public ProcessingConfig {
00153         DYNAMIC_TYPE_USING_INTERFACE
00154         ( ControlTraceWriterConfig, 2, ProcessingConfig );
00155 
00156         DYN_ATTRIBUTE( 0, public, ControlTraceOutFilename, TraceFile );
00157         DYN_ATTRIBUTE( 1, public, TData, NumberOfInputs );
00158 
00159 protected:
00160         void DefaultInit();
00161 };
00162 
00163 class ControlTraceWriter : public Processing
00164 {
00165 public:
00166         ControlTraceWriter();
00167         ControlTraceWriter( const ProcessingConfig& cfg );
00168         virtual ~ControlTraceWriter();
00169 
00170         const char* GetClassName() const { return "ControlTraceWriter"; }
00171         const ProcessingConfig& GetConfig() const { return mConfig; }
00172 
00173         bool Do();
00174 
00175 protected: // methods
00176         bool ConcreteConfigure( const ProcessingConfig& cfgObject );
00177         bool ConcreteStop();
00178         void RemoveOldControls();
00179         
00180 protected: // attributes
00181         ControlTraceWriterConfig mConfig;
00182         ControlTraceData mTrace;
00183         InControlArray mInputs;
00184 };
00185 
00186 } // CLAM namespace
00187 
00188 #endif
Generated by  doxygen 1.6.3