00001 // Filename: cycleDataWriter.h 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 #ifndef CYCLEDATAWRITER_H 00020 #define CYCLEDATAWRITER_H 00021 00022 #include "pandabase.h" 00023 00024 #include "cycleData.h" 00025 #include "pipelineCycler.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : CycleDataWriter 00029 // Description : This template class calls PipelineCycler::write() in 00030 // the constructor and PipelineCycler::release_write() in 00031 // the destructor. In the interim, it provides a 00032 // transparent read-write access to the CycleData. 00033 // 00034 // It exists as a syntactic convenience to access the 00035 // data in the CycleData. It also allows the whole 00036 // system to compile down to nothing if 00037 // SUPPORT_PIPELINING is not defined. 00038 //////////////////////////////////////////////////////////////////// 00039 template<class CycleDataType> 00040 class CycleDataWriter { 00041 public: 00042 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler); 00043 INLINE CycleDataWriter(const CycleDataWriter<CycleDataType> ©); 00044 INLINE void operator = (const CycleDataWriter<CycleDataType> ©); 00045 00046 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataWriter<CycleDataType> &take_from); 00047 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataReader<CycleDataType> &take_from); 00048 00049 INLINE ~CycleDataWriter(); 00050 00051 INLINE CycleDataType *operator -> (); 00052 INLINE const CycleDataType *operator -> () const; 00053 00054 INLINE operator CycleDataType * (); 00055 00056 private: 00057 #ifdef DO_PIPELINING 00058 // This is the data stored for a real pipelining implementation. 00059 PipelineCycler<CycleDataType> *_cycler; 00060 CycleDataType *_pointer; 00061 #else // !DO_PIPELINING 00062 // This is all we need for the trivial, do-nothing implementation. 00063 CycleDataType *_pointer; 00064 #endif // DO_PIPELINING 00065 }; 00066 00067 #include "cycleDataWriter.I" 00068 00069 #endif