0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / NCollection / NCollection_AlignedAllocator.hxx
1 // Created on: 2014-03-31
2 // Created by: Kirill Gavrilov
3 // Copyright (c) 2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef NCollection_AlignedAllocator_HeaderFile
17 #define NCollection_AlignedAllocator_HeaderFile
18
19 #include <NCollection_BaseAllocator.hxx>
20 #include <Standard.hxx>
21
22 //! NCollection allocator with managed memory alignment capabilities.
23 class NCollection_AlignedAllocator : public NCollection_BaseAllocator
24 {
25 public:
26
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);
31
32   //! Allocate memory with given size. Returns NULL on failure.
33   Standard_EXPORT virtual void* Allocate (const size_t theSize) Standard_OVERRIDE;
34
35   //! Free a previously allocated memory.
36   Standard_EXPORT virtual void  Free (void* thePtr) Standard_OVERRIDE;
37
38 private:
39
40   NCollection_AlignedAllocator            (const NCollection_AlignedAllocator& );
41   NCollection_AlignedAllocator& operator= (const NCollection_AlignedAllocator& );
42
43 protected:
44
45   size_t myAlignment; //!< alignment in bytes
46
47 public:
48
49   DEFINE_STANDARD_RTTIEXT(NCollection_AlignedAllocator,NCollection_BaseAllocator)
50
51 };
52
53 // Definition of HANDLE object using Standard_DefineHandle.hxx
54 DEFINE_STANDARD_HANDLE (NCollection_AlignedAllocator, NCollection_BaseAllocator)
55
56 #endif // NCollection_AlignedAllocator_HeaderFile