Panda3D
|
00001 // Filename: cycleDataWriter.h 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 CYCLEDATAWRITER_H 00016 #define CYCLEDATAWRITER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "cycleData.h" 00021 #include "pipelineCycler.h" 00022 #include "cycleDataLockedReader.h" 00023 #include "thread.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : CycleDataWriter 00027 // Description : This template class calls PipelineCycler::write() in 00028 // the constructor and PipelineCycler::release_write() in 00029 // the destructor. In the interim, it provides a 00030 // transparent read-write access to the CycleData. 00031 // 00032 // It exists as a syntactic convenience to access the 00033 // data in the CycleData. It also allows the whole 00034 // system to compile down to nothing if 00035 // DO_PIPELINING is not defined. 00036 //////////////////////////////////////////////////////////////////// 00037 template<class CycleDataType> 00038 class CycleDataWriter { 00039 public: 00040 // By hiding this template from interrogate, we improve compile-time 00041 // speed and memory utilization. 00042 #ifndef CPPPARSER 00043 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, 00044 Thread *current_thread = Thread::get_current_thread()); 00045 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, bool force_to_0, 00046 Thread *current_thread = Thread::get_current_thread()); 00047 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, 00048 CycleDataType *locked_cdata, 00049 Thread *current_thread = Thread::get_current_thread()); 00050 INLINE CycleDataWriter(const CycleDataWriter<CycleDataType> ©); 00051 INLINE void operator = (const CycleDataWriter<CycleDataType> ©); 00052 00053 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataLockedReader<CycleDataType> &take_from); 00054 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataLockedReader<CycleDataType> &take_from, bool force_to_0); 00055 00056 INLINE ~CycleDataWriter(); 00057 00058 INLINE CycleDataType *operator -> (); 00059 INLINE const CycleDataType *operator -> () const; 00060 00061 INLINE operator CycleDataType * (); 00062 00063 INLINE Thread *get_current_thread() const; 00064 00065 private: 00066 #ifdef DO_PIPELINING 00067 // This is the data stored for a real pipelining implementation. 00068 PipelineCycler<CycleDataType> *_cycler; 00069 Thread *_current_thread; 00070 CycleDataType *_pointer; 00071 #else // !DO_PIPELINING 00072 // This is all we need for the trivial, do-nothing implementation. 00073 CycleDataType *_pointer; 00074 #endif // DO_PIPELINING 00075 #endif // CPPPARSER 00076 }; 00077 00078 #include "cycleDataWriter.I" 00079 00080 #endif