Panda3D
cycleDataStageReader.I
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 cycleDataStageReader.I
10  * @author drose
11  * @date 2006-02-08
12  */
13 
14 #ifndef CPPPARSER
15 
16 #ifdef DO_PIPELINING
17 // This is the implementation for full support of pipelining (as well as the
18 // sanity-check only implementation).
19 
20 /**
21  *
22  */
23 template<class CycleDataType>
26  int stage, Thread *current_thread) :
27  _cycler(&cycler),
28  _current_thread(current_thread),
29  _stage(stage)
30 {
31  _pointer = _cycler->read_stage_unlocked(_stage);
32 }
33 
34 /**
35  *
36  */
37 template<class CycleDataType>
40  _cycler(copy._cycler),
41  _current_thread(copy._current_thread),
42  _pointer(copy._pointer),
43  _stage(copy._stage)
44 {
45 }
46 
47 /**
48  *
49  */
50 template<class CycleDataType>
53  nassertv(_current_thread == copy._current_thread);
54 
55  _cycler = copy._cycler;
56  _pointer = copy._pointer;
57  _stage = copy._stage;
58 }
59 
60 /**
61  *
62  */
63 template<class CycleDataType>
66 }
67 
68 /**
69  * This provides an indirect member access to the actual CycleData data.
70  */
71 template<class CycleDataType>
72 INLINE const CycleDataType *CycleDataStageReader<CycleDataType>::
73 operator -> () const {
74  return _pointer;
75 }
76 
77 /**
78  * This allows the CycleDataStageReader to be passed to any function that
79  * expects a const CycleDataType pointer.
80  */
81 template<class CycleDataType>
83 operator const CycleDataType * () const {
84  return _pointer;
85 }
86 
87 /**
88  * Returns the Thread pointer of the currently-executing thread, as passed to
89  * the constructor of this object.
90  */
91 template<class CycleDataType>
93 get_current_thread() const {
94  return _current_thread;
95 }
96 
97 #else // !DO_PIPELINING
98 // This is the trivial, do-nothing implementation.
99 
100 /**
101  *
102  */
103 template<class CycleDataType>
106  Thread *) {
107  _pointer = cycler.cheat();
108 }
109 
110 /**
111  *
112  */
113 template<class CycleDataType>
116  _pointer(copy._pointer)
117 {
118 }
119 
120 /**
121  *
122  */
123 template<class CycleDataType>
126  _pointer = copy._pointer;
127 }
128 
129 /**
130  *
131  */
132 template<class CycleDataType>
135 }
136 
137 /**
138  * This provides an indirect member access to the actual CycleData data.
139  */
140 template<class CycleDataType>
141 INLINE const CycleDataType *CycleDataStageReader<CycleDataType>::
142 operator -> () const {
143  return _pointer;
144 }
145 
146 /**
147  * This allows the CycleDataStageReader to be passed to any function that
148  * expects a const CycleDataType pointer.
149  */
150 template<class CycleDataType>
152 operator const CycleDataType * () const {
153  return _pointer;
154 }
155 
156 /**
157  * Returns the Thread pointer of the currently-executing thread, as passed to
158  * the constructor of this object.
159  */
160 template<class CycleDataType>
163  return Thread::get_current_thread();
164 }
165 
166 #endif // DO_PIPELINING
167 #endif // CPPPARSER
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
CycleDataType * cheat() const
Returns a pointer without counting it.
const CycleDataType * operator ->() const
This provides an indirect member access to the actual CycleData data.
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
A thread; that is, a lightweight process.
Definition: thread.h:46
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...