EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RefPtr< X > Class Template Reference

Reference-counting-based smart pointer. More...

#include "RefPtr.h"

Inheritance diagram for RefPtr< X >:
Collaboration diagram for RefPtr< X >:

Public Member Functions

 RefPtr (X *p=nullptr)
 Primary constructor. More...
 
 RefPtr (const RefPtr &oth)
 Copy constructor. More...
 
template<typename Y >
 RefPtr (const RefPtr< Y > &oth)
 Casting copy constructor. More...
 
virtual ~RefPtr ()
 Destructor, releases reference. More...
 
RefPtroperator= (const RefPtr &oth)
 Copy operator. More...
 
template<typename Y >
RefPtroperator= (const RefPtr< Y > &oth)
 Casting copy operator. More...
 
X * get () const
 
 operator bool () const
 
X & operator* () const
 
X * operator-> () const
 
template<typename Y >
bool operator== (const RefPtr< Y > &oth) const
 Compares two references. More...
 

Static Public Member Functions

template<typename Y >
static RefPtr StaticCast (const RefPtr< Y > &oth)
 Acts as static_cast from one RefPtr to another. More...
 

Protected Attributes

X * mPtr
 The pointer to the reference-counted object. More...
 

Detailed Description

template<typename X>
class RefPtr< X >

Reference-counting-based smart pointer.

This smart pointer cares about acquiring/releasing reference of the stored object.

NOTE: this class DOES increment count on creation (whereas RefObject does not)

Author
Bloody.Rabbit

Definition at line 133 of file RefPtr.h.

Constructor & Destructor Documentation

template<typename X>
RefPtr< X >::RefPtr ( X *  p = nullptr)
inlineexplicit

Primary constructor.

Parameters
[in]pPointer to object to be referenced.

Definition at line 141 of file RefPtr.h.

Referenced by RefPtr< Character >::StaticCast().

142  : mPtr( p )
143  {
144  if (*this)
145  (*this)->IncRef();
146  }
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245

Here is the caller graph for this function:

template<typename X>
RefPtr< X >::RefPtr ( const RefPtr< X > &  oth)
inline

Copy constructor.

Parameters
[in]othObject to copy the reference from.

Definition at line 152 of file RefPtr.h.

153  : mPtr( oth.get() )
154  {
155  if (*this)
156  (*this)->IncRef();
157  }
X * get() const
Definition: RefPtr.h:213
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
template<typename Y >
RefPtr< X >::RefPtr ( const RefPtr< Y > &  oth)
inline

Casting copy constructor.

Parameters
[in]othObject to copy the reference from.

Definition at line 164 of file RefPtr.h.

165  : mPtr( oth.get() )
166  {
167  if (*this)
168  (*this)->IncRef();
169  }
X * get() const
Definition: RefPtr.h:213
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
virtual RefPtr< X >::~RefPtr ( )
inlinevirtual

Destructor, releases reference.

Definition at line 174 of file RefPtr.h.

175  {
176  if (*this)
177  (*this)->DecRef();
178  }

Member Function Documentation

template<typename X>
X* RefPtr< X >::get ( ) const
inline
Returns
Stored reference.

Definition at line 213 of file RefPtr.h.

