INOS
CINOSContainer< T > Class Template Reference

#include <cinoscontainer.h>

Public Types

typedef int(* tForEach) (T &, void *)
 

Public Member Functions

 CINOSContainer (const char *apName, const char *apElementBases)
 
 CINOSContainer (const char *apName, const char *apElementBases, void *apParent)
 
virtual ~CINOSContainer ()
 destructor
 
void SetParent (void *apParent)
 set container parent
 
void SetBase (const char *apElementBases)
 
void SetName (const char *apName)
 Set different name for registration. Only works prior to registration.
 
uint32 Create (const char *apName)
 create entity
 
uint32 Create (const char *apName, const char *apType)
 create entity
 
uint32 Create (const char *apName, const char *apType, const char *apParam)
 create entity
 
uint32 Destroy (const char *apName)
 destroy entity
 
uint32 Check (const char *apType, const char *apParam)
 check if it is allowed to create entity of apType
 
virtual void Add (T *apEntity)
 add entity to container
 
virtual void Remove (T *apEntity, bool abDelete=true)
 remove entity from container
 
virtual TFind (const char *apName)
 return pointer to entity 'apName'
 
virtual TGetAt (uint32 auIndex)
 return pointer to entity auIndex
 
virtual uint32 GetNumber ()
 return number of entities
 
virtual void ForEach (tForEach cond, void *args)
 
template<typename F >
void ForEach (F cond)
 
void RegisterHook (void *apObject, void *apMethod)
 register event hook
 
CINCOObject * GetRegister (bool abLight=false)
 get pointer to inco registration
 

Protected Member Functions

 DECLARE_DYNAMIC_T (CINOSContainer, T)
 

Protected Attributes

char m_cName [32]
 container name
 
char m_cBase [256]
 pointer to string of all supported base types
 
voidm_pParent
 pointer to container parent
 
voidm_pHookObj
 pointer to hook object
 
voidm_pHookMtd
 pointer to hook method
 
TINOSNameBalancedBinaryTree< T > * m_pEntities
 pool of all entities
 
CINCOObject * m_pRegister
 pointer to inco registration
 
CINCOObject * m_pCmd
 pointer to command folder
 
CINCOObject * m_pEntity
 pointer to entity folder
 
CINCOObject * m_pProp
 Pointer to prop folder.
 
int16 m_iOrder
 inco tree order
 
char m_ceName [64]
 entity name
 
char m_ceType [32]
 entity type
 
char m_ceParam [256]
 entity param's
 

Detailed Description

template<class T>
class CINOSContainer< T >

This container stores elements of arbitrary type and provides an INCO representation of the elements. It also allows to create and destroy new element instances by INCO calls. A container can be restricted to elements of a given set of classes using "base" identifiers.

To make an element class be managed by this container, register and assign it to a base using the INOS_CONTAINER_CLASS macro. It must provide the following interface:

// The name of this element. This name is for the INCO tree representation.
// Optionally, the name may contain dots ('.'). In that case, the container
// creates a hierarchical layout in which the dot is used as a separator and
// each "separated name" becomes a CINCOObject.
//
// e.g. "SimpleName" -> become CINCOObject("SimpleName");
// e.g. "Parent.Name" -> becomes CINCOObject("Parent")->Add(CINCOObject("Name"));
//
// Note that all these intermediately created CINCOObjects will be deleted
// by the container upon element destruction. Only the final object needs
// to be destroyed by the element itself. See also: GetRegister()
const char* GetName();
// The element must create it's INCO representation and add it to apParent.
// The important thing is that the ownership of apParent is transferred
// to the element object. Therefore, the element object must delete that
// object!
void GetRegister(CINCOObject* apParent);
// called after the creation of the element. Often, an element doesn't
// need to do anything in here
virtual void PostCreate(void* apParent);
// Called before an element is being destroyed.
// \return true to allow destruction, false otherwise.
virtual bool PreDestroy(bool& bDeleteSelf);
// binary tree operators
int operator < (const char* aName);
int operator == (const char* aName);
CINCOObject * GetRegister(bool abLight=false)
get pointer to inco registration
Definition cinoscontainer.h:634
Definition cinosmcmodule.h:1900

Constructor & Destructor Documentation

◆ CINOSContainer()

template<class T >
CINOSContainer< T >::CINOSContainer ( const char apName,
const char apElementBases 
)

constructor/destructor

Parameters
apNameINCO name of the container
apElementBasescomma-separated list of allowed element bases (see INOS_CONTAINER_CLASS)

Member Function Documentation

◆ SetBase()

template<class T >
void CINOSContainer< T >::SetBase ( const char apElementBases)

set allowed element bases

Parameters
apElementBasescomma-separated list (see INOS_CONTAINER_CLASS)

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