Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:17

0001 // Created on: 2014-03-31
0002 // Created by: Kirill Gavrilov
0003 // Copyright (c) 2014 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 #ifndef NCollection_AlignedAllocator_HeaderFile
0017 #define NCollection_AlignedAllocator_HeaderFile
0018 
0019 #include <NCollection_BaseAllocator.hxx>
0020 #include <Standard.hxx>
0021 
0022 //! NCollection allocator with managed memory alignment capabilities.
0023 class NCollection_AlignedAllocator : public NCollection_BaseAllocator
0024 {
0025 public:
0026 
0027   //! Constructor. The alignment should be specified explicitly:
0028   //! 16 bytes for SSE instructions
0029   //! 32 bytes for AVX instructions
0030   Standard_EXPORT NCollection_AlignedAllocator (const size_t theAlignment);
0031 
0032   //! Allocate memory with given size. Returns NULL on failure.
0033   Standard_EXPORT virtual void* Allocate (const size_t theSize) Standard_OVERRIDE;
0034 
0035   //! Allocate memory with given size. Returns NULL on failure.
0036   void* AllocateOptimal(const size_t theSize) Standard_OVERRIDE
0037   {
0038     return Allocate(theSize);
0039   }
0040 
0041   //! Free a previously allocated memory.
0042   Standard_EXPORT virtual void  Free (void* thePtr) Standard_OVERRIDE;
0043 
0044 private:
0045 
0046   NCollection_AlignedAllocator            (const NCollection_AlignedAllocator& );
0047   NCollection_AlignedAllocator& operator= (const NCollection_AlignedAllocator& );
0048 
0049 protected:
0050 
0051   size_t myAlignment; //!< alignment in bytes
0052 
0053 public:
0054 
0055   DEFINE_STANDARD_RTTIEXT(NCollection_AlignedAllocator,NCollection_BaseAllocator)
0056 
0057 };
0058 
0059 // Definition of HANDLE object using Standard_DefineHandle.hxx
0060 DEFINE_STANDARD_HANDLE (NCollection_AlignedAllocator, NCollection_BaseAllocator)
0061 
0062 #endif // NCollection_AlignedAllocator_HeaderFile