forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbufferContextChain.cxx
More file actions
66 lines (59 loc) · 1.79 KB
/
bufferContextChain.cxx
File metadata and controls
66 lines (59 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file bufferContextChain.cxx
* @author drose
* @date 2006-03-16
*/
#include "bufferContextChain.h"
#include "bufferContext.h"
#include "indent.h"
/**
* Returns the first BufferContext object stored in the tracker. You can walk
* through the entire list of objects stored on the tracker by calling
* get_next() on each returned object, until the return value is NULL.
*/
BufferContext *BufferContextChain::
get_first() {
// This method is declared non-inline so we can include bufferContext.h,
// which is necessary for proper downcasting of the _next pointer.
if (_next == this) {
return nullptr;
}
return (BufferContext *)_next;
}
/**
* Moves all of the BufferContexts from the other tracker onto this one.
*/
void BufferContextChain::
take_from(BufferContextChain &other) {
_total_size += other._total_size;
_count += other._count;
other._total_size = 0;
other._count = 0;
LinkedListNode *llnode = other._next;
while (llnode != &other) {
nassertv(((BufferContext *)llnode)->_owning_chain == &other);
((BufferContext *)llnode)->_owning_chain = this;
llnode = ((BufferContext *)llnode)->_next;
}
take_list_from(&other);
}
/**
*
*/
void BufferContextChain::
write(std::ostream &out, int indent_level) const {
indent(out, indent_level)
<< _count << " objects, consuming " << _total_size << " bytes:\n";
LinkedListNode *llnode = _next;
while (llnode != this) {
((BufferContext *)llnode)->write(out, indent_level + 2);
llnode = ((BufferContext *)llnode)->_next;
}
}