Panda3D
|
00001 // Filename: cycleDataReader.I 00002 // Created by: drose (21Feb02) 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: CycleDataReader::Constructor (full) 00023 // Access: Public 00024 // Description: 00025 //////////////////////////////////////////////////////////////////// 00026 template<class CycleDataType> 00027 INLINE CycleDataReader<CycleDataType>:: 00028 CycleDataReader(const PipelineCycler<CycleDataType> &cycler, 00029 Thread *current_thread) : 00030 _cycler(&cycler), 00031 _current_thread(current_thread) 00032 { 00033 _pointer = _cycler->read_unlocked(_current_thread); 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: CycleDataReader::Copy Constructor (full) 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 template<class CycleDataType> 00042 INLINE CycleDataReader<CycleDataType>:: 00043 CycleDataReader(const CycleDataReader<CycleDataType> ©) : 00044 _cycler(copy._cycler), 00045 _current_thread(copy._current_thread), 00046 _pointer(copy._pointer) 00047 { 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: CycleDataReader::Copy Assignment (full) 00052 // Access: Public 00053 // Description: 00054 //////////////////////////////////////////////////////////////////// 00055 template<class CycleDataType> 00056 INLINE void CycleDataReader<CycleDataType>:: 00057 operator = (const CycleDataReader<CycleDataType> ©) { 00058 nassertv(_current_thread == copy._current_thread); 00059 00060 _cycler = copy._cycler; 00061 _pointer = copy._pointer; 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: CycleDataReader::Destructor (full) 00066 // Access: Public 00067 // Description: 00068 //////////////////////////////////////////////////////////////////// 00069 template<class CycleDataType> 00070 INLINE CycleDataReader<CycleDataType>:: 00071 ~CycleDataReader() { 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: CycleDataReader::operator -> (full) 00076 // Access: Public 00077 // Description: This provides an indirect member access to the actual 00078 // CycleData data. 00079 //////////////////////////////////////////////////////////////////// 00080 template<class CycleDataType> 00081 INLINE const CycleDataType *CycleDataReader<CycleDataType>:: 00082 operator -> () const { 00083 return _pointer; 00084 } 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function: CycleDataReader::Typecast pointer (full) 00088 // Access: Public 00089 // Description: This allows the CycleDataReader to be passed to any 00090 // function that expects a const CycleDataType pointer. 00091 //////////////////////////////////////////////////////////////////// 00092 template<class CycleDataType> 00093 INLINE CycleDataReader<CycleDataType>:: 00094 operator const CycleDataType * () const { 00095 return _pointer; 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: CycleDataReader::get_current_thread (full) 00100 // Access: Public 00101 // Description: Returns the Thread pointer of the currently-executing 00102 // thread, as passed to the constructor of this object. 00103 //////////////////////////////////////////////////////////////////// 00104 template<class CycleDataType> 00105 INLINE Thread *CycleDataReader<CycleDataType>:: 00106 get_current_thread() const { 00107 return _current_thread; 00108 } 00109 00110 #else // !DO_PIPELINING 00111 // This is the trivial, do-nothing implementation. 00112 00113 //////////////////////////////////////////////////////////////////// 00114 // Function: CycleDataReader::Constructor (trivial) 00115 // Access: Public 00116 // Description: 00117 //////////////////////////////////////////////////////////////////// 00118 template<class CycleDataType> 00119 INLINE CycleDataReader<CycleDataType>:: 00120 CycleDataReader(const PipelineCycler<CycleDataType> &cycler, Thread *) { 00121 _pointer = cycler.cheat(); 00122 } 00123 00124 //////////////////////////////////////////////////////////////////// 00125 // Function: CycleDataReader::Copy Constructor (trivial) 00126 // Access: Public 00127 // Description: 00128 //////////////////////////////////////////////////////////////////// 00129 template<class CycleDataType> 00130 INLINE CycleDataReader<CycleDataType>:: 00131 CycleDataReader(const CycleDataReader<CycleDataType> ©) : 00132 _pointer(copy._pointer) 00133 { 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: CycleDataReader::Copy Assignment (trivial) 00138 // Access: Public 00139 // Description: 00140 //////////////////////////////////////////////////////////////////// 00141 template<class CycleDataType> 00142 INLINE void CycleDataReader<CycleDataType>:: 00143 operator = (const CycleDataReader<CycleDataType> ©) { 00144 _pointer = copy._pointer; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: CycleDataReader::Destructor (trivial) 00149 // Access: Public 00150 // Description: 00151 //////////////////////////////////////////////////////////////////// 00152 template<class CycleDataType> 00153 INLINE CycleDataReader<CycleDataType>:: 00154 ~CycleDataReader() { 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: CycleDataReader::operator -> (trivial) 00159 // Access: Public 00160 // Description: This provides an indirect member access to the actual 00161 // CycleData data. 00162 //////////////////////////////////////////////////////////////////// 00163 template<class CycleDataType> 00164 INLINE const CycleDataType *CycleDataReader<CycleDataType>:: 00165 operator -> () const { 00166 return _pointer; 00167 } 00168 00169 //////////////////////////////////////////////////////////////////// 00170 // Function: CycleDataReader::Typecast pointer (trivial) 00171 // Access: Public 00172 // Description: This allows the CycleDataReader to be passed to any 00173 // function that expects a const CycleDataType pointer. 00174 //////////////////////////////////////////////////////////////////// 00175 template<class CycleDataType> 00176 INLINE CycleDataReader<CycleDataType>:: 00177 operator const CycleDataType * () const { 00178 return _pointer; 00179 } 00180 00181 //////////////////////////////////////////////////////////////////// 00182 // Function: CycleDataReader::get_current_thread (trivial) 00183 // Access: Public 00184 // Description: Returns the Thread pointer of the currently-executing 00185 // thread, as passed to the constructor of this object. 00186 //////////////////////////////////////////////////////////////////// 00187 template<class CycleDataType> 00188 INLINE Thread *CycleDataReader<CycleDataType>:: 00189 get_current_thread() const { 00190 return Thread::get_current_thread(); 00191 } 00192 00193 #endif // DO_PIPELINING 00194 #endif // CPPPARSER