1 // Created on: 2014-03-31
2 // Created by: Kirill Gavrilov
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef NCollection_AlignedAllocator_HeaderFile
17 #define NCollection_AlignedAllocator_HeaderFile
19 #include <NCollection_BaseAllocator.hxx>
20 #include <Standard.hxx>
22 //! NCollection allocator with managed memory alignment capabilities.
23 class NCollection_AlignedAllocator : public NCollection_BaseAllocator
27 //! Constructor. The alignment should be specified explicitly:
28 //! 16 bytes for SSE instructions
29 //! 32 bytes for AVX instructions
30 Standard_EXPORT NCollection_AlignedAllocator (const size_t theAlignment);
32 //! Allocate memory with given size. Returns NULL on failure.
33 Standard_EXPORT virtual void* Allocate (const size_t theSize) Standard_OVERRIDE;
35 //! Free a previously allocated memory.
36 Standard_EXPORT virtual void Free (void* thePtr) Standard_OVERRIDE;
40 NCollection_AlignedAllocator (const NCollection_AlignedAllocator& );
41 NCollection_AlignedAllocator& operator= (const NCollection_AlignedAllocator& );
45 size_t myAlignment; //!< alignment in bytes
49 DEFINE_STANDARD_RTTIEXT(NCollection_AlignedAllocator,NCollection_BaseAllocator)
53 // Definition of HANDLE object using Standard_DefineHandle.hxx
54 DEFINE_STANDARD_HANDLE (NCollection_AlignedAllocator, NCollection_BaseAllocator)
56 #endif // NCollection_AlignedAllocator_HeaderFile