ClosableObject Class Reference

ClosableObject is a common base for all classes which require a close() method to be called before destruction (e.g. More...

#include <ClosableObject.h>

Inheritance diagram for ClosableObject:

ByteStream Cache CheckpointThread Database ExecStream ExecStreamGraph FlatFileBuffer SegBufferReader SegBufferWriter Segment SegPageBackupRestoreDevice SegStreamAllocation List of all members.

Public Member Functions

virtual ~ClosableObject ()
 Destructor.
bool isClosed () const
 
Returns:
whether the object has been closed

void close ()
 Closes this object, releasing any unallocated resources.

Protected Member Functions

virtual void closeImpl ()=0
 Must be implemented by derived class to release any resources.
 ClosableObject ()

Protected Attributes

bool needsClose

Detailed Description

ClosableObject is a common base for all classes which require a close() method to be called before destruction (e.g.

to avoid the error of calling virtual methods from a base class destructor). Deriving from ClosableObject makes it easier to instantiate a shared_ptr which takes care of automatic close on destruction (see ClosableObjectDestructor).

Definition at line 36 of file ClosableObject.h.


Constructor & Destructor Documentation

ClosableObject::ClosableObject (  )  [explicit, protected]

Definition at line 29 of file ClosableObject.cpp.

References needsClose.

00030 {
00031     needsClose = true;
00032 }

ClosableObject::~ClosableObject (  )  [virtual]

Destructor.

An assertion violation will result if the object has not yet been closed.

Definition at line 34 of file ClosableObject.cpp.

References needsClose.

00035 {
00036     assert(!needsClose);
00037 }


Member Function Documentation

virtual void ClosableObject::closeImpl (  )  [protected, pure virtual]

Must be implemented by derived class to release any resources.

Implemented in CacheImpl< PageT, VictimPolicyT >, ByteArrayInputStream, ByteArrayOutputStream, ByteOutputStream, CheckpointThread, Database, BarrierExecStream, DoubleBufferExecStream, ExecStream, ExecStreamGraphImpl, MockResourceExecStream, ReshapeExecStream, ScratchBufferExecStream, SegBufferExecStream, SegBufferReader, SegBufferReaderExecStream, SegBufferWriter, SegBufferWriterExecStream, JavaSinkExecStream, JavaTransformExecStream, FlatFileBuffer, FlatFileExecStreamImpl, BTreeExecStream, BTreeInsertExecStream, BTreePrefetchSearchExecStream, BTreeReadExecStream, BTreeSearchExecStream, FtrsTableWriterExecStream, LhxAggExecStream, LhxJoinExecStream, LbmBitOpExecStream, LbmChopperExecStream, LbmGeneratorExecStream, LbmIntersectExecStream, LbmMinusExecStream, LbmSplicerExecStream, LbmUnionExecStream, LcsClusterAppendExecStream, LcsRowScanBaseExecStream, LcsRowScanExecStream, DelegatingSegment, DynamicDelegatingSegment, ScratchSegment, SegInputStream, Segment, SegOutputStream, SegPageBackupRestoreDevice, SegStream, SegStreamAllocation, SpillOutputStream, and ExternalSortExecStreamImpl.

Referenced by close().

bool ClosableObject::isClosed (  )  const [inline]

Returns:
whether the object has been closed

Definition at line 58 of file ClosableObject.h.

00059     {
00060         return !needsClose;
00061     }

void ClosableObject::close (  ) 

Closes this object, releasing any unallocated resources.

Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.

Definition at line 39 of file ClosableObject.cpp.

References closeImpl(), and needsClose.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().

00040 {
00041     if (!needsClose) {
00042         return;
00043     }
00044     needsClose = false;
00045     closeImpl();
00046 }


Member Data Documentation

bool ClosableObject::needsClose [protected]

Definition at line 44 of file ClosableObject.h.

Referenced by SegStreamAllocation::beginWrite(), ExecStreamGraphImpl::clear(), ClosableObject(), close(), FlatFileBuffer::open(), ExecStreamGraphImpl::open(), ExecStream::open(), and ~ClosableObject().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:28 2009 for Fennel by  doxygen 1.5.1