Honeycomb  0.1
Component-Model Framework
Classes | Public Member Functions | Friends | List of all members
honey::ComObject Class Reference

Component object. Object that consists of a collection of components. More...

#include <ComObject.h>

Inheritance diagram for honey::ComObject:
Inheritance graph
[legend]
Collaboration diagram for honey::ComObject:
Collaboration graph
[legend]

Public Member Functions

 SIGNAL (sigComInsert,(ComObject &src, Component &com))
 Called after component is inserted. More...
 
 SIGNAL (sigComRemove,(ComObject &src, Component &com))
 Called after component is removed. Reference component with a shared pointer to prevent deletion. More...
 
 SIGNAL (sigSetInstId,(ComObject &src, Id id))
 Called before instance id is changed. More...
 
virtual ~ComObject ()
 Removes and releases all contained components. More...
 
virtual void setInstId (const Id &id)
 Override from object, sends message about change. More...
 
void addCom (Component &com, bool createDeps=false)
 Add a component reference. The component is added to the end of its slot (and any supertype slots). More...
 
void addCom (Component *com, bool createDeps=false)
 Wrapper for pointer arg. More...
 
void insertCom (Component &com, szt index, bool createDeps=false)
 Add a component reference. The component is inserted into its slot at index. More...
 
template<class Com >
bool hasCom (const Id &id=idnull) const
 hasComInSlot() with type Com More...
 
bool hasComInSlot (const Id &type, const Id &id=idnull) const
 Check if object contains any components of type (with id). More...
 
template<class Com >
szt comCount () const
 comCountInSlot() with type Com More...
 
szt comCountInSlot (const Id &type) const
 Get number of components of type that this object contains. O(1) complexity. More...
 
auto comSlots () const -> decltype(keys(declval< const SlotMap >()))
 Get iterator over all slots in this object. A slot may contain one or many components. More...
 
template<class Com >
Com & com () const
 Get component of type Com. Returns first component in slot, must exist. More...
 
template<class Com >
Com & com (const Id &id) const
 comInSlot() with type Com More...
 
ComponentcomInSlot (const Id &type, const Id &id=idnull) const
 Get a single component of type with id. If id is null then first component in slot will be returned. More...
 
template<class Com >
const vector< typename Com::Ptr > & coms () const
 comsInSlot() with type Com More...
 
const vector< Component::Ptr > & comsInSlot (const Id &type) const
 Get all components of type. May return empty list. O(1) complexity. More...
 
void removeCom (Component &com, bool removeDeps=false)
 Remove a single component. O(n) complexity. More...
 
template<class Com >
void removeCom (const Id &id=idnull, bool removeDeps=false)
 Remove a single component of type Com with id. O(n) complexity unless id is null. If id is null then first component in slot is removed. More...
 
template<class Com >
void removeComAtIndex (szt index, bool removeDeps=false)
 removeComInSlot() with type Com More...
 
void removeComInSlot (const Id &type, szt index, bool removeDeps=false)
 Remove component of type at index. O(1) complexity, must exist. More...
 
template<class Com >
void removeComs (bool removeDeps=false)
 removeComsInSlot() with type Com More...
 
void removeComs ()
 Remove all components. Components are removed in type-dependent order. More...
 
void removeComsInSlot (const Id &type, bool removeDeps=false)
 Remove all components of type. Components are removed from slot list in reverse order. More...
 
ListenerListlisteners ()
 Get listener list. More...
 
- Public Member Functions inherited from honey::Object
 Object (const Id &id=idnull)
 
virtual ~Object ()
 
const IdgetInstId () const
 
