Panda3D
 All Classes Functions Variables Enumerations
bufferContextChain.cxx
1 // Filename: bufferContextChain.cxx
2 // Created by: drose (16Mar06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "bufferContextChain.h"
16 #include "bufferContext.h"
17 #include "indent.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: BufferContextChain::get_first
21 // Access: Public
22 // Description: Returns the first BufferContext object stored in the
23 // tracker. You can walk through the entire list of
24 // objects stored on the tracker by calling get_next()
25 // on each returned object, until the return value is
26 // NULL.
27 ////////////////////////////////////////////////////////////////////
30  // This method is declared non-inline so we can include
31  // bufferContext.h, which is necessary for proper downcasting of the
32  // _next pointer.
33  if (_next == this) {
34  return NULL;
35  }
36  return (BufferContext *)_next;
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: BufferContextChain::take_from
41 // Access: Public
42 // Description: Moves all of the BufferContexts from the other
43 // tracker onto this one.
44 ////////////////////////////////////////////////////////////////////
47  _total_size += other._total_size;
48  _count += other._count;
49  other._total_size = 0;
50  other._count = 0;
51 
52  LinkedListNode *llnode = other._next;
53  while (llnode != &other) {
54  nassertv(((BufferContext *)llnode)->_owning_chain == &other);
55  ((BufferContext *)llnode)->_owning_chain = this;
56  llnode = ((BufferContext *)llnode)->_next;
57  }
58 
59  take_list_from(&other);
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: BufferContextChain::write
64 // Access: Public
65 // Description:
66 ////////////////////////////////////////////////////////////////////
67 void BufferContextChain::
68 write(ostream &out, int indent_level) const {
69  indent(out, indent_level)
70  << _count << " objects, consuming " << _total_size << " bytes:\n";
71 
72  LinkedListNode *llnode = _next;
73  while (llnode != this) {
74  ((BufferContext *)llnode)->write(out, indent_level + 2);
75  llnode = ((BufferContext *)llnode)->_next;
76  }
77 }
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:41
This just stores the pointers to implement a doubly-linked list of some kind of object.
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
BufferContext * get_first()
Returns the first BufferContext object stored in the tracker.
void take_from(BufferContextChain &other)
Moves all of the BufferContexts from the other tracker onto this one.