Fundamental.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 _Fundamental_
00023 #define _Fundamental_
00024 #include <typeinfo>
00025 #include "DynamicType.hxx"
00026 #include "Array.hxx"
00027 #include "DataTypes.hxx"
00028 #include "OSDefines.hxx"
00029 #include "Err.hxx"
00030 #include "ProcessingData.hxx"
00031 
00032 namespace CLAM
00033 {
00034 
00036         // Class Fundamental:
00037         //
00038 
00044         class Fundamental : public ProcessingData
00045         {
00046         public:
00047                 DYNAMIC_TYPE_USING_INTERFACE (Fundamental, 2, ProcessingData);
00049                 DYN_ATTRIBUTE (0, public, DataArray, CandidatesFreq);
00051                 DYN_ATTRIBUTE (1, public, DataArray, CandidatesErr);
00052 
00053         protected:
00054                 void DefaultInit();
00055 
00056         public:
00057                 void SetnMaxCandidates(TSize nMaxCandidates)
00058                 {
00059                         if (HasCandidatesFreq())
00060                                 GetCandidatesFreq().Resize(nMaxCandidates);
00061 
00062                         if (HasCandidatesErr())
00063                                 GetCandidatesErr().Resize(nMaxCandidates);
00064                 }
00065 
00066                 TSize GetnMaxCandidates() const
00067                 {
00068                         if (HasCandidatesFreq())
00069                                 return GetCandidatesFreq().AllocatedSize();
00070 
00071                         if (HasCandidatesErr())
00072                                 return GetCandidatesErr().AllocatedSize();
00073 
00074                         return 0;
00075                 }
00076 
00077                 void SetnCandidates(int size)
00078                 {
00079                         if (HasCandidatesFreq())
00080                                 GetCandidatesFreq().SetSize(size);
00081 
00082                         if (HasCandidatesErr())
00083                                 GetCandidatesErr().SetSize(size);
00084                 }
00085 
00086                 int GetnCandidates() const
00087                 {
00088                         if (HasCandidatesFreq())
00089                                 return GetCandidatesFreq().Size();
00090 
00091                         if (HasCandidatesErr())
00092                                 return GetCandidatesErr().Size();
00093 
00094                         return 0;
00095                 }
00096                 
00102                 TData GetFreq(TIndex pos=0) const;
00103 
00108                 TData GetErr(TIndex pos=0) const;
00109 
00110 
00115                 void SetFreq(TIndex pos,TData newFreq);
00116 
00121                 void SetErr(TIndex pos,TData newErr);
00122                 
00123                 // Other functionality
00124                 
00129                 void AddElem (TData freq=0.f, TData err=0.f);
00130 
00136                 void InsertElem (TIndex pos, TData freq=0.f, TData err=0.f);
00137 
00141                 void DeleteElem (TIndex pos);
00142 
00143   
00144                 // Ordering functions
00145 
00150                 void SortByFrequency();
00151 
00156                 void SortByError();
00157 
00159                 void Init()
00160                 {
00161                         GetCandidatesFreq().SetSize(0);
00162                         GetCandidatesErr().SetSize(0);
00163                         SetnCandidates(0);
00164                 }
00165         };
00166 
00167 } // namespace CLAM
00168 
00169 #endif
00170 
Generated by  doxygen 1.6.3