BInstanceAllocator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 //
00003 //  File:           support/BInstanceAllocator.h
00004 //
00005 //  Description:    Base class for a class hierarchy, which provides more
00006 //                  optimimal heap allocation of instance data.
00007 //
00008 //  Copyright 2001, Be Incorporated, All Rights Reserved.
00009 //
00010 ***************************************************************************/
00011 
00012 #ifndef _SUPPORT_INSTANCE_ALLOCATOR_H
00013 #define _SUPPORT_INSTANCE_ALLOCATOR_H
00014 
00015 #include <support/SupportDefs.h>
00016 
00017 namespace B {
00018 namespace Support {
00019 
00020 class BInstanceAllocator
00021 {
00022 public:
00023 virtual                 ~BInstanceAllocator();
00024 
00025 protected:
00026                         BInstanceAllocator(size_t total_instance_size=0);
00027 
00028         // Use this function when calling up to your superclass's
00029         // constructor, to add your instance data memory needs into
00030         // the hierarchy.  The final BInstanceAllocator constructor
00031         // will be called with the total instance data required.
00032 static  size_t          AddInstanceData(size_t current, size_t additional);
00033         
00034         // Call this function in your constructor implementation to
00035         // retrieve the instance data for your class.  You will need
00036         // to manually call in-place constructors and destructors for
00037         // any objects in your instance data.
00038         void*           GetInstanceData(size_t amount);
00039 private:
00040         struct instance_data {
00041             size_t amount;
00042             size_t pos;
00043         };
00044         
00045         instance_data*  fInstanceData;
00046 };
00047 
00048 } } // namespace B::Support
00049 
00050 #endif

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.