1 /* 2 * Open BEAGLE 3 * Copyright (C) 2001-2007 by Christian Gagne and Marc Parizeau 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * Contact: 20 * Laboratoire de Vision et Systemes Numeriques 21 * Departement de genie electrique et de genie informatique 22 * Universite Laval, Quebec, Canada, G1K 7P4 23 * http://vision.gel.ulaval.ca 24 * 25 */ 26 27 /*! 28 * \file beagle/AbstractAllocT.hpp 29 * \brief Definition of abstract templated class AbstractAllocT. 30 * \author Christian Gagne 31 * \author Marc Parizeau 32 * $Revision: 1.4.2.1 $ 33 * $Date: 2007/05/09 01:51:08 $ 34 */ 35 36 #ifndef Beagle_AbstractAllocT_hpp 37 #define Beagle_AbstractAllocT_hpp 38 39 #include "beagle/config.hpp" 40 #include "beagle/macros.hpp" 41 #include "beagle/Allocator.hpp" 42 #include "beagle/PointerT.hpp" 43 #include "beagle/AllocatorT.hpp" 44 45 46 namespace Beagle { 47 48 /*! 49 * \class AbstractAllocT beagle/AbstractAllocT.hpp "beagle/AbstractAllocT.hpp" 50 * \brief Abstract templated allocator class. 51 * \param T Type (abtsract) of object allocated. 52 * \param BaseType Base type from which the actual allocator type is derived. 53 * \ingroup OOF 54 * \ingroup Allocs 55 * \par Note: 56 * This class is usually used to define the Alloc type of an abstract Beagle class. 57 */ 58 template <class T, class BaseType> 59 class AbstractAllocT : public BaseType { 60 61 public: 62 63 //! AbstractAllocT allocator type. 64 typedef AbstractAllocT<AbstractAllocT<T,BaseType>,typename BaseType::Alloc> 65 Alloc; 66 //! AbstractAllocT handle type. 67 typedef PointerT<AbstractAllocT<T,BaseType>,typename BaseType::Handle> 68 Handle; 69 //! AbstractAllocT bag type. 70 typedef ContainerT<AbstractAllocT<T,BaseType>,typename BaseType::Bag> 71 Bag; 72 AbstractAllocT()73 AbstractAllocT() { } ~AbstractAllocT()74 virtual ~AbstractAllocT() { } 75 76 /*! 77 * \brief Allocate a new object on the heap. 78 * \return Pointer to the allocated object. 79 */ 80 virtual Object* allocate() const =0; 81 82 /*! 83 * \brief Allocate a new object on the heap that is a clone an existing object. 84 * \param inOrigObj Constant reference to the original object to clone. 85 * \return Pointer to the allocated object. 86 */ 87 virtual Object* clone(const Object& inOrigObj) const =0; 88 89 /*! 90 * \brief Copy an object into another. 91 * \param inOrigObj Constant reference to the original object to copy. 92 * \param outCopyObj Reference to the object that is a copy of the original. 93 */ 94 virtual void copy(Object& outCopyObj, const Object& inOrigObj) const =0; 95 96 }; 97 98 } 99 100 #endif // Beagle_AbstractAllocT_hpp 101 102