Panda3D

vertexDataBook.h

00001 // Filename: vertexDataBook.h
00002 // Created by:  drose (16May07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef VERTEXDATABOOK_H
00016 #define VERTEXDATABOOK_H
00017 
00018 #include "pandabase.h"
00019 #include "pmutex.h"
00020 #include "mutexHolder.h"
00021 #include "vertexDataPage.h"
00022 #include "indirectLess.h"
00023 #include "plist.h"
00024 
00025 class VertexDataBlock;
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : VertexDataBook
00029 // Description : A collection of VertexDataPages, which can be used to
00030 //               allocate new VertexDataBlock objects.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_PANDA_GOBJ VertexDataBook {
00033 PUBLISHED:
00034   VertexDataBook(size_t block_size);
00035   ~VertexDataBook();
00036 
00037   INLINE VertexDataBlock *alloc(size_t size);
00038 
00039   INLINE int get_num_pages() const;
00040 
00041   size_t count_total_page_size() const;
00042   size_t count_total_page_size(VertexDataPage::RamClass ram_class) const;
00043   size_t count_allocated_size() const;
00044   size_t count_allocated_size(VertexDataPage::RamClass ram_class) const;
00045 
00046   void save_to_disk();
00047 
00048 public:
00049   void reorder_page(VertexDataPage *page);
00050 
00051 private:
00052   INLINE VertexDataPage *create_new_page(size_t size);
00053   VertexDataBlock *do_alloc(size_t size);
00054 
00055 private:
00056   size_t _block_size;
00057 
00058   typedef pset<VertexDataPage *, IndirectLess<VertexDataPage> > Pages;
00059   Pages _pages;
00060 
00061   Mutex _lock;
00062   friend class VertexDataPage;
00063 };
00064 
00065 #include "vertexDataBook.I"
00066 
00067 #endif
 All Classes Functions Variables Enumerations