Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | Protected Member Functions | Friends | List of all members
jop::Component Class Referenceabstract

#include <Component.hpp>

Inheritance diagram for jop::Component:
jop::Camera jop::Collider jop::Collider2D jop::LightSource jop::Listener jop::ModelLoader jop::SoundSource jop::PhantomBody jop::RigidBody jop::RigidBody2D jop::SoundEffect jop::SoundStream jop::CullerComponent jop::Drawable jop::AnimatedSprite jop::SkyBox jop::SkySphere jop::Sprite jop::Text jop::World jop::World2D

Public Member Functions

virtual ~Component ()=0
 Virtual destructor. More...
 
Message::Result sendMessage (const Message &message)
 Send a message to this component. More...
 
virtual void update (const float deltaTime)
 Update function. More...
 
uint32 getID () const
 Get the identifier. More...
 
void setID (const uint32 ID)
 Set the identifier. More...
 
WeakReference< ObjectgetObject ()
 Get the object this component is bound to. More...
 
WeakReference< const ObjectgetObject () const
 Get the object this component is bound to. More...
 
bool isActive () const
 Check if this component is active. More...
 
void removeSelf ()
 Remove this component from its object. More...
 

Protected Member Functions

 Component (Object &object, const uint32 ID)
 Constructor. More...
 
 Component (const Component &other, Object &newObj)
 Copy constructor. More...
 
virtual Message::Result receiveMessage (const Message &message)
 Receive a message. More...
 

Friends

class Object
 

Detailed Description

Definition at line 37 of file Component.hpp.

Constructor & Destructor Documentation

jop::Component::Component ( Object object,
const uint32  ID 
)
protected

Constructor.

Parameters
objectReference to the object this component will be bound to
IDIdentifier. If you don't plan on using this for anything, pass 0
jop::Component::Component ( const Component other,
Object newObj 
)
protected

Copy constructor.

This copy constructor differs in signature from the standard. Cloned components often need to know their objects during construction, and thus needs to be passed in here. Your own components' copy constructors should be defined the same way. See clone(Object&).

Parameters
otherThe other component to be copied
newObjThe new object
virtual jop::Component::~Component ( )
pure virtual

Virtual destructor.

Member Function Documentation

uint32 jop::Component::getID ( ) const

Get the identifier.

Returns
The identifier
WeakReference<Object> jop::Component::getObject ( )

Get the object this component is bound to.

Returns
Reference to the object
WeakReference<const Object> jop::Component::getObject ( ) const

Get the object this component is bound to.

Returns
Reference to the object
bool jop::Component::isActive ( ) const

Check if this component is active.

This is the same as calling getObject()->isActive().

Returns
True if active
virtual Message::Result jop::Component::receiveMessage ( const Message message)
protectedvirtual

Receive a message.

Override this to handle messages sent to this. Don't forget to call the base class' method as well to ensure that the message gets forwarded correctly.

Parameters
messageThe message
Returns
The message result

Reimplemented in jop::RigidBody, jop::LightSource, jop::Camera, jop::Drawable, jop::RigidBody2D, and jop::World.

void jop::Component::removeSelf ( )

Remove this component from its object.

The component will be removed immediately.

Message::Result jop::Component::sendMessage ( const Message message)

Send a message to this component.

Parameters
messageThe message
Returns
Message result
void jop::Component::setID ( const uint32  ID)

Set the identifier.

Parameters
IDThe new identifier
This method is exposed as command named setID
virtual void jop::Component::update ( const float  deltaTime)
virtual

Friends And Related Function Documentation

friend class Object
friend

Definition at line 43 of file Component.hpp.


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