00001 // Filename: cycleDataStageReader.I 00002 // Created by: drose (08Feb06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CPPPARSER 00016 00017 #ifdef DO_PIPELINING 00018 // This is the implementation for full support of pipelining (as well 00019 // as the sanity-check only implementation). 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function: CycleDataStageReader::Constructor (full) 00023 // Access: Public 00024 // Description: 00025 //////////////////////////////////////////////////////////////////// 00026 template<class CycleDataType> 00027 INLINE CycleDataStageReader<CycleDataType>:: 00028 CycleDataStageReader(const PipelineCycler<CycleDataType> &cycler, 00029 int stage, Thread *current_thread) : 00030 _cycler(&cycler), 00031 _current_thread(current_thread), 00032 _stage(stage) 00033 { 00034 _pointer = _cycler->read_stage_unlocked(_stage); 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: CycleDataStageReader::Copy Constructor (full) 00039 // Access: Public 00040 // Description: 00041 //////////////////////////////////////////////////////////////////// 00042 template<class CycleDataType> 00043 INLINE CycleDataStageReader<CycleDataType>:: 00044 CycleDataStageReader(const CycleDataStageReader<CycleDataType> ©) : 00045 _cycler(copy._cycler), 00046 _current_thread(copy._current_thread), 00047 _pointer(copy._pointer), 00048 _stage(copy._stage) 00049 { 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: CycleDataStageReader::Copy Assignment (full) 00054 // Access: Public 00055 // Description: 00056 //////////////////////////////////////////////////////////////////// 00057 template<class CycleDataType> 00058 INLINE void CycleDataStageReader<CycleDataType>:: 00059 operator = (const CycleDataStageReader<CycleDataType> ©) { 00060 nassertv(_current_thread == copy._current_thread); 00061 00062 _cycler = copy._cycler; 00063 _pointer = copy._pointer; 00064 _stage = copy._stage; 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: CycleDataStageReader::Destructor (full) 00069 // Access: Public 00070 // Description: 00071 //////////////////////////////////////////////////////////////////// 00072 template<class CycleDataType> 00073 INLINE CycleDataStageReader<CycleDataType>:: 00074 ~CycleDataStageReader() { 00075 } 00076 00077 //////////////////////////////////////////////////////////////////// 00078 // Function: CycleDataStageReader::operator -> (full) 00079 // Access: Public 00080 // Description: This provides an indirect member access to the actual 00081 // CycleData data. 00082 //////////////////////////////////////////////////////////////////// 00083 template<class CycleDataType> 00084 INLINE const CycleDataType *CycleDataStageReader<CycleDataType>:: 00085 operator -> () const { 00086 return _pointer; 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: CycleDataStageReader::Typecast pointer (full) 00091 // Access: Public 00092 // Description: This allows the CycleDataStageReader to be passed to any 00093 // function that expects a const CycleDataType pointer. 00094 //////////////////////////////////////////////////////////////////// 00095 template<class CycleDataType> 00096 INLINE CycleDataStageReader<CycleDataType>:: 00097 operator const CycleDataType * () const { 00098 return _pointer; 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: CycleDataStageReader::get_current_thread (full) 00103 // Access: Public 00104 // Description: Returns the Thread pointer of the currently-executing 00105 // thread, as passed to the constructor of this object. 00106 //////////////////////////////////////////////////////////////////// 00107 template<class CycleDataType> 00108 INLINE Thread *CycleDataStageReader<CycleDataType>:: 00109 get_current_thread() const { 00110 return _current_thread; 00111 } 00112 00113 #else // !DO_PIPELINING 00114 // This is the trivial, do-nothing implementation. 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: CycleDataStageReader::Constructor (trivial) 00118 // Access: Public 00119 // Description: 00120 //////////////////////////////////////////////////////////////////// 00121 template<class CycleDataType> 00122 INLINE CycleDataStageReader<CycleDataType>:: 00123 CycleDataStageReader(const PipelineCycler<CycleDataType> &cycler, int, 00124 Thread *) { 00125 _pointer = cycler.cheat(); 00126 } 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: CycleDataStageReader::Copy Constructor (trivial) 00130 // Access: Public 00131 // Description: 00132 //////////////////////////////////////////////////////////////////// 00133 template<class CycleDataType> 00134 INLINE CycleDataStageReader<CycleDataType>:: 00135 CycleDataStageReader(const CycleDataStageReader<CycleDataType> ©) : 00136 _pointer(copy._pointer) 00137 { 00138 } 00139 00140 //////////////////////////////////////////////////////////////////// 00141 // Function: CycleDataStageReader::Copy Assignment (trivial) 00142 // Access: Public 00143 // Description: 00144 //////////////////////////////////////////////////////////////////// 00145 template<class CycleDataType> 00146 INLINE void CycleDataStageReader<CycleDataType>:: 00147 operator = (const CycleDataStageReader<CycleDataType> ©) { 00148 _pointer = copy._pointer; 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: CycleDataStageReader::Destructor (trivial) 00153 // Access: Public 00154 // Description: 00155 //////////////////////////////////////////////////////////////////// 00156 template<class CycleDataType> 00157 INLINE CycleDataStageReader<CycleDataType>:: 00158 ~CycleDataStageReader() { 00159 } 00160 00161 //////////////////////////////////////////////////////////////////// 00162 // Function: CycleDataStageReader::operator -> (trivial) 00163 // Access: Public 00164 // Description: This provides an indirect member access to the actual 00165 // CycleData data. 00166 //////////////////////////////////////////////////////////////////// 00167 template<class CycleDataType> 00168 INLINE const CycleDataType *CycleDataStageReader<CycleDataType>:: 00169 operator -> () const { 00170 return _pointer; 00171 } 00172 00173 //////////////////////////////////////////////////////////////////// 00174 // Function: CycleDataStageReader::Typecast pointer (trivial) 00175 // Access: Public 00176 // Description: This allows the CycleDataStageReader to be passed to any 00177 // function that expects a const CycleDataType pointer. 00178 //////////////////////////////////////////////////////////////////// 00179 template<class CycleDataType> 00180 INLINE CycleDataStageReader<CycleDataType>:: 00181 operator const CycleDataType * () const { 00182 return _pointer; 00183 } 00184 00185 //////////////////////////////////////////////////////////////////// 00186 // Function: CycleDataStageReader::get_current_thread (trivial) 00187 // Access: Public 00188 // Description: Returns the Thread pointer of the currently-executing 00189 // thread, as passed to the constructor of this object. 00190 //////////////////////////////////////////////////////////////////// 00191 template<class CycleDataType> 00192 INLINE Thread *CycleDataStageReader<CycleDataType>:: 00193 get_current_thread() const { 00194 return Thread::get_current_thread(); 00195 } 00196 00197 #endif // DO_PIPELINING 00198 #endif // CPPPARSER