Panda3D
cycleDataWriter.h
1 // Filename: cycleDataWriter.h
2 // Created by: drose (21Feb02)
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 CYCLEDATAWRITER_H
16 #define CYCLEDATAWRITER_H
17 
18 #include "pandabase.h"
19 
20 #include "cycleData.h"
21 #include "pipelineCycler.h"
22 #include "cycleDataLockedReader.h"
23 #include "thread.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : CycleDataWriter
27 // Description : This template class calls PipelineCycler::write() in
28 // the constructor and PipelineCycler::release_write() in
29 // the destructor. In the interim, it provides a
30 // transparent read-write access to the CycleData.
31 //
32 // It exists as a syntactic convenience to access the
33 // data in the CycleData. It also allows the whole
34 // system to compile down to nothing if
35 // DO_PIPELINING is not defined.
36 ////////////////////////////////////////////////////////////////////
37 template<class CycleDataType>
39 public:
40  // By hiding this template from interrogate, we improve compile-time
41  // speed and memory utilization.
42 #ifndef CPPPARSER
44  Thread *current_thread = Thread::get_current_thread());
45  INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, bool force_to_0,
46  Thread *current_thread = Thread::get_current_thread());
47  INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler,
48  CycleDataType *locked_cdata,
49  Thread *current_thread = Thread::get_current_thread());
50  INLINE CycleDataWriter(const CycleDataWriter<CycleDataType> &copy);
51  INLINE void operator = (const CycleDataWriter<CycleDataType> &copy);
52 
53  INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataLockedReader<CycleDataType> &take_from);
54  INLINE CycleDataWriter(PipelineCycler<CycleDataType> &cycler, CycleDataLockedReader<CycleDataType> &take_from, bool force_to_0);
55 
56  INLINE ~CycleDataWriter();
57 
58  INLINE CycleDataType *operator -> ();
59  INLINE const CycleDataType *operator -> () const;
60 
61  INLINE operator CycleDataType * ();
62 
63  INLINE Thread *get_current_thread() const;
64 
65 private:
66 #ifdef DO_PIPELINING
67  // This is the data stored for a real pipelining implementation.
69  Thread *_current_thread;
70  CycleDataType *_pointer;
71 #else // !DO_PIPELINING
72  // This is all we need for the trivial, do-nothing implementation.
73  CycleDataType *_pointer;
74 #endif // DO_PIPELINING
75 #endif // CPPPARSER
76 };
77 
78 #include "cycleDataWriter.I"
79 
80 #endif
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
CycleDataType * operator->()
This provides an indirect member access to the actual CycleData data.
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A thread; that is, a lightweight process.
Definition: thread.h:51