WSF
WsfComponentList Class Reference

#include <WsfComponentList.hpp>

Inheritance diagram for WsfComponentList:

Classes

class  RoleRange
class  RoleIterator

Public Types

using NameAndComponent = std::pair<WsfStringId, WsfComponent*>
using ComponentList = std::vector<NameAndComponent>

Public Member Functions

 WsfComponentList ()
 WsfComponentList (const WsfComponentList &aSrc)
 WsfComponentList (WsfComponentList &&)=default
virtual ~WsfComponentList ()
WsfComponentListoperator= (const WsfComponentList &aRhs)
WsfComponentListoperator= (WsfComponentList &&)
bool HasComponents () const
 Returns true if the component list has at least one component.
void DeleteAllComponents ()
 Delete all of the components maintained by the list.
bool DeleteComponent (WsfStringId aName, int aRole)
unsigned int GetComponentCount (int aRole) const

Function templates to make using a component list simpler and more type-safe.

These methods can be used if the template type registers its component role using the WSF_DECLARE_COMPONENT_ROLE_TYPE macro. It is a compile-time error to instantiate these templates with a type that has not registered its component role. The header file for the class must be available whenever these classes are used.

ComponentList mComponentsByName
template<class T>
bool DeleteComponent (WsfStringId aName)
template<class T>
bool DeleteComponent ()
template<class T>
T * GetComponent () const
template<class T>
T * GetComponent (WsfStringId aName) const
template<class T>
unsigned int GetComponentCount () const
template<class T>
T * GetComponentEntry (unsigned int aEntry) const
template<class T>
bool FindByRole (T *&aPtr) const
template<typename T>
RoleRange< T > GetComponentRange ()
virtual void ComponentAdded (WsfComponent *aComponentPtr)
virtual void ComponentDeleted (WsfComponent *aComponentPtr)
bool AddComponentP (WsfComponent *aComponentPtr, bool aDoNotify)
void CopyAllP (const WsfComponentList &aSrc, bool aDoNotify)
 Base class implementation of copying a component list.
void DeleteAllP (bool aDoNotify)
 Base class implementation of deleting all components in the list.
bool DeleteComponentP (WsfStringId aName, int aRole, bool aDoNotify)
WsfComponentFindComponentP (WsfStringId aName, int aRole) const
WsfComponentFindComponentP (WsfStringId aName) const
WsfComponentFindComponentByRoleP (int aRole) const
WsfComponentGetComponentEntryByRoleP (int aRole, unsigned int aEntry) const
bool RemoveComponentP (WsfStringId aName, int aRole, bool aDelete, bool aDoNotify)

Detailed Description

The non-templated base class for a component list. This is provided so there is less code duplication. Much of the list manipulation can be done in a generic matter.

Member Typedef Documentation

◆ ComponentList

◆ NameAndComponent

Constructor & Destructor Documentation

◆ WsfComponentList() [1/3]

◆ WsfComponentList() [2/3]

WsfComponentList::WsfComponentList ( const WsfComponentList & aSrc)

References CopyAllP(), and WsfComponentList().

◆ WsfComponentList() [3/3]

WsfComponentList::WsfComponentList ( WsfComponentList && )
default

References operator=(), and WsfComponentList().

◆ ~WsfComponentList()

WsfComponentList::~WsfComponentList ( )
virtual

References DeleteAllP().

Member Function Documentation

◆ AddComponentP()

bool WsfComponentList::AddComponentP ( WsfComponent * aComponentPtr,
bool aDoNotify )
protected

Add a component to the component list. Attempts to add a component to the list of components. The names of components must be unique within their role.

Parameters
aComponentPtrThe component to be added.
aDoNotifyIf true, invoke the ComponentAdded() virtual method to inform the derived class that the component was added.
Returns
true if successful, false if a component of the same name and primary role already exists. If true then this class assumes ownership of the component. If false the caller retains ownership and is responsible for deleting the object.

References ComponentAdded(), WsfComponent::GetComponentName(), WsfComponent::GetComponentRoles(), and mComponentsByName.

Referenced by WsfComponentListT< WsfComponentT< Comm > >::AddComponent(), and CopyAllP().

◆ ComponentAdded()

void WsfComponentList::ComponentAdded ( WsfComponent * aComponentPtr)
protectedvirtual

A virtual method that allows a derived class to know when a entry is being added to the list.

Note
This method is not invoked during copy construction because the inheriting class is in an indeterminate state.

Reimplemented in WsfPlatform.

Referenced by AddComponentP(), and WsfComponentListT< WsfComponentT< Comm > >::SetParentOfComponents().

◆ ComponentDeleted()

void WsfComponentList::ComponentDeleted ( WsfComponent * aComponentPtr)
protectedvirtual

A virtual method that allows a derived class to know when a entry is being delete from the list.

Note
This method is not invoked during destruction because the inheriting class is in an indeterminate state.

Reimplemented in WsfPlatform.

Referenced by DeleteAllP(), and RemoveComponentP().

◆ CopyAllP()

void WsfComponentList::CopyAllP ( const WsfComponentList & aSrc,
bool aDoNotify )
protected

