CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 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 _AttributePool_hxx_ 00023 #define _AttributePool_hxx_ 00024 00025 #include "DescriptionAttributes.hxx" 00026 00027 namespace CLAM 00028 { 00033 class AttributePool : public Component 00034 { 00035 public: 00036 AttributePool() 00037 { 00038 _data=0; 00039 _size=0; 00040 _attribute=0; 00041 } 00042 void SetDefinition(const AbstractAttribute & attribute) 00043 { 00044 _attribute = & attribute; 00045 } 00046 const char * GetClassName() const { return "AttributePool"; } 00047 void StoreOn(Storage & storage) const 00048 { 00049 _attribute->XmlDumpData(storage, _data, _size); 00050 } 00051 void LoadFrom(Storage & storage) 00052 { 00053 _attribute->XmlRestoreData(storage, _data, _size); 00054 } 00055 void * GetData() { return _data; } 00056 const void * GetData() const { return _data; } 00057 void Allocate(unsigned size) 00058 { 00059 _data = _attribute->Allocate(size); 00060 _size=size; 00061 } 00062 void Deallocate() 00063 { 00064 if (!_data) return; 00065 _attribute->Deallocate(_data); 00066 _data = 0; 00067 } 00068 void Insert(unsigned pos) 00069 { 00070 _size++; 00071 if (_data) 00072 _attribute->Insert(_data,pos); 00073 } 00074 void Remove(unsigned pos) 00075 { 00076 _size--; 00077 if (_data) 00078 _attribute->Remove(_data,pos); 00079 } 00080 private: 00081 void * _data; 00082 const AbstractAttribute * _attribute; 00083 unsigned _size; 00084 }; 00085 } 00086 00087 00088 #endif// _AttributePool_hxx_ 00089