- Public Member Functions inherited from honey::SharedObj< Object >
 SharedObj (Alloc &&a=Alloc()) debug_if(
 Construct with allocator that is called to deallocate this shared object when all references have been released. More...
 

Friends

class Component
 

Additional Inherited Members

- Protected Member Functions inherited from honey::SharedObj< Object >
void finalize ()
 Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction. More...
 
- Protected Attributes inherited from honey::Object
Id _instId
 

Detailed Description

Component object. Object that consists of a collection of components.

A component object contains multiple slots into which components can be inserted. A single slot contains one or many components of the same type.

Constructor & Destructor Documentation

virtual honey::ComObject::~ComObject ( )
inlinevirtual

Removes and releases all contained components.

Member Function Documentation

void honey::ComObject::addCom ( Component com,
bool  createDeps = false 
)
inline

Add a component reference. The component is added to the end of its slot (and any supertype slots).

Components contained by this object will be released upon object destruction.

Parameters
comComponent to add
createDepsAutomatically create any missing component dependencies. For performance set to false to avoid walking dep graph. Even if false, deps will still be verified in debug mode.
void honey::ComObject::addCom ( Component com,
bool  createDeps = false 
)
inline

Wrapper for pointer arg.

template<class Com >
Com& honey::ComObject::com ( ) const
inline

Get component of type Com. Returns first component in slot, must exist.

template<class Com >
Com& honey::ComObject::com ( const Id id) const
inline

comInSlot() with type Com

template<class Com >
szt honey::ComObject::comCount ( ) const
inline

comCountInSlot() with type Com

szt honey::ComObject::comCountInSlot ( const Id type) const
inline

Get number of components of type that this object contains. O(1) complexity.

Component& honey::ComObject::comInSlot ( const Id type,
const Id id = idnull 
) const
inline

Get a single component of type with id. If id is null then first component in slot will be returned.

template<class Com >
const vector<typename Com::Ptr>& honey::ComObject::coms ( ) const
inline

comsInSlot() with type Com

const vector<Component::Ptr>& honey::ComObject::comsInSlot ( const Id type) const
inline

Get all components of type. May return empty list. O(1) complexity.

auto honey::ComObject::comSlots ( ) const -> decltype(keys(declval<const SlotMap>()))
inline

Get iterator over all slots in this object. A slot may contain one or many components.

template<class Com >
bool honey::ComObject::hasCom ( const Id id = idnull) const
inline

hasComInSlot() with type Com

bool honey::ComObject::hasComInSlot ( const Id type,
const Id id = idnull 
) const
inline

Check if object contains any components of type (with id).

void honey::ComObject::insertCom ( Component com,
szt  index,
bool  createDeps = false 
)
inline

Add a component reference. The component is inserted into its slot at index.

The component will be also added to the end of any supertype slots. Components contained by this object will be released upon object destruction.

ListenerList& honey::ComObject::listeners ( )
inline

Get listener list.

void honey::ComObject::removeCom ( Component com,
bool  removeDeps = false 
)
inline

Remove a single component. O(n) complexity.

Parameters
comComponent to remove
removeDepsAutomatically remove any dependent components. For performance set to false to avoid walking dep graph. Even if false, deps will still be verified in debug mode.
template<class Com >
void honey::ComObject::removeCom ( const Id id = idnull,
bool  removeDeps = false 
)
inline

Remove a single component of type Com with id. O(n) complexity unless id is null. If id is null then first component in slot is removed.

template<class Com >
void honey::ComObject::removeComAtIndex ( szt  index,
bool  removeDeps = false 
)
inline

removeComInSlot() with type Com

void honey::ComObject::removeComInSlot ( const Id type,
szt  index,
bool  removeDeps = false 
)
inline

Remove component of type at index. O(1) complexity, must exist.

template<class Com >
void honey::ComObject::removeComs ( bool  removeDeps = false)
inline

removeComsInSlot() with type Com

void honey::ComObject::removeComs ( )

Remove all components. Components are removed in type-dependent order.

void honey::ComObject::removeComsInSlot ( const Id type,
bool  removeDeps = false 
)
inline

Remove all components of type. Components are removed from slot list in reverse order.

virtual void honey::ComObject::setInstId ( const Id id)
inlinevirtual

Override from object, sends message about change.

Reimplemented from honey::Object.

honey::ComObject::SIGNAL ( sigComInsert  ,
(ComObject &src, Component &com  
)

Called after component is inserted.

honey::ComObject::SIGNAL ( sigComRemove  ,
(ComObject &src, Component &com  
)

Called after component is removed. Reference component with a shared pointer to prevent deletion.

honey::ComObject::SIGNAL ( sigSetInstId  ,
(ComObject &src, Id id)   
)

Called before instance id is changed.

Friends And Related Function Documentation

friend class Component
friend

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