Referenced by Character::_Load(), ActiveModule::Activate(), RamMethods::ActivityCheck(), CorporationDB::AddCorporation(), StationOffice::AddItem(), StructureItem::AddItem(), Inventory::AddItem(), ShipItem::AddItem(), Character::AddItem(), ShipItem::AddItemByFlag(), FleetService::AddMember(), AnomalyMgr::AddSignal(), TurretModule::ApplyDamage(), SystemEntity::ApplyDamage(), ActiveModule::ApplyEffect(), SystemManager::BootSystem(), DynamicEntityFactory::BuildEntity(), ReprocessingServiceBound::CalcReprocessingEfficiency(), MiningLaser::CanActivate(), TradeBound::CancelTrade(), Agent::CanUseAgent(), Client::CheckShipRef(), Command_dogma(), Command_giveallskills(), Command_giveskill(), Command_inventory(), Command_shipinventory(), Command_status(), Command_tr(), Client::ContainsTypeQty(), AllianceDB::CreateAlliance(), ShipService::CreateBoundObject(), FleetService::CreateFleet(), ProbeItem::Delete(), InventoryItem::Delete(), GenericModule::DeOverload(), Client::DockToStation(), InventoryItem::Donate(), DroneSE::DroneSE(), Prospector::DropSalvage(), Client::Eject(), MarketMgr::ExecuteBuyOrder(), MarketMgr::ExecuteSellOrder(), EntityList::FindClientByName(), FleetService::GetBoosterData(), Client::GetCharID(), Client::GetCorpTaxRate(), RepairService::GetDamageReports(), ItemFactory::GetInventoryFromId(), ItemFactory::GetItemContainer(), ItemFactory::GetItemContainerInventory(), ModuleManager::GetModule(), Client::GetName(), ShipSE::GetPilot(), ReprocessingServiceBound::GetQuote(), Character::GetSkill(), Character::GetSkillLevel(), ShipSE::HasPilot(), Character::HasSkillTrainedToLevel(), Character::InjectSkillIntoBrain(), GenericModule::IsLoaded(), Sentry::Killed(), CustomsSE::Killed(), NPC::Killed(), DroneSE::Killed(), StructureSE::Killed(), ShipSE::LaunchDrone(), FleetService::LeaveFleet(), BeltMgr::Load(), TurretModule::LoadCharge(), MiningLaser::LoadCharge(), ActiveModule::LoadCharge(), ModuleManager::LoadCharge(), ShipItem::LoadCharge(), ShipItem::LoadChargesToBank(), Inventory::LoadContents(), Character::LoadPausedSkillQueue(), ProbeSE::MakeSlimItem(), SpawnMgr::MakeSpawn(), InventoryItem::Merge(), InventoryItem::MergeTypesInCargo(), Missile::Missile(), InventoryItem::Move(), Client::MoveItem(), InventoryBound::MoveItems(), ShipItem::MoveModuleSlot(), Client::MoveToLocation(), NPC::NPC(), NPCAIMgr::NPCAIMgr(), GenericModule::Offline(), GenericModule::Online(), RefPtr< Character >::operator=(), RefPtr< Character >::operator==(), GenericModule::Overload(), Client::PickAlternateShip(), Colony::PlanetXfer(), ProbeSE::ProbeSE(), ActiveModule::Process(), ShipSE::Process(), MiningLaser::ProcessCycle(), GenericModule::ProcessEffects(), ShipItem::ProcessShipEffects(), ProbeSE::ProcessTic(), Prospector::Prospector(), InventoryItem::Relocate(), StationOffice::RemoveItem(), StructureItem::RemoveItem(), Inventory::RemoveItem(), CargoContainer::RemoveItem(), ShipItem::RemoveItem(), WreckContainer::RemoveItem(), FleetService::RemoveMember(), Client::RemoveMissionItem(), ShipItem::RemoveRig(), ActiveModule::ReprocessCharge(), ReprocessingServiceBound::ReprocessingServiceBound(), Client::ResetAfterPopped(), Client::SelectCharacter(), Client::SelfChatMessage(), Client::SendSessionChange(), ProbeSE::SendSlimChange(), Client::SetPodItem(), ActiveModule::ShowEffect(), Character::SkillQueueLoop(), ModuleItem::Spawn(), Skill::Spawn(), InventoryItem::Spawn(), BeltMgr::SpawnAsteroid(), ItemFactory::SpawnAsteroid(), ItemFactory::SpawnCargoContainer(), ItemFactory::SpawnItem(), InventoryItem::SpawnItem(), ItemFactory::SpawnModule(), ItemFactory::SpawnOffice(), ItemFactory::SpawnProbe(), ItemFactory::SpawnShip(), ItemFactory::SpawnSkill(), ItemFactory::SpawnStructure(), ItemFactory::SpawnWreckContainer(), Blueprint::SplitBlueprint(), RefPtr< Character >::StaticCast(), SystemEntity::SystemEntity(), TargetManager::TimeToLock(), InventoryItem::ToVirtual(), TradeService::TransferContainerContents(), ActiveModule::UnloadCharge(), ModuleManager::UnloadCharge(), Prospector::Update(), FleetService::UpdateMember(), Client::UpdateSession(), Agent::UpdateStandings(), and Client::~Client().

213 { return mPtr; }
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
RefPtr< X >::operator bool ( ) const
inline
Returns
True if stores a reference, false otherwise.

Definition at line 218 of file RefPtr.h.

218 { return ( mPtr != nullptr ); }
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
X& RefPtr< X >::operator* ( ) const
inline

Definition at line 220 of file RefPtr.h.

220 { assert( *this ); return *mPtr; }
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
X* RefPtr< X >::operator-> ( ) const
inline

Definition at line 221 of file RefPtr.h.

221 { assert( *this ); return mPtr; }
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
RefPtr& RefPtr< X >::operator= ( const RefPtr< X > &  oth)
inline

Copy operator.

Parameters
[in]othObject to copy the reference from.

Definition at line 185 of file RefPtr.h.

186  {
187  if (*this)
188  (*this)->DecRef();
189  mPtr = oth.get();
190  if (*this)
191  (*this)->IncRef();
192  return *this;
193  }
X * get() const
Definition: RefPtr.h:213
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
template<typename Y >
RefPtr& RefPtr< X >::operator= ( const RefPtr< Y > &  oth)
inline

Casting copy operator.

Parameters
[in]othObject to copy the reference from.

Definition at line 200 of file RefPtr.h.

201  {
202  if (*this)
203  (*this)->DecRef();
204  mPtr = oth.get();
205  if (*this)
206  (*this)->IncRef();
207  return *this;
208  }
X * get() const
Definition: RefPtr.h:213
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
template<typename Y >
bool RefPtr< X >::operator== ( const RefPtr< Y > &  oth) const
inline

Compares two references.

Returns
True if both references are of same object, false if not.

Definition at line 229 of file RefPtr.h.

230  {
231  return ( mPtr == oth.get() );
232  }
X * get() const
Definition: RefPtr.h:213
X * mPtr
The pointer to the reference-counted object.
Definition: RefPtr.h:245
template<typename X>
template<typename Y >
static RefPtr RefPtr< X >::StaticCast ( const RefPtr< Y > &  oth)
inlinestatic

Member Data Documentation

template<typename X>
X* RefPtr< X >::mPtr
protected

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