Descriptor.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 __Descriptor_H__
00023 #define __Descriptor_H__
00024 
00025 #include "DynamicType.hxx"
00026 #include "ProcessingData.hxx"
00027 #include "DataTypes.hxx"
00028 #include "Stats.hxx"
00029 
00030 
00031 namespace CLAM{
00032 
00033 
00039 template <bool abs>
00040 class DescriptorTmpl:public ProcessingData
00041 {
00042 public:
00043         DescriptorTmpl(int n):ProcessingData(n){mpStats=0;}
00044         DescriptorTmpl(const DescriptorTmpl<abs>& prototype, bool shareData=false, bool deep=true)
00045                 : ProcessingData(prototype, shareData, deep)
00046         {
00047                 mpStats=0;
00048         };
00049         virtual ~DescriptorTmpl()
00050         {
00051                 if (mpStats)
00052                 {
00053                         delete mpStats;
00054                         mpStats=0;
00055                 }
00056         }
00057         virtual void Compute()
00058         {
00059                 CLAM_ASSERT(mpStats,"Descriptor::Compute: Error no valid statistics. This may happen if you forget to set your data after having set the prototype");
00060                 ConcreteCompute();
00061         }
00062         virtual void ConcreteCompute()=0;
00063         void SetPrototype(const DescriptorTmpl<abs>& proto)
00064         {
00065                 *this=proto;
00066                 if(mpStats)
00067                 {
00068                         delete mpStats;
00069                         mpStats=0;
00070                 }
00071         }
00072 protected:
00073         void InitStats(DataArray* pData)
00074         {
00075                 if(mpStats) delete mpStats;
00076                 mpStats=new StatsTmpl<abs>(pData);
00077         }
00078 protected:
00079         StatsTmpl<abs>* mpStats;
00080 
00081 };
00082 
00083 typedef DescriptorTmpl<false> Descriptor;
00084 typedef DescriptorTmpl<true> DescriptorAbs;
00085 
00086 };
00087 
00088 
00089 
00090 #endif // Descriptor.hxx
00091 
00092 
00093 
Generated by  doxygen 1.6.3