◆ DeleteAllComponents()

void WsfComponentList::DeleteAllComponents ( )

Delete all of the components maintained by the list.

References DeleteAllP().

Referenced by WsfPlatform::~WsfPlatform().

◆ DeleteAllP()

void WsfComponentList::DeleteAllP ( bool aDoNotify)
protected

Base class implementation of deleting all components in the list.

References ComponentDeleted(), and mComponentsByName.

Referenced by DeleteAllComponents(), operator=(), operator=(), WsfComponentListT< WsfComponentT< Comm > >::operator=(), and ~WsfComponentList().

◆ DeleteComponent() [1/3]

template<class T>
bool WsfComponentList::DeleteComponent ( )
inline

Delete a component with the role implied by the template argument. This is typically used to delete components that are uniquely identified by role. Typical usage:

platformPtr->DeleteComponent<WsfComm>();
WsfPlatform * platformPtr
Definition WsfScriptTrackClass.cpp:507
Returns
true if the component was deleted or false if the component could not be found.
Note
If used for a component class that is not uniquely identified only by role, the first component with the specified role will be deleted.

References DeleteComponent(), and FindComponentByRoleP().

Referenced by WsfPlatform::SetMover().

◆ DeleteComponent() [2/3]

template<class T>
bool WsfComponentList::DeleteComponent ( WsfStringId aName)
inline

Delete a component with the specified name and role implied by the template argument. Typical usage:

platformPtr->DeleteComponent<WsfSensor>(name);
Definition WsfSensor.hpp:92
Parameters
aNameThe name of the component to be deleted.
Returns
true if the component was deleted or false if the component could not be found.

References DeleteComponent().

◆ DeleteComponent() [3/3]

bool WsfComponentList::DeleteComponent ( WsfStringId aName,
int aRole )

Delete a single component with the specified name and role from the list.

Parameters
aNameThe name of the component to be deleted.
aRoleThe primary role of the component to be deleted.
Returns
true if successful or false if the component could not be found.

References DeleteComponentP().

Referenced by WsfExtEmission::AddSensor(), WsfMilExtInterface::AddWeapon(), wsf::six_dof::Mover::CommonSubobjectJettisonTasks(), WsfP6DOF_Mover::CommonSubobjectJettisonTasks(), DeleteComponent(), DeleteComponent(), WsfObjectTypeListBase::DeleteComponentP(), WsfZoneTypes::LoadInstance(), WsfDisDirectedEnergyFire::Process(), WsfExtInterface::StripExternalPlatform(), and WsfDisWeaponEvents::TransferPlatformToExternalControl().

◆ DeleteComponentP()

bool WsfComponentList::DeleteComponentP ( WsfStringId aName,
int aRole,
bool aDoNotify )
protected

References RemoveComponentP().

Referenced by DeleteComponent().

◆ FindByRole()

◆ FindComponentByRoleP()

WsfComponent * WsfComponentList::FindComponentByRoleP ( int aRole) const
protected

◆ FindComponentP() [1/2]

WsfComponent * WsfComponentList::FindComponentP ( WsfStringId aName) const
protected

References mComponentsByName.

◆ FindComponentP() [2/2]

WsfComponent * WsfComponentList::FindComponentP ( WsfStringId aName,
int aRole ) const
protected

Find the first component with the specified name and role. Remember that components are guaranteed to have unique names only within a primary role. If a non-primary role is specified then multiple components may have the same name and only the first one will be located.

Parameters
aNameThe name of the desired component.
aRoleThe role of the desired component.
Returns
A pointer to the component if found. 0 if the requested component does not exist.

References WsfComponent::ComponentHasRole(), and mComponentsByName.

Referenced by WsfComponentListT< WsfComponentT< Comm > >::FindComponent(), WsfComponentListT< WsfComponentT< Comm > >::FindComponent(), and GetComponent().

◆ GetComponent() [1/2]

template<class T>
T * WsfComponentList::GetComponent ( ) const
inline

Get a component with the role implied by the template argument This method can be used to return the component with the role implied by the template argument. In general this should be used to retrieve a component where it is known that at most one instance having the specified role exist with the list. If it is used then it will return the first entry with the given role. Typical usage:

WsfSensor* sensorPtr = platformPtr->GetComponent<WsfSensor>();

References FindComponentByRoleP().

