Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/cycleDataWriter.I

Go to the documentation of this file.
00001 // Filename: cycleDataWriter.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 #ifdef DO_PIPELINING
00020 // This is the implementation for full support of pipelining (as well
00021 // as the sanity-check only implementation).
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: CycleDataWriter::Constructor (full)
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 template<class CycleDataType>
00029 INLINE CycleDataWriter<CycleDataType>::
00030 CycleDataWriter(PipelineCycler<CycleDataType> &cycler) :
00031   _cycler(&cycler)
00032 {
00033   _pointer = _cycler->write();
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //     Function: CycleDataWriter::Copy Constructor (full)
00038 //       Access: Public
00039 //  Description:
00040 ////////////////////////////////////////////////////////////////////
00041 template<class CycleDataType>
00042 INLINE CycleDataWriter<CycleDataType>::
00043 CycleDataWriter(const CycleDataWriter<CycleDataType> &copy) :
00044   _cycler(copy._cycler),
00045   _pointer(copy._pointer)
00046 {
00047   nassertv(_pointer != (CycleDataType *)NULL);
00048   _cycler->increment_write(_pointer);
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: CycleDataWriter::Copy Assigment (full)
00053 //       Access: Public
00054 //  Description:
00055 ////////////////////////////////////////////////////////////////////
00056 template<class CycleDataType>
00057 INLINE void CycleDataWriter<CycleDataType>::
00058 operator = (const CycleDataWriter<CycleDataType> &copy) {
00059   _cycler = copy._cycler;
00060   _pointer = copy._pointer;
00061 
00062   nassertv(_pointer != (CycleDataType *)NULL);
00063   _cycler->increment_write(_pointer);
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: CycleDataWriter::Constructor (full)
00068 //       Access: Public
00069 //  Description: This is a lot like a copy constructor, in that the
00070 //               new CycleDataWriter object gets a handle to the same
00071 //               pointer held by the old CycleDataWriter object.
00072 //               However, since only one write pointer may be active
00073 //               at a time, this invalidates the old object.
00074 ////////////////////////////////////////////////////////////////////
00075 template<class CycleDataType>
00076 INLINE CycleDataWriter<CycleDataType>::
00077 CycleDataWriter(PipelineCycler<CycleDataType> &cycler, 
00078                 CycleDataWriter<CycleDataType> &take_from) :
00079   _cycler(&cycler),
00080   _pointer(take_from._pointer)
00081 {
00082   take_from._pointer = (CycleDataType *)NULL;
00083   nassertv(_pointer != (CycleDataType *)NULL);
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: CycleDataWriter::Constructor (full)
00088 //       Access: Public
00089 //  Description: This flavor of the constructor elevates the pointer
00090 //               from the CycleDataReader from a read to a write
00091 //               pointer (and invalidates the reader).
00092 ////////////////////////////////////////////////////////////////////
00093 template<class CycleDataType>
00094 INLINE CycleDataWriter<CycleDataType>::
00095 CycleDataWriter(PipelineCycler<CycleDataType> &cycler,
00096                 CycleDataReader<CycleDataType> &take_from) :
00097   _cycler(&cycler)
00098 {
00099   _pointer = _cycler->elevate_read(take_from.take_pointer());
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: CycleDataWriter::Destructor (full)
00104 //       Access: Public
00105 //  Description:
00106 ////////////////////////////////////////////////////////////////////
00107 template<class CycleDataType>
00108 INLINE CycleDataWriter<CycleDataType>::
00109 ~CycleDataWriter() {
00110   if (_pointer != (CycleDataType *)NULL) {
00111     _cycler->release_write(_pointer);
00112   }
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: CycleDataWriter::operator -> (full)
00117 //       Access: Public
00118 //  Description: This provides an indirect member access to the actual
00119 //               CycleData data.
00120 ////////////////////////////////////////////////////////////////////
00121 template<class CycleDataType>
00122 INLINE CycleDataType *CycleDataWriter<CycleDataType>::
00123 operator -> () {
00124   nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat());
00125   return _pointer;
00126 }
00127 
00128 ////////////////////////////////////////////////////////////////////
00129 //     Function: CycleDataWriter::operator -> (full)
00130 //       Access: Public
00131 //  Description: This provides an indirect member access to the actual
00132 //               CycleData data.
00133 ////////////////////////////////////////////////////////////////////
00134 template<class CycleDataType>
00135 INLINE const CycleDataType *CycleDataWriter<CycleDataType>::
00136 operator -> () const {
00137   nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat());
00138   return _pointer;
00139 }
00140 
00141 ////////////////////////////////////////////////////////////////////
00142 //     Function: CycleDataWriter::Typecast pointer (full)
00143 //       Access: Public
00144 //  Description: This allows the CycleDataWriter to be passed to any
00145 //               function that expects a CycleDataType pointer.
00146 ////////////////////////////////////////////////////////////////////
00147 template<class CycleDataType>
00148 INLINE CycleDataWriter<CycleDataType>::
00149 operator CycleDataType * () {
00150   nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat());
00151   return _pointer;
00152 }
00153 
00154 #else  // !DO_PIPELINING
00155 // This is the trivial, do-nothing implementation.
00156 
00157 ////////////////////////////////////////////////////////////////////
00158 //     Function: CycleDataWriter::Constructor (trivial)
00159 //       Access: Public
00160 //  Description:
00161 ////////////////////////////////////////////////////////////////////
00162 template<class CycleDataType>
00163 INLINE CycleDataWriter<CycleDataType>::
00164 CycleDataWriter(PipelineCycler<CycleDataType> &cycler) {
00165   _pointer = cycler.write();
00166 }
00167 
00168 ////////////////////////////////////////////////////////////////////
00169 //     Function: CycleDataWriter::Copy Constructor (trivial)
00170 //       Access: Public
00171 //  Description:
00172 ////////////////////////////////////////////////////////////////////
00173 template<class CycleDataType>
00174 INLINE CycleDataWriter<CycleDataType>::
00175 CycleDataWriter(const CycleDataWriter<CycleDataType> &copy) :
00176   _pointer(copy._pointer)
00177 {
00178 }
00179 
00180 ////////////////////////////////////////////////////////////////////
00181 //     Function: CycleDataWriter::Copy Assigment (trivial)
00182 //       Access: Public
00183 //  Description:
00184 ////////////////////////////////////////////////////////////////////
00185 template<class CycleDataType>
00186 INLINE void CycleDataWriter<CycleDataType>::
00187 operator = (const CycleDataWriter<CycleDataType> &copy) {
00188   _pointer = copy._pointer;
00189 }
00190 
00191 ////////////////////////////////////////////////////////////////////
00192 //     Function: CycleDataWriter::Constructor (trivial)
00193 //       Access: Public
00194 //  Description: This is a lot like a copy constructor, in that the
00195 //               new CycleDataWriter object gets a handle to the same
00196 //               pointer held by the old CycleDataWriter object.
00197 //               However, since only one write pointer may be active
00198 //               at a time, this invalidates the old object.
00199 ////////////////////////////////////////////////////////////////////
00200 template<class CycleDataType>
00201 INLINE CycleDataWriter<CycleDataType>::
00202 CycleDataWriter(PipelineCycler<CycleDataType> &, 
00203                 CycleDataWriter<CycleDataType> &take_from) :
00204   _pointer(take_from.take_pointer())
00205 {
00206 }
00207 
00208 ////////////////////////////////////////////////////////////////////
00209 //     Function: CycleDataWriter::Constructor (trivial)
00210 //       Access: Public
00211 //  Description: This flavor of the constructor elevates the pointer
00212 //               from the CycleDataReader from a read to a write
00213 //               pointer (and invalidates the reader).
00214 ////////////////////////////////////////////////////////////////////
00215 template<class CycleDataType>
00216 INLINE CycleDataWriter<CycleDataType>::
00217 CycleDataWriter(PipelineCycler<CycleDataType> &,
00218                 CycleDataReader<CycleDataType> &take_from) :
00219   _pointer((CycleDataType *)take_from.take_pointer())
00220 {
00221 }
00222 
00223 ////////////////////////////////////////////////////////////////////
00224 //     Function: CycleDataWriter::Destructor (trivial)
00225 //       Access: Public
00226 //  Description:
00227 ////////////////////////////////////////////////////////////////////
00228 template<class CycleDataType>
00229 INLINE CycleDataWriter<CycleDataType>::
00230 ~CycleDataWriter() {
00231 }
00232 
00233 ////////////////////////////////////////////////////////////////////
00234 //     Function: CycleDataWriter::operator -> (trivial)
00235 //       Access: Public
00236 //  Description: This provides an indirect member access to the actual
00237 //               CycleData data.
00238 ////////////////////////////////////////////////////////////////////
00239 template<class CycleDataType>
00240 INLINE CycleDataType *CycleDataWriter<CycleDataType>::
00241 operator -> () {
00242   return _pointer;
00243 }
00244 
00245 ////////////////////////////////////////////////////////////////////
00246 //     Function: CycleDataWriter::operator -> (trivial)
00247 //       Access: Public
00248 //  Description: This provides an indirect member access to the actual
00249 //               CycleData data.
00250 ////////////////////////////////////////////////////////////////////
00251 template<class CycleDataType>
00252 INLINE const CycleDataType *CycleDataWriter<CycleDataType>::
00253 operator -> () const {
00254   return _pointer;
00255 }
00256 
00257 ////////////////////////////////////////////////////////////////////
00258 //     Function: CycleDataWriter::Typecast pointer (trivial)
00259 //       Access: Public
00260 //  Description: This allows the CycleDataWriter to be passed to any
00261 //               function that expects a CycleDataType pointer.
00262 ////////////////////////////////////////////////////////////////////
00263 template<class CycleDataType>
00264 INLINE CycleDataWriter<CycleDataType>::
00265 operator CycleDataType * () {
00266   return _pointer;
00267 }
00268 
00269 #endif  // DO_PIPELINING

Generated on Fri May 2 00:43:36 2003 for Panda by doxygen1.3