Panda3D
 All Classes Functions Variables Enumerations
cycleDataStageWriter.h
00001 // Filename: cycleDataStageWriter.h
00002 // Created by:  drose (06Feb06)
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 CYCLEDATASTAGEWRITER_H
00016 #define CYCLEDATASTAGEWRITER_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "cycleData.h"
00021 #include "pipelineCycler.h"
00022 #include "cycleDataLockedStageReader.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : CycleDataStageWriter
00026 // Description : This class is similar to CycleDataWriter, except it
00027 //               allows writing to a particular stage of the pipeline.
00028 //               Usually this is used to implement writing directly to
00029 //               an upstream pipeline value, to recompute a cached
00030 //               value there (otherwise, the cached value would go
00031 //               away with the next pipeline cycle).
00032 ////////////////////////////////////////////////////////////////////
00033 template<class CycleDataType>
00034 class CycleDataStageWriter {
00035 public:
00036   // By hiding this template from interrogate, we improve compile-time
00037   // speed and memory utilization.
00038 #ifndef CPPPARSER
00039   INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
00040                               Thread *current_thread = Thread::get_current_thread());
00041   INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
00042                               bool force_to_0, Thread *current_thread = Thread::get_current_thread());
00043 
00044   INLINE CycleDataStageWriter(const CycleDataStageWriter<CycleDataType> &copy);
00045   INLINE void operator = (const CycleDataStageWriter<CycleDataType> &copy);
00046 
00047   INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
00048                               CycleDataLockedStageReader<CycleDataType> &take_from);
00049   INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
00050                               CycleDataLockedStageReader<CycleDataType> &take_from,
00051                               bool force_to_0);
00052 
00053   INLINE ~CycleDataStageWriter();
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   int _stage;
00069 #else  // !DO_PIPELINING
00070   // This is all we need for the trivial, do-nothing implementation.
00071   CycleDataType *_pointer;
00072 #endif  // DO_PIPELINING
00073 #endif  // CPPPARSER
00074 };
00075 
00076 #include "cycleDataStageWriter.I"
00077 
00078 #endif
 All Classes Functions Variables Enumerations