0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / NCollection / NCollection_BaseAllocator.hxx
CommitLineData
b311480e 1// Created on: 2002-04-12
2// Created by: Alexander KARTOMIN (akm)
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
7fd59977 4//
b311480e 5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20// Purpose: Basic class for memory allocation wizards.
21// Defines the interface for devising different allocators
22// firstly to be used by collections of NCollection, though it
23// it is not deferred. It allocates/frees the memory through
24// Standard procedures, thus it is unnecessary (and sometimes
25// injurious) to have more than one such allocator. To avoid
26// creation of multiple objects the constructors were maid
27// inaccessible. To create the BaseAllocator use the method
28// CommonBaseAllocator.
29// Note that this object is managed by Handle.
7fd59977 30
31#ifndef NCollection_BaseAllocator_HeaderFile
32#define NCollection_BaseAllocator_HeaderFile
33
34#include <MMgt_TShared.hxx>
35#include <Standard_DefineHandle.hxx>
36#include <NCollection_TypeDef.hxx>
37
38class Handle(NCollection_BaseAllocator);
39
40/**
41* Purpose: Basic class for memory allocation wizards.
42* Defines the interface for devising different allocators
43* firstly to be used by collections of NCollection, though it
44* it is not deferred. It allocates/frees the memory through
45* Standard procedures, thus it is unnecessary (and sometimes
46* injurious) to have more than one such allocator. To avoid
47* creation of multiple objects the constructors were maid
48* inaccessible. To create the BaseAllocator use the method
49* CommonBaseAllocator.
50* Note that this object is managed by Handle.
51*/
52class NCollection_BaseAllocator : public MMgt_TShared
53{
54 public:
55 // ---------- PUBLIC METHODS ------------
56 Standard_EXPORT virtual void* Allocate (const size_t size);
57 Standard_EXPORT virtual void Free (void * anAddress);
58
59 //! CommonBaseAllocator
60 //! This method is designed to have the only one BaseAllocator (to avoid
61 //! useless copying of collections). However one can use operator new to
62 //! create more BaseAllocators, but it is injurious.
63 Standard_EXPORT static const Handle(NCollection_BaseAllocator)&
64 CommonBaseAllocator(void);
65
66 //! Callback function to register alloc/free calls
67 Standard_EXPORT static void StandardCallBack
68 (const Standard_Boolean theIsAlloc,
69 const Standard_Address theStorage,
70 const Standard_Size theRoundSize,
71 const Standard_Size theSize);
72
73 //! Prints memory usage statistics cumulated by StandardCallBack
74 Standard_EXPORT static void PrintMemUsageStatistics();
75
76 protected:
77 //! Constructor - prohibited
78 NCollection_BaseAllocator(void) {};
79
80 private:
81 //! Copy constructor - prohibited
82 NCollection_BaseAllocator(const NCollection_BaseAllocator&);
83
84 public:
85 // ---------- CasCade RunTime Type Information
86 DEFINE_STANDARD_RTTI(NCollection_BaseAllocator)
87};
88
89DEFINE_STANDARD_HANDLE(NCollection_BaseAllocator,MMgt_TShared)
90
91#endif