ReferenceCountable Class Reference

Back to the index.

Public Member Functions | Friends | List of all members
ReferenceCountable Class Reference

Base class for reference countable objects. More...

#include <refcount_ptr.h>

Inheritance diagram for ReferenceCountable:
Command Component FileLoaderImpl UI AddComponentCommand BackwardStepCommand CloseCommand ContinueBackwardsCommand ContinueCommand CopyComponentCommand HelpCommand ListComponentsCommand LoadCommand MoveComponentCommand PauseCommand QuitCommand RemoveComponentCommand ResetCommand SaveCommand StatusCommand StepCommand VersionCommand CacheComponent CPUComponent DummyComponent MachineComponent MainbusComponent MemoryMappedComponent RootComponent FileLoader_aout FileLoader_bout FileLoader_ELF FileLoader_raw ConsoleUI NullUI

Public Member Functions

 ReferenceCountable ()
 Default constructor, which initializes the reference count to zero. More...
 
 ~ReferenceCountable ()
 

Friends

template<class T >
class refcount_ptr
 

Detailed Description

Base class for reference countable objects.

Usage:

refcount_ptr<MyClass> myPtr = new MyClass(...);

where MyClass should have increase_refcount() and decrease_refcount(), e.g.

class MyClass : public ReferenceCountable
{
     ...
}

Note: Although MyClass objects can be created using the following syntax:

MyClass myobject(...);

this causes the object to have a reference count of 0. That is, the address should not be taken of such an object and exposed to the outside.

Implementation note: The counter itself is mutable, and the increase_refcount() and decrease_refcount() member functions are marked as const. This is because const objects also need to be properly reference counted.

Definition at line 62 of file refcount_ptr.h.

Constructor & Destructor Documentation

◆ ReferenceCountable()

ReferenceCountable::ReferenceCountable ( )
inline

Default constructor, which initializes the reference count to zero.

Definition at line 69 of file refcount_ptr.h.

◆ ~ReferenceCountable()

ReferenceCountable::~ReferenceCountable ( )
inline

Definition at line 74 of file refcount_ptr.h.

Friends And Related Function Documentation

◆ refcount_ptr

template<class T >
friend class refcount_ptr
friend

Definition at line 83 of file refcount_ptr.h.


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

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17