refactor relation of BuffHandle and BufferDescriptor

they are now tightly coupled and assumed to
work together; there is no need to relay half
of BuffHandle's interface through BufferDescriptor
This commit is contained in:
Fischlurch 2011-11-25 18:20:01 +01:00
parent d6b069fbbd
commit ce25be6fa3
3 changed files with 17 additions and 27 deletions

View file

@ -211,18 +211,23 @@ namespace engine {
void void
BufferDescriptor::emit (BuffHandle const& handle) const BuffHandle::emit()
{ {
REQUIRE (verifyValidity()); REQUIRE (isValid());
provider_->emitBuffer(handle); descriptor_.provider_->emitBuffer(*this);
} }
void void
BufferDescriptor::release (BuffHandle const& handle) const BuffHandle::release()
{ {
REQUIRE (verifyValidity()); if (pBuffer_)
provider_->releaseBuffer(handle); {
REQUIRE (isValid());
descriptor_.provider_->releaseBuffer(*this);
pBuffer_ = 0;
}
ENSURE (!isValid());
} }

View file

@ -81,6 +81,7 @@ namespace engine {
*/ */
class BufferDescriptor class BufferDescriptor
{ {
protected:
BufferProvider* provider_; BufferProvider* provider_;
HashVal subClassification_; HashVal subClassification_;
@ -90,6 +91,7 @@ namespace engine {
{ } { }
friend class BufferProvider; friend class BufferProvider;
friend class BuffHandle;
public: public:
// using standard copy operations // using standard copy operations
@ -97,9 +99,6 @@ namespace engine {
bool verifyValidity() const; bool verifyValidity() const;
size_t determineBufferSize() const; size_t determineBufferSize() const;
void emit (BuffHandle const&) const;
void release (BuffHandle const&) const;
operator HashVal() const { return subClassification_; } operator HashVal() const { return subClassification_; }
}; };
@ -136,23 +135,8 @@ namespace engine {
void void emit();
emit() void release();
{
REQUIRE (pBuffer_);
descriptor_.emit (*this);
}
void release()
{
if (pBuffer_)
{
REQUIRE (isValid());
descriptor_.release (*this);
pBuffer_ = 0;
}
ENSURE (!isValid());
}
template<typename BU> template<typename BU>
@ -181,7 +165,7 @@ namespace engine {
HashVal HashVal
entryID() const entryID() const
{ {
return descriptor_; return HashVal(descriptor_);
} }
size_t size_t

View file

@ -70,6 +70,7 @@ namespace engine {
PBu inBuff; PBu inBuff;
}; };
class BufferDescriptor;
/** Obsolete, to be rewritten /////TICKET #826 */ /** Obsolete, to be rewritten /////TICKET #826 */
class BuffTableStorage class BuffTableStorage