Panda3D
Loading...
Searching...
No Matches
vertexDataBook.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file vertexDataBook.h
10 * @author drose
11 * @date 2007-05-16
12 */
13
14#ifndef VERTEXDATABOOK_H
15#define VERTEXDATABOOK_H
16
17#include "pandabase.h"
18#include "pmutex.h"
19#include "mutexHolder.h"
20#include "vertexDataPage.h"
21#include "indirectLess.h"
22#include "plist.h"
23
24class VertexDataBlock;
25
26/**
27 * A collection of VertexDataPages, which can be used to allocate new
28 * VertexDataBlock objects.
29 */
30class EXPCL_PANDA_GOBJ VertexDataBook {
31PUBLISHED:
32 explicit VertexDataBook(size_t block_size);
33 ~VertexDataBook();
34
35 INLINE VertexDataBlock *alloc(size_t size);
36
37 INLINE size_t get_num_pages() const;
38
39 size_t count_total_page_size() const;
40 size_t count_total_page_size(VertexDataPage::RamClass ram_class) const;
41 size_t count_allocated_size() const;
42 size_t count_allocated_size(VertexDataPage::RamClass ram_class) const;
43
44 void save_to_disk();
45
46public:
47 void reorder_page(VertexDataPage *page);
48
49private:
50 INLINE VertexDataPage *create_new_page(size_t size);
51 VertexDataBlock *do_alloc(size_t size);
52
53private:
54 size_t _block_size;
55
56 typedef pset<VertexDataPage *, IndirectLess<VertexDataPage> > Pages;
57 Pages _pages;
58
59 Mutex _lock;
60 friend class VertexDataPage;
61};
62
63#include "vertexDataBook.I"
64
65#endif
A standard mutex, or mutual exclusion lock.
Definition pmutex.h:40
A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object.
size_t count_allocated_size() const
Returns the total size of all bytes allocated within pages owned by this book.
VertexDataBlock * alloc(size_t size)
Allocates and returns a new VertexDataBuffer of the requested size.
size_t get_num_pages() const
Returns the number of pages created for the book.
size_t count_total_page_size() const
Returns the total size of all bytes owned by all pages owned by this book.
void save_to_disk()
Writes all pages to disk immediately, just in case they get evicted later.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.