mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
trivialize CycleDataReader and CycleDataWriter
This commit is contained in:
parent
54f300f612
commit
ddff6234ba
@ -16,9 +16,12 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef DO_PIPELINING
|
||||
// This is the implementation for full support of pipelining (as well
|
||||
// as the sanity-check only implementation).
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Constructor
|
||||
// Function: CycleDataReader::Constructor (full)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -32,7 +35,7 @@ CycleDataReader(const PipelineCycler<CycleDataType> &cycler) :
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Copy Constructor
|
||||
// Function: CycleDataReader::Copy Constructor (full)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -51,7 +54,7 @@ CycleDataReader(const CycleDataReader<CycleDataType> ©) :
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Destructor
|
||||
// Function: CycleDataReader::Destructor (full)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -69,7 +72,7 @@ INLINE CycleDataReader<CycleDataType>::
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::operator ->
|
||||
// Function: CycleDataReader::operator -> (full)
|
||||
// Access: Public
|
||||
// Description: This provides an indirect member access to the actual
|
||||
// CycleData data.
|
||||
@ -82,7 +85,7 @@ operator -> () const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Typecast pointer
|
||||
// Function: CycleDataReader::Typecast pointer (full)
|
||||
// Access: Public
|
||||
// Description: This allows the CycleDataReader to be passed to any
|
||||
// function that expects a const CycleDataType pointer.
|
||||
@ -95,7 +98,7 @@ operator const CycleDataType * () const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::take_pointer
|
||||
// Function: CycleDataReader::take_pointer (full)
|
||||
// Access: Public
|
||||
// Description: This is intended to be called only from
|
||||
// CycleDataWriter when it elevates the pointer from
|
||||
@ -115,7 +118,7 @@ take_pointer() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::elevate_to_write
|
||||
// Function: CycleDataReader::elevate_to_write (full)
|
||||
// Access: Public
|
||||
// Description: Call this to permanently elevate the readable pointer
|
||||
// to a writable pointer. This returns a writable
|
||||
@ -132,3 +135,95 @@ elevate_to_write(PipelineCycler<CycleDataType> &cycler) {
|
||||
}
|
||||
return _write_pointer;
|
||||
}
|
||||
|
||||
#else // !DO_PIPELINING
|
||||
// This is the trivial, do-nothing implementation.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Constructor (trivial)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataReader<CycleDataType>::
|
||||
CycleDataReader(const PipelineCycler<CycleDataType> &cycler) {
|
||||
_pointer = cycler.read();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Copy Constructor (trivial)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataReader<CycleDataType>::
|
||||
CycleDataReader(const CycleDataReader<CycleDataType> ©) :
|
||||
_pointer(copy._pointer)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Destructor (trivial)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataReader<CycleDataType>::
|
||||
~CycleDataReader() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::operator -> (trivial)
|
||||
// Access: Public
|
||||
// Description: This provides an indirect member access to the actual
|
||||
// CycleData data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE const CycleDataType *CycleDataReader<CycleDataType>::
|
||||
operator -> () const {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::Typecast pointer (trivial)
|
||||
// Access: Public
|
||||
// Description: This allows the CycleDataReader to be passed to any
|
||||
// function that expects a const CycleDataType pointer.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataReader<CycleDataType>::
|
||||
operator const CycleDataType * () const {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::take_pointer (trivial)
|
||||
// Access: Public
|
||||
// Description: This is intended to be called only from
|
||||
// CycleDataWriter when it elevates the pointer from
|
||||
// read to write status. This function returns the
|
||||
// reader's pointer and relinquishes ownership of the
|
||||
// pointer, rendering the reader invalid for future
|
||||
// reads.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE const CycleDataType *CycleDataReader<CycleDataType>::
|
||||
take_pointer() {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataReader::elevate_to_write (trivial)
|
||||
// Access: Public
|
||||
// Description: Call this to permanently elevate the readable pointer
|
||||
// to a writable pointer. This returns a writable
|
||||
// pointer; subsequent calls to the same function will
|
||||
// trivially return the same writable pointer.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataType *CycleDataReader<CycleDataType>::
|
||||
elevate_to_write(PipelineCycler<CycleDataType> &cycler) {
|
||||
return (CycleDataType *)_pointer;
|
||||
}
|
||||
|
||||
#endif // DO_PIPELINING
|
||||
|
@ -51,9 +51,15 @@ public:
|
||||
INLINE CycleDataType *elevate_to_write(PipelineCycler<CycleDataType> &cycler);
|
||||
|
||||
private:
|
||||
#ifdef DO_PIPELINING
|
||||
// This is the data stored for a real pipelining implementation.
|
||||
const PipelineCycler<CycleDataType> &_cycler;
|
||||
const CycleDataType *_pointer;
|
||||
CycleDataType *_write_pointer;
|
||||
#else // !DO_PIPELINING
|
||||
// This is all we need for the trivial, do-nothing implementation.
|
||||
const CycleDataType *_pointer;
|
||||
#endif // DO_PIPELINING
|
||||
};
|
||||
|
||||
#include "cycleDataReader.I"
|
||||
|
@ -16,9 +16,12 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef DO_PIPELINING
|
||||
// This is the implementation for full support of pipelining (as well
|
||||
// as the sanity-check only implementation).
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Constructor
|
||||
// Function: CycleDataWriter::Constructor (full)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -31,7 +34,7 @@ CycleDataWriter(PipelineCycler<CycleDataType> &cycler) :
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Constructor
|
||||
// Function: CycleDataWriter::Constructor (full)
|
||||
// Access: Public
|
||||
// Description: This is a lot like a copy constructor, in that the
|
||||
// new CycleDataWriter object gets a handle to the same
|
||||
@ -51,7 +54,7 @@ CycleDataWriter(PipelineCycler<CycleDataType> &cycler,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Constructor
|
||||
// Function: CycleDataWriter::Constructor (full)
|
||||
// Access: Public
|
||||
// Description: This flavor of the constructor elevates the pointer
|
||||
// from the CycleDataReader from a read to a write
|
||||
@ -67,7 +70,7 @@ CycleDataWriter(PipelineCycler<CycleDataType> &cycler,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Destructor
|
||||
// Function: CycleDataWriter::Destructor (full)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -80,7 +83,7 @@ INLINE CycleDataWriter<CycleDataType>::
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::operator ->
|
||||
// Function: CycleDataWriter::operator -> (full)
|
||||
// Access: Public
|
||||
// Description: This provides an indirect member access to the actual
|
||||
// CycleData data.
|
||||
@ -93,7 +96,7 @@ operator -> () {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::operator ->
|
||||
// Function: CycleDataWriter::operator -> (full)
|
||||
// Access: Public
|
||||
// Description: This provides an indirect member access to the actual
|
||||
// CycleData data.
|
||||
@ -106,7 +109,7 @@ operator -> () const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Typecast pointer
|
||||
// Function: CycleDataWriter::Typecast pointer (full)
|
||||
// Access: Public
|
||||
// Description: This allows the CycleDataWriter to be passed to any
|
||||
// function that expects a CycleDataType pointer.
|
||||
@ -117,3 +120,97 @@ operator CycleDataType * () {
|
||||
nassertr(_pointer != (CycleDataType *)NULL, _cycler.cheat());
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
#else // !DO_PIPELINING
|
||||
// This is the trivial, do-nothing implementation.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Constructor (trivial)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataWriter<CycleDataType>::
|
||||
CycleDataWriter(PipelineCycler<CycleDataType> &cycler) {
|
||||
_pointer = cycler.write();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Constructor (trivial)
|
||||
// Access: Public
|
||||
// Description: This is a lot like a copy constructor, in that the
|
||||
// new CycleDataWriter object gets a handle to the same
|
||||
// pointer held by the old CycleDataWriter object.
|
||||
// However, since only one write pointer may be active
|
||||
// at a time, this invalidates the old object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataWriter<CycleDataType>::
|
||||
CycleDataWriter(PipelineCycler<CycleDataType> &,
|
||||
CycleDataWriter<CycleDataType> &take_from) :
|
||||
_pointer(take_from.take_pointer())
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Constructor (trivial)
|
||||
// Access: Public
|
||||
// Description: This flavor of the constructor elevates the pointer
|
||||
// from the CycleDataReader from a read to a write
|
||||
// pointer (and invalidates the reader).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataWriter<CycleDataType>::
|
||||
CycleDataWriter(PipelineCycler<CycleDataType> &,
|
||||
CycleDataReader<CycleDataType> &take_from) :
|
||||
_pointer((CycleDataType *)take_from.take_pointer())
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Destructor (trivial)
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataWriter<CycleDataType>::
|
||||
~CycleDataWriter() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::operator -> (trivial)
|
||||
// Access: Public
|
||||
// Description: This provides an indirect member access to the actual
|
||||
// CycleData data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataType *CycleDataWriter<CycleDataType>::
|
||||
operator -> () {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::operator -> (trivial)
|
||||
// Access: Public
|
||||
// Description: This provides an indirect member access to the actual
|
||||
// CycleData data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE const CycleDataType *CycleDataWriter<CycleDataType>::
|
||||
operator -> () const {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CycleDataWriter::Typecast pointer (trivial)
|
||||
// Access: Public
|
||||
// Description: This allows the CycleDataWriter to be passed to any
|
||||
// function that expects a CycleDataType pointer.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class CycleDataType>
|
||||
INLINE CycleDataWriter<CycleDataType>::
|
||||
operator CycleDataType * () {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
#endif // DO_PIPELINING
|
||||
|
@ -51,8 +51,14 @@ public:
|
||||
INLINE operator CycleDataType * ();
|
||||
|
||||
private:
|
||||
#ifdef DO_PIPELINING
|
||||
// This is the data stored for a real pipelining implementation.
|
||||
PipelineCycler<CycleDataType> &_cycler;
|
||||
CycleDataType *_pointer;
|
||||
#else // !DO_PIPELINING
|
||||
// This is all we need for the trivial, do-nothing implementation.
|
||||
CycleDataType *_pointer;
|
||||
#endif // DO_PIPELINING
|
||||
};
|
||||
|
||||
#include "cycleDataWriter.I"
|
||||
|
Loading…
x
Reference in New Issue
Block a user