Panda3D

cycleDataReader.h
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file cycleDataReader.h
10 * @author drose
11 * @date 2002-02-21
12 */
13
14 #ifndef CYCLEDATAREADER_H
15 #define CYCLEDATAREADER_H
16
17 #include "pandabase.h"
18
19 #include "cycleData.h"
20 #include "pipelineCycler.h"
21 #include "thread.h"
22
23 /**
24 * This template class calls PipelineCycler::read_unlocked(), and then
25 * provides a transparent read-only access to the CycleData. It is used to
26 * access the data quickly, without holding a lock, for a thread that does not
27 * intend to modify the data and write it back out. For cases where the data
28 * might be subsequently modified, you should use CycleDataLockedReader.
29 *
30 * It exists as a syntactic convenience to access the data in the CycleData.
31 * It also allows the whole system to compile down to nothing if DO_PIPELINING
32 * is not defined.
33 */
34 template<class CycleDataType>
35 class CycleDataReader {
36 public:
37 // By hiding this template from interrogate, we improve compile-time speed
38 // and memory utilization.
39 #ifndef CPPPARSER
40 INLINE CycleDataReader(const PipelineCycler<CycleDataType> &cycler,
41 Thread *current_thread = Thread::get_current_thread());
42 INLINE CycleDataReader(const CycleDataReader<CycleDataType> &copy);
43 INLINE void operator = (const CycleDataReader<CycleDataType> &copy);
44
45 INLINE ~CycleDataReader();
46
47 INLINE const CycleDataType *operator -> () const;
48 INLINE operator const CycleDataType * () const;
49 INLINE const CycleDataType *p() const;
50
51 INLINE Thread *get_current_thread() const;
52
53 private:
54 #ifdef DO_PIPELINING
55 // This is the data stored for a real pipelining implementation.
56 const PipelineCycler<CycleDataType> *_cycler;
57 Thread *_current_thread;
58 const CycleDataType *_pointer;
59 CycleDataType *_write_pointer;
60 #else // !DO_PIPELINING
61 // This is all we need for the trivial, do-nothing implementation.
62 const CycleDataType *_pointer;
63 #endif // DO_PIPELINING
64 #endif // CPPPARSER
65 };
66
67 #include "cycleDataReader.I"
68
69 #endif
CycleDataReader
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
Definition: cycleDataReader.h:35
CycleDataReader::get_current_thread
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
Definition: cycleDataReader.I:178
CycleDataReader::operator->
const CycleDataType * operator->() const
This provides an indirect member access to the actual CycleData data.
Definition: cycleDataReader.I:148
CycleDataReader::p
const CycleDataType * p() const
This allows the CycleDataReader to be passed to any function that expects a const CycleDataType point...
Definition: cycleDataReader.I:168
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
Thread::get_current_thread
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition: thread.h:109
cycleDataReader.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pipelineCycler.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PipelineCycler
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
Definition: pipelineCycler.h:46
thread.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.