Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:18:02

0001 // Created on: 2002-04-12
0002 // Created by: Alexander KARTOMIN (akm)
0003 // Copyright (c) 2002-2023 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 // Purpose:     Basic class for memory allocation wizards.
0017 //              Defines  the  interface  for devising  different  allocators
0018 //              firstly to be used  by collections of NCollection, though it
0019 //              it is not  deferred. It allocates/frees  the memory  through
0020 //              Standard procedures, thus it is  unnecessary (and  sometimes
0021 //              injurious) to have  more than one such  allocator.  To avoid
0022 //              creation  of multiple  objects the  constructors  were  maid
0023 //              inaccessible.  To  create the  BaseAllocator use  the method
0024 //              CommonBaseAllocator.
0025 //              Note that this object is managed by Handle.
0026 
0027 #ifndef NCollection_BaseAllocator_HeaderFile
0028 #define NCollection_BaseAllocator_HeaderFile
0029 
0030 #include <Standard_DefineHandle.hxx>
0031 #include <Standard_Transient.hxx>
0032 
0033 /**
0034  * Purpose:     Basic class for memory allocation wizards.
0035  *              Defines  the  interface  for devising  different  allocators
0036  *              firstly to be used  by collections of NCollection, though it
0037  *              it is not  deferred. It allocates/frees  the memory  through
0038  *              Standard procedures, thus it is  unnecessary (and  sometimes
0039  *              injurious) to have  more than one such  allocator.  To avoid
0040  *              creation  of multiple  objects the  constructors  were  maid
0041  *              inaccessible.  To  create the  BaseAllocator use  the method
0042  *              CommonBaseAllocator.
0043  *              Note that this object is managed by Handle.
0044  */
0045 class NCollection_BaseAllocator : public Standard_Transient
0046 {
0047 public:
0048   // ---------- PUBLIC METHODS ------------
0049   Standard_EXPORT virtual void* Allocate(const size_t theSize);
0050   Standard_EXPORT virtual void* AllocateOptimal(const size_t theSize);
0051   Standard_EXPORT virtual void  Free(void* theAddress);
0052 
0053   //! CommonBaseAllocator
0054   //! This method is designed to have the only one BaseAllocator (to avoid
0055   //! useless copying of collections). However one can use operator new to
0056   //! create more BaseAllocators, but it is injurious.
0057   Standard_EXPORT static const occ::handle<NCollection_BaseAllocator>& CommonBaseAllocator();
0058 
0059 protected:
0060   //! Constructor - prohibited
0061   NCollection_BaseAllocator() noexcept {}
0062 
0063 private:
0064   //! Copy constructor - prohibited
0065   NCollection_BaseAllocator(const NCollection_BaseAllocator&) = delete;
0066 
0067 public:
0068   // ---------- CasCade RunTime Type Information
0069   DEFINE_STANDARD_RTTIEXT(NCollection_BaseAllocator, Standard_Transient)
0070 };
0071 #endif