Panda3D
 All Classes Functions Variables Enumerations
cycleDataReader.I
1 // Filename: cycleDataReader.I
2 // Created by: drose (21Feb02)
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: CycleDataReader::Constructor (full)
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 template<class CycleDataType>
29  Thread *current_thread) :
30  _cycler(&cycler),
31  _current_thread(current_thread)
32 {
33  _pointer = _cycler->read_unlocked(_current_thread);
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: CycleDataReader::Copy Constructor (full)
38 // Access: Public
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 template<class CycleDataType>
44  _cycler(copy._cycler),
45  _current_thread(copy._current_thread),
46  _pointer(copy._pointer)
47 {
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: CycleDataReader::Copy Assignment (full)
52 // Access: Public
53 // Description:
54 ////////////////////////////////////////////////////////////////////
55 template<class CycleDataType>
58  nassertv(_current_thread == copy._current_thread);
59 
60  _cycler = copy._cycler;
61  _pointer = copy._pointer;
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: CycleDataReader::Destructor (full)
66 // Access: Public
67 // Description:
68 ////////////////////////////////////////////////////////////////////
69 template<class CycleDataType>
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: CycleDataReader::operator -> (full)
76 // Access: Public
77 // Description: This provides an indirect member access to the actual
78 // CycleData data.
79 ////////////////////////////////////////////////////////////////////
80 template<class CycleDataType>
81 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
82 operator -> () const {
83  return _pointer;
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: CycleDataReader::Typecast pointer (full)
88 // Access: Public
89 // Description: This allows the CycleDataReader to be passed to any
90 // function that expects a const CycleDataType pointer.
91 ////////////////////////////////////////////////////////////////////
92 template<class CycleDataType>
94 operator const CycleDataType * () const {
95  return _pointer;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: CycleDataReader::p (full)
100 // Access: Public
101 // Description: This allows the CycleDataReader to be passed to any
102 // function that expects a const CycleDataType pointer.
103 ////////////////////////////////////////////////////////////////////
104 template<class CycleDataType>
105 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
106 p() const {
107  return _pointer;
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: CycleDataReader::get_current_thread (full)
112 // Access: Public
113 // Description: Returns the Thread pointer of the currently-executing
114 // thread, as passed to the constructor of this object.
115 ////////////////////////////////////////////////////////////////////
116 template<class CycleDataType>
118 get_current_thread() const {
119  return _current_thread;
120 }
121 
122 #else // !DO_PIPELINING
123 // This is the trivial, do-nothing implementation.
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: CycleDataReader::Constructor (trivial)
127 // Access: Public
128 // Description:
129 ////////////////////////////////////////////////////////////////////
130 template<class CycleDataType>
133  _pointer = cycler.cheat();
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: CycleDataReader::Copy Constructor (trivial)
138 // Access: Public
139 // Description:
140 ////////////////////////////////////////////////////////////////////
141 template<class CycleDataType>
144  _pointer(copy._pointer)
145 {
146 }
147 
148 ////////////////////////////////////////////////////////////////////
149 // Function: CycleDataReader::Copy Assignment (trivial)
150 // Access: Public
151 // Description:
152 ////////////////////////////////////////////////////////////////////
153 template<class CycleDataType>
156  _pointer = copy._pointer;
157 }
158 
159 ////////////////////////////////////////////////////////////////////
160 // Function: CycleDataReader::Destructor (trivial)
161 // Access: Public
162 // Description:
163 ////////////////////////////////////////////////////////////////////
164 template<class CycleDataType>
167 }
168 
169 ////////////////////////////////////////////////////////////////////
170 // Function: CycleDataReader::operator -> (trivial)
171 // Access: Public
172 // Description: This provides an indirect member access to the actual
173 // CycleData data.
174 ////////////////////////////////////////////////////////////////////
175 template<class CycleDataType>
176 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
177 operator -> () const {
178  return _pointer;
179 }
180 
181 ////////////////////////////////////////////////////////////////////
182 // Function: CycleDataReader::Typecast pointer (trivial)
183 // Access: Public
184 // Description: This allows the CycleDataReader to be passed to any
185 // function that expects a const CycleDataType pointer.
186 ////////////////////////////////////////////////////////////////////
187 template<class CycleDataType>
189 operator const CycleDataType * () const {
190  return _pointer;
191 }
192 
193 ////////////////////////////////////////////////////////////////////
194 // Function: CycleDataReader::p (trivial)
195 // Access: Public
196 // Description: This allows the CycleDataReader to be passed to any
197 // function that expects a const CycleDataType pointer.
198 ////////////////////////////////////////////////////////////////////
199 template<class CycleDataType>
200 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
201 p() const {
202  return _pointer;
203 }
204 
205 ////////////////////////////////////////////////////////////////////
206 // Function: CycleDataReader::get_current_thread (trivial)
207 // Access: Public
208 // Description: Returns the Thread pointer of the currently-executing
209 // thread, as passed to the constructor of this object.
210 ////////////////////////////////////////////////////////////////////
211 template<class CycleDataType>
215 }
216 
217 #endif // DO_PIPELINING
218 #endif // CPPPARSER
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
const CycleDataType * p() const
This allows the CycleDataReader to be passed to any function that expects a const CycleDataType point...
CycleDataType * cheat() const
Returns a pointer without counting it.
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
A thread; that is, a lightweight process.
Definition: thread.h:51
const CycleDataType * operator->() const
This provides an indirect member access to the actual CycleData data.