Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

VirtualBoxBaseProto Class Reference

#include <VirtualBoxBase.h>

Inheritance diagram for VirtualBoxBaseProto:

util::Lockable MediumBase VirtualBoxBase ImageMediumBase com::SupportErrorInfoDerived< MediumBase, HardDisk2, IHardDisk2 > HostUSBDevice VirtualBoxBaseNEXT VirtualBoxBaseWithChildren VirtualBoxBaseWithTypedChildren< C > VirtualBoxBaseWithTypedChildren< Snapshot > com::SupportErrorInfoDerived< ImageMediumBase, DVDImage2, IDVDImage2 > com::SupportErrorInfoDerived< ImageMediumBase, FloppyImage2, IFloppyImage2 > HardDisk2 HardDiskFormat ImageMediumBase OUSBDevice ProgressBase USBDeviceFilter VirtualBoxBaseWithChildrenNEXT VirtualBoxBaseWithTypedChildrenNEXT< C > VirtualBoxBaseWithTypedChildrenNEXT< HardDisk2 >

List of all members.


Detailed Description

Abstract base class for all component classes implementing COM interfaces of the VirtualBox COM library.

Declares functionality that should be available in all components.

Note that this class is always subclassed using the virtual keyword so that only one instance of its VTBL and data is present in each derived class even in case if VirtualBoxBaseProto appears more than once among base classes of the particular component as a result of multiple inheritance.

This makes it possible to have intermediate base classes used by several components that implement some common interface functionality but still let the final component classes choose what VirtualBoxBase variant it wants to use.

Among the basic functionality implemented by this class is the primary object state that indicates if the object is ready to serve the calls, and if not, what stage it is currently at. Here is the primary state diagram:

+-------------------------------------------------------+ | | | (InitFailed) -----------------------+ | | ^ | | v | v | [*] ---> NotReady ----> (InInit) -----> Ready -----> (InUninit) ----+ ^ | ^ | ^ | v | v | | Limited | (MayUninit) --> (WillUninit) | | | | +-------+ +-------+

The object is fully operational only when its state is Ready. The Limited state means that only some vital part of the object is operational, and it requires some sort of reinitialization to become fully operational. The NotReady state means the object is basically dead: it either was not yet initialized after creation at all, or was uninitialized and is waiting to be destroyed when the last reference to it is released. All other states are transitional.

The NotReady->InInit->Ready, NotReady->InInit->Limited and NotReady->InInit->InitFailed transition is done by the AutoInitSpan smart class.

The Limited->InInit->Ready, Limited->InInit->Limited and Limited->InInit->InitFailed transition is done by the AutoReinitSpan smart class.

The Ready->InUninit->NotReady, InitFailed->InUninit->NotReady and WillUninit->InUninit->NotReady transitions are done by the AutoUninitSpan smart class.

The Ready->MayUninit->Ready and Ready->MayUninit->WillUninit transitions are done by the AutoMayUninitSpan smart class.

In order to maintain the primary state integrity and declared functionality all subclasses must:

1) Use the above Auto*Span classes to perform state transitions. See the individual class descriptions for details.

2) All public methods of subclasses (i.e. all methods that can be called directly, not only from within other methods of the subclass) must have a standard prolog as described in the AutoCaller and AutoLimitedCaller documentation. Alternatively, they must use addCaller()/releaseCaller() directly (and therefore have both the prolog and the epilog), but this is not recommended.

Definition at line 604 of file VirtualBoxBase.h.


Public Types

typedef AutoCallerBase< false > AutoCaller
typedef AutoCallerBase< true > AutoLimitedCaller
enum  State {
  NotReady, Ready, InInit, InUninit,
  InitFailed, Limited, MayUninit, WillUninit
}

Public Member Functions

virtual HRESULT addCaller (State *aState=NULL, bool aLimited=false)
HRESULT addLimitedCaller (State *aState=NULL)
bool isWriteLockOnCurrentThread ()
virtual RWLockHandlelockHandle () const
virtual void releaseCaller ()
LockOps * rlock ()
virtual void uninit ()
LockOps * wlock ()

Protected Member Functions

WriteLockHandlestateLockHandle ()

Private Member Functions

void setState (State aState)

Private Attributes

unsigned mCallers
RTSEMEVENTMULTI mInitUninitSem
unsigned mInitUninitWaiters
RWLockHandlemObjectLock
State mState
RTTHREAD mStateChangeThread
WriteLockHandle mStateLock
RTSEMEVENT mZeroCallersSem

Classes

class  AutoCallerBase
class  AutoInitSpan
class  AutoMayUninitSpan
class  AutoReinitSpan
class  AutoUninitSpan

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index