Panda3D

cycleDataReader.I

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> &copy) :
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> &copy) {
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::p (full)
00100 //       Access: Public
00101 //  Description: This allows the CycleDataReader to be passed to any
00102 //               function that expects a const CycleDataType pointer.
00103 ////////////////////////////////////////////////////////////////////
00104 template<class CycleDataType>
00105 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
00106 p() const {
00107   return _pointer;
00108 }
00109 
00110 ////////////////////////////////////////////////////////////////////
00111 //     Function: CycleDataReader::get_current_thread (full)
00112 //       Access: Public
00113 //  Description: Returns the Thread pointer of the currently-executing
00114 //               thread, as passed to the constructor of this object.
00115 ////////////////////////////////////////////////////////////////////
00116 template<class CycleDataType>
00117 INLINE Thread *CycleDataReader<CycleDataType>::
00118 get_current_thread() const {
00119   return _current_thread;
00120 }
00121 
00122 #else  // !DO_PIPELINING
00123 // This is the trivial, do-nothing implementation.
00124 
00125 ////////////////////////////////////////////////////////////////////
00126 //     Function: CycleDataReader::Constructor (trivial)
00127 //       Access: Public
00128 //  Description:
00129 ////////////////////////////////////////////////////////////////////
00130 template<class CycleDataType>
00131 INLINE CycleDataReader<CycleDataType>::
00132 CycleDataReader(const PipelineCycler<CycleDataType> &cycler, Thread *) {
00133   _pointer = cycler.cheat();
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: CycleDataReader::Copy Constructor (trivial)
00138 //       Access: Public
00139 //  Description:
00140 ////////////////////////////////////////////////////////////////////
00141 template<class CycleDataType>
00142 INLINE CycleDataReader<CycleDataType>::
00143 CycleDataReader(const CycleDataReader<CycleDataType> &copy) :
00144   _pointer(copy._pointer)
00145 {
00146 }
00147 
00148 ////////////////////////////////////////////////////////////////////
00149 //     Function: CycleDataReader::Copy Assignment (trivial)
00150 //       Access: Public
00151 //  Description:
00152 ////////////////////////////////////////////////////////////////////
00153 template<class CycleDataType>
00154 INLINE void CycleDataReader<CycleDataType>::
00155 operator = (const CycleDataReader<CycleDataType> &copy) {
00156   _pointer = copy._pointer;
00157 }
00158 
00159 ////////////////////////////////////////////////////////////////////
00160 //     Function: CycleDataReader::Destructor (trivial)
00161 //       Access: Public
00162 //  Description:
00163 ////////////////////////////////////////////////////////////////////
00164 template<class CycleDataType>
00165 INLINE CycleDataReader<CycleDataType>::
00166 ~CycleDataReader() {
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: CycleDataReader::operator -> (trivial)
00171 //       Access: Public
00172 //  Description: This provides an indirect member access to the actual
00173 //               CycleData data.
00174 ////////////////////////////////////////////////////////////////////
00175 template<class CycleDataType>
00176 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
00177 operator -> () const {
00178   return _pointer;
00179 }
00180 
00181 ////////////////////////////////////////////////////////////////////
00182 //     Function: CycleDataReader::Typecast pointer (trivial)
00183 //       Access: Public
00184 //  Description: This allows the CycleDataReader to be passed to any
00185 //               function that expects a const CycleDataType pointer.
00186 ////////////////////////////////////////////////////////////////////
00187 template<class CycleDataType>
00188 INLINE CycleDataReader<CycleDataType>::
00189 operator const CycleDataType * () const {
00190   return _pointer;
00191 }
00192 
00193 ////////////////////////////////////////////////////////////////////
00194 //     Function: CycleDataReader::p (trivial)
00195 //       Access: Public
00196 //  Description: This allows the CycleDataReader to be passed to any
00197 //               function that expects a const CycleDataType pointer.
00198 ////////////////////////////////////////////////////////////////////
00199 template<class CycleDataType>
00200 INLINE const CycleDataType *CycleDataReader<CycleDataType>::
00201 p() const {
00202   return _pointer;
00203 }
00204 
00205 ////////////////////////////////////////////////////////////////////
00206 //     Function: CycleDataReader::get_current_thread (trivial)
00207 //       Access: Public
00208 //  Description: Returns the Thread pointer of the currently-executing
00209 //               thread, as passed to the constructor of this object.
00210 ////////////////////////////////////////////////////////////////////
00211 template<class CycleDataType>
00212 INLINE Thread *CycleDataReader<CycleDataType>::
00213 get_current_thread() const {
00214   return Thread::get_current_thread();
00215 }
00216 
00217 #endif  // DO_PIPELINING
00218 #endif  // CPPPARSER
 All Classes Functions Variables Enumerations