00001 // Filename: pipelineCycler.I 00002 // Created by: drose (21Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 #ifdef DO_PIPELINING 00021 // The following implementations are to support compiled-in pipeline 00022 // sanity checks. 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Function: PipelineCycler::Constructor (sanity-check) 00026 // Access: Public 00027 // Description: 00028 //////////////////////////////////////////////////////////////////// 00029 template<class CycleDataType> 00030 INLINE PipelineCycler<CycleDataType>:: 00031 PipelineCycler(Pipeline *pipeline) : 00032 PipelineCyclerBase(new CycleDataType, pipeline) 00033 { 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: PipelineCycler::Copy Constructor (sanity-check) 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 template<class CycleDataType> 00042 INLINE PipelineCycler<CycleDataType>:: 00043 PipelineCycler(const PipelineCycler<CycleDataType> ©) : 00044 // In the DO_PIPELINING copy constructor, the pointer value is ignored. 00045 PipelineCyclerBase(NULL, copy) 00046 { 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: PipelineCycler::Copy Assignment (sanity-check) 00051 // Access: Public 00052 // Description: 00053 //////////////////////////////////////////////////////////////////// 00054 template<class CycleDataType> 00055 INLINE void PipelineCycler<CycleDataType>:: 00056 operator = (const PipelineCycler<CycleDataType> ©) { 00057 PipelineCyclerBase::operator = (copy); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: PipelineCycler::read (sanity-check) 00062 // Access: Public 00063 // Description: See PipelineCyclerBase::read(). 00064 //////////////////////////////////////////////////////////////////// 00065 template<class CycleDataType> 00066 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00067 read() const { 00068 return (const CycleDataType *)PipelineCyclerBase::read(); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: PipelineCycler::write (sanity-check) 00073 // Access: Public 00074 // Description: See PipelineCyclerBase::write(). 00075 //////////////////////////////////////////////////////////////////// 00076 template<class CycleDataType> 00077 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00078 write() { 00079 return (CycleDataType *)PipelineCyclerBase::write(); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: PipelineCycler::elevate_read (sanity-check) 00084 // Access: Public 00085 // Description: See PipelineCyclerBase::elevate_read(). 00086 //////////////////////////////////////////////////////////////////// 00087 template<class CycleDataType> 00088 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00089 elevate_read(const CycleDataType *pointer) { 00090 return (CycleDataType *)PipelineCyclerBase::elevate_read(pointer); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: PipelineCycler::write_stage (sanity-check) 00095 // Access: Public 00096 // Description: See PipelineCyclerBase::write_stage(). 00097 //////////////////////////////////////////////////////////////////// 00098 template<class CycleDataType> 00099 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00100 write_stage(int n) { 00101 return (CycleDataType *)PipelineCyclerBase::write_stage(n); 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: PipelineCycler::cheat (sanity-check) 00106 // Access: Public 00107 // Description: Returns a pointer without counting it. This is only 00108 // intended for use as the return value for certain 00109 // nassertr() functions, so the application can recover 00110 // after a failure to manage the read and write pointers 00111 // correctly. You should never call this function 00112 // directly. 00113 //////////////////////////////////////////////////////////////////// 00114 template<class CycleDataType> 00115 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00116 cheat() const { 00117 return (CycleDataType *)PipelineCyclerBase::cheat(); 00118 } 00119 00120 #else // !DO_PIPELINING 00121 // The following implementations are provided for when pipelining is 00122 // not compiled in. They are trivial functions that do as little as 00123 // possible. 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: PipelineCycler::Constructor (trivial) 00127 // Access: Public 00128 // Description: 00129 //////////////////////////////////////////////////////////////////// 00130 template<class CycleDataType> 00131 INLINE PipelineCycler<CycleDataType>:: 00132 PipelineCycler(Pipeline *pipeline) : 00133 PipelineCyclerBase(&_typed_data, pipeline) 00134 { 00135 } 00136 00137 //////////////////////////////////////////////////////////////////// 00138 // Function: PipelineCycler::Copy Constructor (trivial) 00139 // Access: Public 00140 // Description: 00141 //////////////////////////////////////////////////////////////////// 00142 template<class CycleDataType> 00143 INLINE PipelineCycler<CycleDataType>:: 00144 PipelineCycler(const PipelineCycler<CycleDataType> ©) : 00145 PipelineCyclerBase(&_typed_data, copy), 00146 _typed_data(copy._typed_data) 00147 { 00148 } 00149 00150 //////////////////////////////////////////////////////////////////// 00151 // Function: PipelineCycler::Copy Assignment (trivial) 00152 // Access: Public 00153 // Description: 00154 //////////////////////////////////////////////////////////////////// 00155 template<class CycleDataType> 00156 INLINE void PipelineCycler<CycleDataType>:: 00157 operator = (const PipelineCycler<CycleDataType> ©) { 00158 PipelineCyclerBase::operator = (copy); 00159 _typed_data = copy._typed_data; 00160 } 00161 00162 //////////////////////////////////////////////////////////////////// 00163 // Function: PipelineCycler::read (trivial) 00164 // Access: Public 00165 // Description: See PipelineCyclerBase::read(). 00166 //////////////////////////////////////////////////////////////////// 00167 template<class CycleDataType> 00168 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00169 read() const { 00170 return &_typed_data; 00171 } 00172 00173 //////////////////////////////////////////////////////////////////// 00174 // Function: PipelineCycler::write (trivial) 00175 // Access: Public 00176 // Description: See PipelineCyclerBase::write(). 00177 //////////////////////////////////////////////////////////////////// 00178 template<class CycleDataType> 00179 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00180 write() { 00181 return &_typed_data; 00182 } 00183 00184 //////////////////////////////////////////////////////////////////// 00185 // Function: PipelineCycler::elevate_read (trivial) 00186 // Access: Public 00187 // Description: See PipelineCyclerBase::elevate_read(). 00188 //////////////////////////////////////////////////////////////////// 00189 template<class CycleDataType> 00190 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00191 elevate_read(const CycleDataType *) { 00192 return &_typed_data; 00193 } 00194 00195 //////////////////////////////////////////////////////////////////// 00196 // Function: PipelineCycler::write_stage (trivial) 00197 // Access: Public 00198 // Description: See PipelineCyclerBase::write_stage(). 00199 //////////////////////////////////////////////////////////////////// 00200 template<class CycleDataType> 00201 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00202 write_stage(int) { 00203 return &_typed_data; 00204 } 00205 00206 //////////////////////////////////////////////////////////////////// 00207 // Function: PipelineCycler::cheat (trivial) 00208 // Access: Public 00209 // Description: Returns a pointer without counting it. This is only 00210 // intended for use as the return value for certain 00211 // nassertr() functions, so the application can recover 00212 // after a failure to manage the read and write pointers 00213 // correctly. You should never call this function 00214 // directly. 00215 //////////////////////////////////////////////////////////////////// 00216 template<class CycleDataType> 00217 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00218 cheat() const { 00219 return (CycleDataType *)&_typed_data; 00220 } 00221 00222 00223 #endif // DO_PIPELINING