Panda3D
cycleDataStageWriter.h
1 // Filename: cycleDataStageWriter.h
2 // Created by: drose (06Feb06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CYCLEDATASTAGEWRITER_H
16 #define CYCLEDATASTAGEWRITER_H
17 
18 #include "pandabase.h"
19 
20 #include "cycleData.h"
21 #include "pipelineCycler.h"
22 #include "cycleDataLockedStageReader.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : CycleDataStageWriter
26 // Description : This class is similar to CycleDataWriter, except it
27 // allows writing to a particular stage of the pipeline.
28 // Usually this is used to implement writing directly to
29 // an upstream pipeline value, to recompute a cached
30 // value there (otherwise, the cached value would go
31 // away with the next pipeline cycle).
32 ////////////////////////////////////////////////////////////////////
33 template<class CycleDataType>
35 public:
36  // By hiding this template from interrogate, we improve compile-time
37  // speed and memory utilization.
38 #ifndef CPPPARSER
39  INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
40  Thread *current_thread = Thread::get_current_thread());
41  INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
42  bool force_to_0, Thread *current_thread = Thread::get_current_thread());
43 
44  INLINE CycleDataStageWriter(const CycleDataStageWriter<CycleDataType> &copy);
45  INLINE void operator = (const CycleDataStageWriter<CycleDataType> &copy);
46 
47  INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
49  INLINE CycleDataStageWriter(PipelineCycler<CycleDataType> &cycler, int stage,
51  bool force_to_0);
52 
53  INLINE ~CycleDataStageWriter();
54 
55  INLINE CycleDataType *operator -> ();
56  INLINE const CycleDataType *operator -> () const;
57 
58  INLINE operator CycleDataType * ();
59 
60  INLINE Thread *get_current_thread() const;
61 
62 private:
63 #ifdef DO_PIPELINING
64  // This is the data stored for a real pipelining implementation.
66  Thread *_current_thread;
67  CycleDataType *_pointer;
68  int _stage;
69 #else // !DO_PIPELINING
70  // This is all we need for the trivial, do-nothing implementation.
71  CycleDataType *_pointer;
72 #endif // DO_PIPELINING
73 #endif // CPPPARSER
74 };
75 
76 #include "cycleDataStageWriter.I"
77 
78 #endif
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
CycleDataType * operator->()
This provides an indirect member access to the actual CycleData data.
This class is similar to CycleDataLockedReader, except it allows reading from a particular stage of t...
A thread; that is, a lightweight process.
Definition: thread.h:51
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...