CLAM-Development  1.4.0
Descriptor.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef __Descriptor_H__
23 #define __Descriptor_H__
24 
25 #include "DynamicType.hxx"
26 #include "ProcessingData.hxx"
27 #include "DataTypes.hxx"
28 #include "Stats.hxx"
29 
30 
31 namespace CLAM{
32 
33 
39 template <bool abs>
41 {
42 public:
44  DescriptorTmpl(const DescriptorTmpl<abs>& prototype, bool shareData=false, bool deep=true)
45  : ProcessingData(prototype, shareData, deep)
46  {
47  mpStats=0;
48  };
49  virtual ~DescriptorTmpl()
50  {
51  if (mpStats)
52  {
53  delete mpStats;
54  mpStats=0;
55  }
56  }
57  virtual void Compute()
58  {
59  CLAM_ASSERT(mpStats,"Descriptor::Compute: Error no valid statistics. This may happen if you forget to set your data after having set the prototype");
61  }
62  virtual void ConcreteCompute()=0;
63  void SetPrototype(const DescriptorTmpl<abs>& proto)
64  {
65  *this=proto;
66  if(mpStats)
67  {
68  delete mpStats;
69  mpStats=0;
70  }
71  }
72 protected:
73  void InitStats(DataArray* pData)
74  {
75  if(mpStats) delete mpStats;
76  mpStats=new StatsTmpl<abs>(pData);
77  }
78 protected:
80 
81 };
82 
85 
86 };
87 
88 
89 
90 #endif // Descriptor.hxx
91 
92 
93