Murl::Logic::GraphInstanceObjects< InstanceObjectType > Class Template Reference

Template class controlling multiple replications created by XML <Instance> node. More...

#include "murl_logic_graph_instance_objects.h"

Inheritance diagram for Murl::Logic::GraphInstanceObjects< InstanceObjectType >:

Public Member Functions

 GraphInstanceObjects ()
 The default constructor.
 
Bool SetNodeObserver (INodeObserverPtr nodeObserver)
 Set the node observer. More...
 
 ~GraphInstanceObjects () override
 The destructor.
 
virtual Bool Init (const Graph::IRoot *root, const String &pathName, const String &instanceName, const String &replicationName, const String &postfixName=String())
 Initialize the object. More...
 
virtual Bool Init (Graph::INamespace *namespaceNode, const String &instanceNodeIdPath)
 Initialize the object. More...
 
virtual Bool Init (Logic::NamespaceNode namespaceNode, const String &instanceNodeIdPath)
 Initialize the object. More...
 
virtual Bool DeInit ()
 Deinitialize the object. More...
 
virtual Bool IsInitialized () const
 Check if the object is initialized successful. More...
 
virtual Graph::IInstanceGetInstanceNode () const
 Get the interface of the graph instance node. More...
 
virtual InstanceObjectType * Obtain ()
 Obtain a single InstanceObjectType object. More...
 
virtual void ObtainAll ()
 Obtain all InstanceObjectType object.
 
virtual Bool Release (InstanceObjectType *object)
 Release a single InstanceObjectType object. More...
 
virtual void ReleaseAll ()
 Release all InstanceObjectType object.
 
void SetObtained (UInt32 index, Bool isObtained)
 Set the obtained status of an InstanceObjectType object. More...
 
UInt32 GetMaxObtained () const
 Get the highest obtained instance index. More...
 
UInt32 GetNumberOfObtained () const
 Get the number of obtained instances. More...
 
UInt32 GetNumberOfRemaining () const
 Get the number of non-obtained instances. More...
 
UInt32 GetNumberOfInstances () const
 Get the number of instances. More...
 
const InstanceObjectType * GetInstance (UInt32 index) const
 Get the const InstanceObjectType object by index. More...
 
const InstanceObjectType * GetObtainedInstance (UInt32 index) const
 Get the const InstanceObjectType object by index if obtained. More...
 
InstanceObjectType * GetInstance (UInt32 index)
 Get the InstanceObjectType object by index. More...
 
InstanceObjectType * GetObtainedInstance (UInt32 index)
 Get the InstanceObjectType object by index if obtained. More...
 
Bool IsObtained (UInt32 index) const
 Check if a InstanceObjectType object is obtained. More...
 
- Public Member Functions inherited from Murl::Logic::BaseStepable
 BaseStepable ()
 The default constructor. More...
 
 ~BaseStepable () override
 The destructor. More...
 
 operator IStepablePtr ()
 Conversion operator. More...
 
- Public Member Functions inherited from Murl::Logic::Stepable
 ~Stepable () override
 The destructor.
 
Bool SetAppStepable (IAppStepablePtr appStepable) override
 Implementation of IStepable::SetAppStepable() method. More...
 
void SetEnabled (Bool isEnabled) override
 Implementation of IStepable::SetEnabled() method. More...
 
Bool IsEnabled () const override
 Implementation of IStepable::IsEnabled() method. More...
 
void Reset () override
 Implementation of IStepable::Reset() method.
 
void ProcessTick (const Logic::IState *state) override
 Implementation of IStepable::ProcessTick() method. More...
 
void FinishTick (const Logic::IState *state) override
 Implementation of IStepable::FinishTick() method. More...
 

Protected Member Functions

void OnSetEnabled (Bool isEnabled) override
 Overwrite of the BaseStepable::OnSetEnabled() method, calls SetEnabled() to all obtained InstanceObjectType objects. More...
 
void OnReset () override
 Overwrite of the BaseStepable::OnReset() method, calls Reset() to all obtained InstanceObjectType objects.
 
void OnProcessTick (const Logic::IState *state) override
 Overwrite of the BaseStepable::OnProcessTick() method, calls ProcessTick() to all obtained InstanceObjectType objects. More...
 
void OnFinishTick (const Logic::IState *state) override
 Overwrite of the BaseStepable::OnFinishTick() method, calls FinishTick() to all obtained InstanceObjectType objects. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Murl::Logic::Stepable
static IStepablePtr Create ()
 Create a stepable object. More...
 

Detailed Description

template<class InstanceObjectType>
class Murl::Logic::GraphInstanceObjects< InstanceObjectType >

Template class controlling multiple replications created by XML <Instance> node.

A InstanceObjectType class must derive from the Logic::GraphReplication base class. See class Logic::GraphPositionInstance or Logic::GraphSoundInstance for example.

Member Function Documentation

◆ SetNodeObserver()

template<class InstanceObjectType >
Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::SetNodeObserver ( INodeObserverPtr  nodeObserver)
inline

Set the node observer.

Parameters
nodeObserverThe node observer.
Returns
true if successful, false if the internal node observer is already in use.

◆ Init() [1/3]

template<class InstanceObjectType >
virtual Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init ( const Graph::IRoot root,
const String pathName,
const String instanceName,
const String replicationName,
const String postfixName = String() 
)
inlinevirtual

Initialize the object.

Create and initialize InstanceObjectType classes for each of the Graph::IInstance replications.

Parameters
rootThe graph root node.
pathNameThe full path to the Graph::IInstance excluding the replication name.
instanceNameThe instance name excluding the path.
replicationNameThe prefix of the {replication} name excluding the path.
postfixNameAn optional postfix of the {replication} name excluding the path.
Returns
true if successful.

References Murl::SharedPointer< DataType >::Get(), Murl::Graph::IInstance::GetNumberOfReplications(), Murl::Logic::GraphNodeT< NodeType >::GetReference(), Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsInitialized(), Murl::ObjectArray< DataType >::SetCount(), and Murl::Util::UInt32ToString().

Referenced by Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init().

◆ Init() [2/3]

template<class InstanceObjectType >
virtual Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init ( Graph::INamespace namespaceNode,
const String instanceNodeIdPath 
)
inlinevirtual

Initialize the object.

Create and initialize InstanceObjectType classes for each of the Graph::IInstance replications.

Parameters
namespaceNodeThe graph namespace node.
instanceNodeIdPathThe instance name with optional path.
Returns
true if successful.

References Murl::SharedPointer< DataType >::Get(), Murl::Graph::IInstance::GetNumberOfReplications(), Murl::Logic::GraphNodeT< NodeType >::GetReference(), Murl::Graph::IInstance::GetReplicationNode(), Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init(), Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsInitialized(), and Murl::ObjectArray< DataType >::SetCount().

◆ Init() [3/3]

template<class InstanceObjectType >
virtual Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init ( Logic::NamespaceNode  namespaceNode,
const String instanceNodeIdPath 
)
inlinevirtual

Initialize the object.

Create and initialize InstanceObjectType classes for each of the Graph::IInstance replications.

Parameters
namespaceNodeThe logic namespace node.
instanceNodeIdPathThe instance name with optional path.
Returns
true if successful.

References Murl::Logic::GraphNodeT< NodeType >::GetNode(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init().

◆ DeInit()

template<class InstanceObjectType >
virtual Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::DeInit ( )
inlinevirtual

Deinitialize the object.

Deinitialize all InstanceObjectType class instances.

Returns
true if successful.

References Murl::ObjectArray< DataType >::Empty(), Murl::ObjectArray< DataType >::GetCount(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsInitialized().

◆ IsInitialized()

template<class InstanceObjectType >
virtual Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsInitialized ( ) const
inlinevirtual

Check if the object is initialized successful.

Returns
true if initialized successful.

References Murl::Logic::GraphNodeT< NodeType >::IsValid().

Referenced by Murl::Logic::GraphInstanceObjects< InstanceObjectType >::DeInit(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init().

◆ GetInstanceNode()

template<class InstanceObjectType >
virtual Graph::IInstance* Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetInstanceNode ( ) const
inlinevirtual

Get the interface of the graph instance node.

Returns
A pointer to the graph instance interface or null.

References Murl::Logic::GraphNodeT< NodeType >::GetNode().

◆ Obtain()

template<class InstanceObjectType >
virtual InstanceObjectType* Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Obtain ( )
inlinevirtual

Obtain a single InstanceObjectType object.

Returns
A pointer to the InstanceObjectType object or null.

References Murl::ObjectArray< DataType >::GetCount(), Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::SetObtained().

◆ Release()

template<class InstanceObjectType >
virtual Bool Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Release ( InstanceObjectType *  object)
inlinevirtual

Release a single InstanceObjectType object.

Parameters
objectA pointer to the InstanceObjectType.
Returns
true if successful.

References Murl::ObjectArray< DataType >::GetCount(), Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetInstance(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::SetObtained().

◆ SetObtained()

template<class InstanceObjectType >
void Murl::Logic::GraphInstanceObjects< InstanceObjectType >::SetObtained ( UInt32  index,
Bool  isObtained 
)
inline

Set the obtained status of an InstanceObjectType object.

A valid index is [0 .. GetNumberOfInstances() - 1].

Parameters
indexThe zero-based index of the object.
isObtainedThe obtained state.

References Murl::ObjectArray< DataType >::GetCount(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained().

Referenced by Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Obtain(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Release().

◆ GetMaxObtained()

template<class InstanceObjectType >
UInt32 Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetMaxObtained ( ) const
inline

Get the highest obtained instance index.

This is an effective approach for iterating through all obtained instances.

for (UInt32 i = 0; i < mMyInstances.GetMaxObtained(); i++)
{
MyInstanceType* instance = mMyInstances.GetObtainedInstance(i);
if (instance != 0)
{
instance->DoSomething();
}
}
MurlUInt32 UInt32
Unsigned 32 bit integer data type.
Definition: murl_types.h:136
Returns
The highest obtained instance index.

◆ GetNumberOfObtained()

template<class InstanceObjectType >
UInt32 Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetNumberOfObtained ( ) const
inline

Get the number of obtained instances.

Returns
The number of obtained instances.

◆ GetNumberOfRemaining()

template<class InstanceObjectType >
UInt32 Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetNumberOfRemaining ( ) const
inline

Get the number of non-obtained instances.

Returns
The number of non-obtained instances.

References Murl::ObjectArray< DataType >::GetCount().

◆ GetNumberOfInstances()

template<class InstanceObjectType >
UInt32 Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetNumberOfInstances ( ) const
inline

Get the number of instances.

Returns
The number of instances.

References Murl::ObjectArray< DataType >::GetCount().

◆ GetInstance() [1/2]

template<class InstanceObjectType >
const InstanceObjectType* Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetInstance ( UInt32  index) const
inline

Get the const InstanceObjectType object by index.

A valid index is [0 .. GetNumberOfInstances() - 1].

Parameters
indexThe zero-based index of the object.
Returns
A const pointer to the InstanceObjectType object or null.

References Murl::ObjectArray< DataType >::GetCount().

Referenced by Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Release().

◆ GetObtainedInstance() [1/2]

template<class InstanceObjectType >
const InstanceObjectType* Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetObtainedInstance ( UInt32  index) const
inline

Get the const InstanceObjectType object by index if obtained.

A valid index is [0 .. GetNumberOfInstances() - 1].

Parameters
indexThe zero-based index of the object.
Returns
A const pointer to the InstanceObjectType object or null if the object is not obtained.

References Murl::ObjectArray< DataType >::GetCount(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained().

◆ GetInstance() [2/2]

template<class InstanceObjectType >
InstanceObjectType* Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetInstance ( UInt32  index)
inline

Get the InstanceObjectType object by index.

A valid index is [0 .. GetNumberOfInstances() - 1].

Parameters
indexThe zero-based index of the object.
Returns
A pointer to the InstanceObjectType object or null.

References Murl::ObjectArray< DataType >::GetCount().

◆ GetObtainedInstance() [2/2]

template<class InstanceObjectType >
InstanceObjectType* Murl::Logic::GraphInstanceObjects< InstanceObjectType >::GetObtainedInstance ( UInt32  index)
inline

Get the InstanceObjectType object by index if obtained.

A valid index is [0 .. GetNumberOfInstances() - 1].

Parameters
indexThe zero-based index of the object.
Returns
A pointer to the InstanceObjectType object or null if the object is not obtained.

References Murl::ObjectArray< DataType >::GetCount(), and Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained().

◆ IsObtained()

◆ OnSetEnabled()

template<class InstanceObjectType >
void Murl::Logic::GraphInstanceObjects< InstanceObjectType >::OnSetEnabled ( Bool  isEnabled)
inlineoverrideprotectedvirtual

Overwrite of the BaseStepable::OnSetEnabled() method, calls SetEnabled() to all obtained InstanceObjectType objects.

Parameters
isEnabledtrue if enabled.

Reimplemented from Murl::Logic::BaseStepable.

References Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained(), and Murl::Logic::GraphNodeT< NodeType >::SetActive().

◆ OnProcessTick()

template<class InstanceObjectType >
void Murl::Logic::GraphInstanceObjects< InstanceObjectType >::OnProcessTick ( const Logic::IState state)
inlineoverrideprotectedvirtual

Overwrite of the BaseStepable::OnProcessTick() method, calls ProcessTick() to all obtained InstanceObjectType objects.

Parameters
stateThe IState object.

Reimplemented from Murl::Logic::BaseStepable.

References Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained().

◆ OnFinishTick()

template<class InstanceObjectType >
void Murl::Logic::GraphInstanceObjects< InstanceObjectType >::OnFinishTick ( const Logic::IState state)
inlineoverrideprotectedvirtual

Overwrite of the BaseStepable::OnFinishTick() method, calls FinishTick() to all obtained InstanceObjectType objects.

Parameters
stateThe IState object.

Reimplemented from Murl::Logic::BaseStepable.

References Murl::Logic::GraphInstanceObjects< InstanceObjectType >::IsObtained().


The documentation for this class was generated from the following file:
  • murl_logic_graph_instance_objects.h


Copyright © 2011-2022 Spraylight GmbH.