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 // SUPPORT_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(const CycleDataWriter<CycleDataType> ©); 00048 INLINE void operator = (const CycleDataWriter<CycleDataType> ©); 00049 00050 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataLockedReader<CycleDataType> &take_from); 00051 INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataLockedReader<CycleDataType> &take_from, bool force_to_0); 00052 00053 INLINE ~CycleDataWriter(); 00054 00055 INLINE CycleDataType *operator -> (); 00056 INLINE const CycleDataType *operator -> () const; 00057 00058 INLINE operator CycleDataType * (); 00059 00060 INLINE Thread *get_current_thread() const; 00061 00062 private: 00063 #ifdef DO_PIPELINING 00064 // This is the data stored for a real pipelining implementation. 00065 PipelineCycler<CycleDataType> *_cycler; 00066 Thread *_current_thread; 00067 CycleDataType *_pointer; 00068 #else // !DO_PIPELINING 00069 // This is all we need for the trivial, do-nothing implementation. 00070 CycleDataType *_pointer; 00071 #endif // DO_PIPELINING 00072 #endif // CPPPARSER 00073 }; 00074 00075 #include "cycleDataWriter.I" 00076 00077 #endif