Panda3D
 All Classes Functions Variables Enumerations
cycleDataStageReader.I
1 // Filename: cycleDataStageReader.I
2 // Created by: drose (08Feb06)
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 #ifndef CPPPARSER
16 
17 #ifdef DO_PIPELINING
18 // This is the implementation for full support of pipelining (as well
19 // as the sanity-check only implementation).
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: CycleDataStageReader::Constructor (full)
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 template<class CycleDataType>
29  int stage, Thread *current_thread) :
30  _cycler(&cycler),
31  _current_thread(current_thread),
32  _stage(stage)
33 {
34  _pointer = _cycler->read_stage_unlocked(_stage);
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: CycleDataStageReader::Copy Constructor (full)
39 // Access: Public
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 template<class CycleDataType>
45  _cycler(copy._cycler),
46  _current_thread(copy._current_thread),
47  _pointer(copy._pointer),
48  _stage(copy._stage)
49 {
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: CycleDataStageReader::Copy Assignment (full)
54 // Access: Public
55 // Description:
56 ////////////////////////////////////////////////////////////////////
57 template<class CycleDataType>
60  nassertv(_current_thread == copy._current_thread);
61 
62  _cycler = copy._cycler;
63  _pointer = copy._pointer;
64  _stage = copy._stage;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: CycleDataStageReader::Destructor (full)
69 // Access: Public
70 // Description:
71 ////////////////////////////////////////////////////////////////////
72 template<class CycleDataType>
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: CycleDataStageReader::operator -> (full)
79 // Access: Public
80 // Description: This provides an indirect member access to the actual
81 // CycleData data.
82 ////////////////////////////////////////////////////////////////////
83 template<class CycleDataType>
84 INLINE const CycleDataType *CycleDataStageReader<CycleDataType>::
85 operator -> () const {
86  return _pointer;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: CycleDataStageReader::Typecast pointer (full)
91 // Access: Public
92 // Description: This allows the CycleDataStageReader to be passed to any
93 // function that expects a const CycleDataType pointer.
94 ////////////////////////////////////////////////////////////////////
95 template<class CycleDataType>
97 operator const CycleDataType * () const {
98  return _pointer;
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: CycleDataStageReader::get_current_thread (full)
103 // Access: Public
104 // Description: Returns the Thread pointer of the currently-executing
105 // thread, as passed to the constructor of this object.
106 ////////////////////////////////////////////////////////////////////
107 template<class CycleDataType>
109 get_current_thread() const {
110  return _current_thread;
111 }
112 
113 #else // !DO_PIPELINING
114 // This is the trivial, do-nothing implementation.
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: CycleDataStageReader::Constructor (trivial)
118 // Access: Public
119 // Description:
120 ////////////////////////////////////////////////////////////////////
121 template<class CycleDataType>
124  Thread *) {
125  _pointer = cycler.cheat();
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: CycleDataStageReader::Copy Constructor (trivial)
130 // Access: Public
131 // Description:
132 ////////////////////////////////////////////////////////////////////
133 template<class CycleDataType>
136  _pointer(copy._pointer)
137 {
138 }
139 
140 ////////////////////////////////////////////////////////////////////
141 // Function: CycleDataStageReader::Copy Assignment (trivial)
142 // Access: Public
143 // Description:
144 ////////////////////////////////////////////////////////////////////
145 template<class CycleDataType>
148  _pointer = copy._pointer;
149 }
150 
151 ////////////////////////////////////////////////////////////////////
152 // Function: CycleDataStageReader::Destructor (trivial)
153 // Access: Public
154 // Description:
155 ////////////////////////////////////////////////////////////////////
156 template<class CycleDataType>
159 }
160 
161 ////////////////////////////////////////////////////////////////////
162 // Function: CycleDataStageReader::operator -> (trivial)
163 // Access: Public
164 // Description: This provides an indirect member access to the actual
165 // CycleData data.
166 ////////////////////////////////////////////////////////////////////
167 template<class CycleDataType>
168 INLINE const CycleDataType *CycleDataStageReader<CycleDataType>::
169 operator -> () const {
170  return _pointer;
171 }
172 
173 ////////////////////////////////////////////////////////////////////
174 // Function: CycleDataStageReader::Typecast pointer (trivial)
175 // Access: Public
176 // Description: This allows the CycleDataStageReader to be passed to any
177 // function that expects a const CycleDataType pointer.
178 ////////////////////////////////////////////////////////////////////
179 template<class CycleDataType>
181 operator const CycleDataType * () const {
182  return _pointer;
183 }
184 
185 ////////////////////////////////////////////////////////////////////
186 // Function: CycleDataStageReader::get_current_thread (trivial)
187 // Access: Public
188 // Description: Returns the Thread pointer of the currently-executing
189 // thread, as passed to the constructor of this object.
190 ////////////////////////////////////////////////////////////////////
191 template<class CycleDataType>
195 }
196 
197 #endif // DO_PIPELINING
198 #endif // CPPPARSER
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
const CycleDataType * operator->() const
This provides an indirect member access to the actual CycleData data.
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
CycleDataType * cheat() const
Returns a pointer without counting it.
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:51