Referenced by WsfWeapon::ActiveWeaponPlatformsFor(), WsfDisArticulatedPartList::AddArticulatedParts(), WsfTaskManager::AssignTask(), WsfWeaponTaskManager::AssignTask(), WsfBeamDirector::WsfBeamDirectorMode::AttemptToDetect(), wsf::comm::ComponentHW_LASER::CanSendTo(), checkDownCommandChain(), checkDownCommandChain(), checkUpCommandChain(), checkUpCommandChain(), WsfL16::SystemStatusPart::CheckWeapon(), WsfRIPRProcessor::CommanderPlatform(), WsfRIPRProcessor::CommanderProcessor(), WsfConfigureAccessReport::Complete(), wsf::cyber::Engagement::Draw(), WsfScriptCallback::Execute(), WsfCallback::ExecuteAndNotify(), wsf::comm::ProtocolIGMP::Find(), wsf::comm::router::ProtocolAdHoc::Find(), wsf::comm::router::ProtocolLegacy::Find(), wsf::comm::router::ProtocolMulticast::Find(), wsf::comm::router::ProtocolOSPF::Find(), WsfXIO_WeaponComponent::FindPart(), SafeRIPRProc::get(), getAllPartsDownCommandChain(), WsfBMUtils::GetCommander(), getManagingSensorsManager(), SafeRIPRProc::GetName(), WsfFalseTargetBlip::GetReferenceJammerToRadarRange(), getTopCommander(), WsfUplinkProcessor::GetUplinkCommForTrack(), WsfBMUtils::GetWeapon(), WsfBMUtils::GetWeaponID(), WsfWeaponEngagement::GetWeaponSystem(), WsfXIO_WeaponComponent::HandleStateChangeRequest(), wsf::comm::router::ProtocolOSPF::Initialize(), WsfCompositeSensor::Initialize(), WsfExchange::Transactor::Initialize(), WsfL16::ComputerPart::Initialize(), WsfL16::SurveillancePart::Initialize(), WsfScriptCallback::Initialize(), WsfWeaponTrackProcessor::Initialize(), WsfGuidedMoverBase::Initialize2(), WsfTaskManager::Initialize2(), WsfExplicitWeapon::InitializeCommandChains(), WsfIterativeRouteMover::IsWaypointSwitchTime(), WsfXIO_ObjectInfoLoad::Load_Platform(), wsf::comm::util::LocalSlaveNetworkName(), WsfMessageProcessor::Selector::Matches(), WsfCommandChain::PlatformAdded(), wsf::comm::NetworkManager::PlatformInitialized(), WsfCompositeSensor::ProcessMessage(), WsfTrackProcessor::ProcessMessage(), Fires::DisObserver::ProcessPDU(), WsfWeapon::RoundsCompleteFor(), WsfWeapon::RoundsFiredAt(), wsf::comm::router::ProtocolOSPF::Routing(), WsfWeapon::SalvosFiredAt(), WsfL16::SystemStatusPart::SendAirSystemStatus(), WsfPlatformPart::SendMessageToProcessor(), WsfTaskManager::SendTaskMessage(), WsfWeaponServer::SetCommander(), WsfExplicitWeapon::SetLaunchState(), WsfUplinkProcessor::StartUplinking(), WsfRIPRProcessor::SubordinatePlatforms(), WsfRIPRProcessor::SubordinateProcessors(), WsfRIPRProcessor::Subordinates(), WsfRIPRProcessor::SubsTargeting(), WsfRIPRProcessor::SubsWeaponsActive(), WsfWeaponTaskManager::TaskCanceled(), WsfWeapon::TimeWeaponLastFiredFor(), WsfWeapon::TimeWeaponLastTerminatedFor(), WsfPerceptionProcessor::TruthAssets(), WsfSA_Perceive::TruthAssets(), WsfHighEnergyLaser::UpdateEngagementGeometry(), WsfEventPipeInterface::UpdatePartArticulation(), WsfWeaponTaskManager::UplinkStart(), wsf::comm::UT_DEFINE_SCRIPT_METHOD(), WsfL16::SystemStatusPart::WeaponQuantity(), WsfWeapon::WeaponsActiveAndPendingFor(), WsfWeapon::WeaponsActiveFor(), and WsfWeapon::WeaponsPendingFor().

◆ GetComponent() [2/2]

template<class T>
T * WsfComponentList::GetComponent ( WsfStringId aName) const
inline

Get a component with the specified name and role implied by the template argument Typical usage:

WsfSensor* sensorPtr = platformPtr->GetComponent<WsfSensor>(name);

References FindComponentP().

◆ GetComponentCount() [1/2]

template<class T>
unsigned int WsfComponentList::GetComponentCount ( ) const
inline

Return the number of components of a particular component role. Typical usage:

unsigned int count = platformPtr->GetComponentCount<WsfSensor>();

References GetComponentCount().

◆ GetComponentCount() [2/2]

◆ GetComponentEntry()

◆ GetComponentEntryByRoleP()

WsfComponent * WsfComponentList::GetComponentEntryByRoleP ( int aRole,
unsigned int aEntry ) const
protected

◆ GetComponentRange()

template<typename T>
RoleRange< T > WsfComponentList::GetComponentRange ( )
inline

Yields a range that lets you loop over every component of a given type. Usage:

for (auto proc: componentList.GetComponentRange<WsfProcessor>())
{
proc->MethodOnProcessor(...); // ... this
...
}
Definition WsfProcessor.hpp:39
Template Parameters
TThe type of the components to loop over.

◆ HasComponents()

◆ operator=() [1/2]

◆ operator=() [2/2]

WsfComponentList & WsfComponentList::operator= ( WsfComponentList && aRhs)

◆ RemoveComponentP()

bool WsfComponentList::RemoveComponentP ( WsfStringId aName,
int aRole,
bool aDelete,
bool aDoNotify )
protected

Member Data Documentation

◆ mComponentsByName


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved