PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes
PLCore::ElementManager< AType > Class Template Reference

Abstract element manager template. More...

#include <ElementManager.h>

Inheritance diagram for PLCore::ElementManager< AType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

String GetManagerName () const
 Returns the name of the manager.
bool SetManagerName (const String &sName="")
 Sets the name of the manager.
bool Clear (bool bProtectedToo=true)
 Clear the manager, delete all elements.
AType * Create (const String &sName="")
 Creates a new element.
bool Add (AType &cElement)
 Adds a element.
bool Unload (AType &cElement)
 Unload a element.
bool Remove (AType &cElement)
 Removes a element.
uint32 UnloadUnused ()
 Unload unused elements.
bool GetUnloadUnused () const
 Returns whether unused element are unloaded automatically or not.
void SetUnloadUnused (bool bUnloadUnused=false)
 Sets whether unused element are unloaded automatically or not.
AType * GetStandard () const
 Get the standard element.
bool SetStandard (AType *pElement=nullptr)
 Set the standard element.
uint32 GetNumOfElements () const
 Returns the number of elements within the manager.
virtual bool Init ()
 Initializes the manager.
virtual bool DeInit ()
 De-initializes the manager.
virtual bool Update ()
 Updates the manager.
virtual ElementManager< AType > & operator= (const ElementManager< AType > &cSource)
 Copy operator.
virtual AType * GetByIndex (uint32 nIndex=0) const
 Returns the element at the given index.
virtual int GetIndex (AType &cElement) const
 Returns the index of the given element.
virtual void MoveElement (uint32 nFromIndex, uint32 nToIndex)
 Moves an element within the element list.
virtual AType * GetByName (const String &sName) const
 Returns the element with the given name.

Protected Member Functions

 ElementManager ()
 Constructor.
virtual ~ElementManager ()
 Destructor.
bool SetElementName (AType &cElement, const String &sName)
 Sets the element name.
virtual AType * CreateElement (const String &sName="")=0
 Creates a new element.

Protected Attributes

String m_sManagerName
AType * m_pStandardElement
bool m_bUnloadUnused
Array< AType * > m_lstElements
HashMap< String, AType * > m_mapElements

Detailed Description

template<class AType>
class PLCore::ElementManager< AType >

Abstract element manager template.


Constructor & Destructor Documentation

template<class AType >
PLCore::ElementManager< AType >::ElementManager ( ) [protected]
template<class AType >
PLCore::ElementManager< AType >::~ElementManager ( ) [protected, virtual]

Destructor.


Member Function Documentation

template<class AType >
String PLCore::ElementManager< AType >::GetManagerName ( ) const

Returns the name of the manager.

Returns:
Name of the manager
Note:
  • The manager name has no special usage, it's just for completeness
template<class AType >
bool PLCore::ElementManager< AType >::SetManagerName ( const String sName = "")

Sets the name of the manager.

Parameters:
[in]sNameNew manager name
Returns:
'true' if all went fine else 'false'
See also:
template<class AType >
bool PLCore::ElementManager< AType >::Clear ( bool  bProtectedToo = true)

Clear the manager, delete all elements.

Parameters:
[in]bProtectedTooDelete protected elements, too?
Returns:
'true' if all went fine, else 'false'
template<class AType >
AType * PLCore::ElementManager< AType >::Create ( const String sName = "")

Creates a new element.

Parameters:
[in]sNameElement name, if "" an unused name is set automatically
Returns:
Pointer to the created element, a null pointer if there was an error
Note:
  • If there's already a element with this name, this element is returned
template<class AType>
bool PLCore::ElementManager< AType >::Add ( AType &  cElement)

Adds a element.

Parameters:
[in]cElementElement to add
Returns:
'true' if all went fine, else 'false' (maybe element is already within another manager)
template<class AType>
bool PLCore::ElementManager< AType >::Unload ( AType &  cElement)

Unload a element.

Parameters:
[in]cElementElement which should be unloaded
Returns:
'true' if all went fine, else 'false'
Note:
  • Protected elements are NOT unloaded!
template<class AType>
bool PLCore::ElementManager< AType >::Remove ( AType &  cElement)

Removes a element.

Parameters:
[in]cElementElement to remove
Returns:
'true' if all went fine, else 'false' (maybe element is not within the manager)
Note:
  • This function will only remove the element from the manager, but NOT deleting it!
template<class AType >
uint32 PLCore::ElementManager< AType >::UnloadUnused ( )

Unload unused elements.

Returns:
Number of unloaded elements
See also:
template<class AType >
bool PLCore::ElementManager< AType >::GetUnloadUnused ( ) const

Returns whether unused element are unloaded automatically or not.

Returns:
'true' if unused elements are unloaded automatically, else 'false'
template<class AType >
void PLCore::ElementManager< AType >::SetUnloadUnused ( bool  bUnloadUnused = false)

Sets whether unused element are unloaded automatically or not.

Parameters:
[in]bUnloadUnusedUnload unused elements automatically?
template<class AType >
AType * PLCore::ElementManager< AType >::GetStandard ( ) const

Get the standard element.

Returns:
The standard element, a null pointer if there's no such element
Note:
  • There should always be a standard element!
  • It is recommended that you protect your standard element
template<class AType>
bool PLCore::ElementManager< AType >::SetStandard ( AType *  pElement = nullptr)

Set the standard element.

Parameters:
[in]pElementElement which should be the standard element, a null pointer to set no such element
Returns:
'true' if all went fine, else 'false' (maybe invalid element)
See also:
template<class AType >
uint32 PLCore::ElementManager< AType >::GetNumOfElements ( ) const

Returns the number of elements within the manager.

Returns:
Number of elements within the manager
template<class AType >
bool PLCore::ElementManager< AType >::Init ( ) [virtual]

Initializes the manager.

Returns:
'true' if all went fine, else 'false'
template<class AType >
bool PLCore::ElementManager< AType >::DeInit ( ) [virtual]

De-initializes the manager.

Returns:
'true' if all went fine, else 'false'

Reimplemented in PLScene::SceneContainer.

template<class AType >
bool PLCore::ElementManager< AType >::Update ( ) [virtual]

Updates the manager.

Returns:
'true' if all went fine, else 'false'
template<class AType>
ElementManager< AType > & PLCore::ElementManager< AType >::operator= ( const ElementManager< AType > &  cSource) [virtual]

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
This instance
template<class AType >
AType * PLCore::ElementManager< AType >::GetByIndex ( uint32  nIndex = 0) const [virtual]

Returns the element at the given index.

Parameters:
[in]nIndexIndex of the element
Returns:
The corresponding object, a null pointer if there's no match
template<class AType>
int PLCore::ElementManager< AType >::GetIndex ( AType &  cElement) const [virtual]

Returns the index of the given element.

Parameters:
[in]cElementThe element for which the index should be retrieved
Returns:
The index position, <0 on failure (e.g. the element is no member of this manager)
template<class AType >
void PLCore::ElementManager< AType >::MoveElement ( uint32  nFromIndex,
uint32  nToIndex 
) [virtual]

Moves an element within the element list.

Parameters:
[in]nFromIndexThe index of the element which should be moved
[in]nToIndexThe index to which the element should be moved
Note:
template<class AType >
AType * PLCore::ElementManager< AType >::GetByName ( const String sName) const [virtual]

Returns the element with the given name.

Parameters:
[in]sNameElement name
Returns:
The corresponding element, a null pointer if there's no match
Note:
  • You can overload this function to specialize the behavior. This is done for instance within SceneContainer to be able to use 'absolute names' like 'Root.MyScene.MyNode', too.

Reimplemented in PLScene::SceneContainer.

template<class AType>
bool PLCore::ElementManager< AType >::SetElementName ( AType &  cElement,
const String sName 
) [protected]

Sets the element name.

Sets the unique element name.

Parameters:
[in]cElementElement to set the name
[in]sNameNew element name
Returns:
'true' if all went fine, else 'false' (maybe the name is already used)
See also:
  • GetName()
Note:
  • You can overload this function if there are 'reserved' names which are NOT allowed to be used or if special characters are not allowed.
template<class AType>
virtual AType* PLCore::ElementManager< AType >::CreateElement ( const String sName = "") [protected, pure virtual]

Creates a new element.

Parameters:
[in]sNameElement name
Returns:
Pointer to the created element, a null pointer if there was an error
Note:
  • This function is used inside the function Create(). If AType is an abstract class you have to overwrite this function to create an instance of the class.

Implemented in PLRenderer::AnimationManager.


Member Data Documentation

template<class AType>
String PLCore::ElementManager< AType >::m_sManagerName [protected]

Manager name

template<class AType>
AType* PLCore::ElementManager< AType >::m_pStandardElement [protected]

Standard element, can be a null pointer

template<class AType>
bool PLCore::ElementManager< AType >::m_bUnloadUnused [protected]

Unload unused resources?

template<class AType>
Array<AType*> PLCore::ElementManager< AType >::m_lstElements [protected]

Element list

template<class AType>
HashMap<String, AType*> PLCore::ElementManager< AType >::m_mapElements [protected]

Element map


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:24
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported