0024512: clang++ compiler complains about extra semicolon
[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//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public 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.
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
30#include <MMgt_TShared.hxx>
31#include <Standard_DefineHandle.hxx>
32#include <NCollection_TypeDef.hxx>
33
34class Handle(NCollection_BaseAllocator);
35
36/**
37* Purpose: Basic class for memory allocation wizards.
38* Defines the interface for devising different allocators
39* firstly to be used by collections of NCollection, though it
40* it is not deferred. It allocates/frees the memory through
41* Standard procedures, thus it is unnecessary (and sometimes
42* injurious) to have more than one such allocator. To avoid
43* creation of multiple objects the constructors were maid
44* inaccessible. To create the BaseAllocator use the method
45* CommonBaseAllocator.
46* Note that this object is managed by Handle.
47*/
48class NCollection_BaseAllocator : public MMgt_TShared
49{
50 public:
51 // ---------- PUBLIC METHODS ------------
52 Standard_EXPORT virtual void* Allocate (const size_t size);
53 Standard_EXPORT virtual void Free (void * anAddress);
54
55 //! CommonBaseAllocator
56 //! This method is designed to have the only one BaseAllocator (to avoid
57 //! useless copying of collections). However one can use operator new to
58 //! create more BaseAllocators, but it is injurious.
59 Standard_EXPORT static const Handle(NCollection_BaseAllocator)&
60 CommonBaseAllocator(void);
61
62 //! Callback function to register alloc/free calls
63 Standard_EXPORT static void StandardCallBack
64 (const Standard_Boolean theIsAlloc,
65 const Standard_Address theStorage,
66 const Standard_Size theRoundSize,
67 const Standard_Size theSize);
68
69 //! Prints memory usage statistics cumulated by StandardCallBack
70 Standard_EXPORT static void PrintMemUsageStatistics();
71
72 protected:
73 //! Constructor - prohibited
5640d653 74 NCollection_BaseAllocator(void) {}
7fd59977 75
76 private:
77 //! Copy constructor - prohibited
78 NCollection_BaseAllocator(const NCollection_BaseAllocator&);
79
80 public:
81 // ---------- CasCade RunTime Type Information
82 DEFINE_STANDARD_RTTI(NCollection_BaseAllocator)
83};
84
85DEFINE_STANDARD_HANDLE(NCollection_BaseAllocator,MMgt_TShared)
86
87#endif