0029151: GCC 7.1 warnings "this statement may fall through" [-Wimplicit-fallthrough=]
[occt.git] / src / NCollection / NCollection_BaseAllocator.hxx
CommitLineData
b311480e 1// Created on: 2002-04-12
2// Created by: Alexander KARTOMIN (akm)
973c2be1 3// Copyright (c) 2002-2014 OPEN CASCADE SAS
7fd59977 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
7fd59977 16// Purpose: Basic class for memory allocation wizards.
17// Defines the interface for devising different allocators
18// firstly to be used by collections of NCollection, though it
19// it is not deferred. It allocates/frees the memory through
20// Standard procedures, thus it is unnecessary (and sometimes
21// injurious) to have more than one such allocator. To avoid
22// creation of multiple objects the constructors were maid
23// inaccessible. To create the BaseAllocator use the method
24// CommonBaseAllocator.
25// Note that this object is managed by Handle.
7fd59977 26
27#ifndef NCollection_BaseAllocator_HeaderFile
28#define NCollection_BaseAllocator_HeaderFile
29
25e59720 30#include <Standard_Transient.hxx>
ec357c5c 31#include <Standard_Type.hxx>
7fd59977 32#include <NCollection_TypeDef.hxx>
33
7fd59977 34
35/**
36* Purpose: Basic class for memory allocation wizards.
37* Defines the interface for devising different allocators
38* firstly to be used by collections of NCollection, though it
39* it is not deferred. It allocates/frees the memory through
40* Standard procedures, thus it is unnecessary (and sometimes
41* injurious) to have more than one such allocator. To avoid
42* creation of multiple objects the constructors were maid
43* inaccessible. To create the BaseAllocator use the method
44* CommonBaseAllocator.
45* Note that this object is managed by Handle.
46*/
25e59720 47class NCollection_BaseAllocator : public Standard_Transient
7fd59977 48{
49 public:
50 // ---------- PUBLIC METHODS ------------
51 Standard_EXPORT virtual void* Allocate (const size_t size);
52 Standard_EXPORT virtual void Free (void * anAddress);
53
54 //! CommonBaseAllocator
55 //! This method is designed to have the only one BaseAllocator (to avoid
56 //! useless copying of collections). However one can use operator new to
57 //! create more BaseAllocators, but it is injurious.
58 Standard_EXPORT static const Handle(NCollection_BaseAllocator)&
59 CommonBaseAllocator(void);
60
61 //! Callback function to register alloc/free calls
62 Standard_EXPORT static void StandardCallBack
63 (const Standard_Boolean theIsAlloc,
64 const Standard_Address theStorage,
65 const Standard_Size theRoundSize,
66 const Standard_Size theSize);
67
68 //! Prints memory usage statistics cumulated by StandardCallBack
69 Standard_EXPORT static void PrintMemUsageStatistics();
70
71 protected:
72 //! Constructor - prohibited
5640d653 73 NCollection_BaseAllocator(void) {}
7fd59977 74
75 private:
76 //! Copy constructor - prohibited
77 NCollection_BaseAllocator(const NCollection_BaseAllocator&);
78
79 public:
80 // ---------- CasCade RunTime Type Information
25e59720 81 DEFINE_STANDARD_RTTIEXT(NCollection_BaseAllocator,Standard_Transient)
7fd59977 82};
83
25e59720 84DEFINE_STANDARD_HANDLE(NCollection_BaseAllocator,Standard_Transient)
7fd59977 85
86#endif