Planet
navihomeaboutscreenshotsdownloaddevelopmentforum
Orxonox: orxonox::BaseObject Class Reference

orxonox::BaseObject Class Reference

The BaseObject is the parent of all classes representing an instance in the game. More...

#include <core/BaseObject.h>

Inheritance diagram for orxonox::BaseObject:
orxonox::OrxonoxClass orxonox::BarColour orxonox::CollisionShape orxonox::Controller orxonox::CreateStars orxonox::DefaultWeaponmodeLink orxonox::DockingAnimation orxonox::DockingEffect orxonox::EffectContainer orxonox::EventDispatcher orxonox::EventFilter orxonox::EventListener orxonox::EventName orxonox::EventTarget orxonox::Gametype orxonox::GlobalShader orxonox::GUISheet orxonox::Info orxonox::Item orxonox::Level orxonox::LevelInfo orxonox::MeshLodInformation orxonox::MultiTriggerContainer orxonox::Munition orxonox::Namespace orxonox::NotificationDispatcher orxonox::NotificationQueue orxonox::OrxonoxOverlay orxonox::OverlayGroup orxonox::Pickup orxonox::PickupCollection orxonox::PickupRepresentation orxonox::PortalLink orxonox::QuestDescription orxonox::QuestEffect orxonox::QuestItem orxonox::QuestListener orxonox::ResourceCollection orxonox::ResourceLocation orxonox::Scene orxonox::Script orxonox::SpaceRaceManager orxonox::Template orxonox::Test orxonox::WeaponMode orxonox::WeaponPack orxonox::WeaponSet orxonox::WeaponSystem orxonox::WorldAmbientSound orxonox::WorldEntity

List of all members.

Public Member Functions

 BaseObject (BaseObject *creator)
 Constructor: Registers the object in the BaseObject-list.
virtual ~BaseObject ()
 Destructor.
void addEventListener (BaseObject *listener)
 Adds an object which listens to the events of this object.
void addEventSource (BaseObject *source, const std::string &state)
 Adds a new event source for a specific state.
void addTemplate (Template *temp)
 Adds a Template to the object.
void addTemplate (const std::string &name)
 Adds a Template to the object.
virtual void changedActivity ()
 This function gets called if the activity of the object changes.
virtual void changedGametype ()
virtual void changedLevel ()
virtual void changedMainStateName ()
 This function gets called if the main state name of the object changes.
virtual void changedName ()
 This function gets called if the name of the object changes.
virtual void changedVisibility ()
 This function gets called if the visibility of the object changes.
void fireEvent (Event &event)
 Fires an event, using the Event struct.
void fireEvent (bool activate, BaseObject *originator, const std::string &name="")
 Fires an event which activates or deactivates a state with agiven originator (the object which triggered the event).
void fireEvent (bool activate, const std::string &name="")
 Fires an event which activates or deactivates a state.
void fireEvent (const std::string &name="")
 Fires an event (without a state).
BaseObjectgetCreator () const
BaseObjectgetEventListener (unsigned int index) const
 Returns an event listener with a given index.
BaseObjectgetEventSource (unsigned int index, const std::string &state) const
 Returns an eventsource with a given index.
const XMLFilegetFile () const
 Returns a pointer to the XMLFile that loaded this object.
const std::stringgetFilename () const
 Returns the levelfile that loaded this object.
const SmartPtr< Gametype > & getGametype () const
const SmartPtr< Level > & getLevel () const
const std::stringgetLoaderIndentation () const
 Returns the indentation of the debug output in the Loader.
const std::stringgetMainStateName () const
 Returns the name of the main state.
const std::stringgetName () const
 Returns the name of the object.
NamespacegetNamespace () const
GametypegetOldGametype () const
const std::stringgetOldName () const
 Returns the old name of the object.
const SmartPtr< Scene > & getScene () const
virtual uint32_t getSceneID () const
const std::set< Template * > & getTemplates () const
 Returns the set of all aplied templates.
const mboolisActive () const
 Returns the state of the objects activity.
bool isInitialized () const
 Returns if the object was initialized (passed the object registration).
const mboolisVisible () const
 Returns the state of the objects visibility.
virtual void processEvent (Event &event)
 Processing an event by calling the right main state.
void removeEventSource (BaseObject *source)
 Removes an eventsource (but doesn't unregister itself at the source).
void setActive (bool bActive)
 Sets the state of the objects activity.
void setCreator (BaseObject *creator)
void setFile (const XMLFile *file)
 Sets a pointer to the xml file that loaded this object.
void setGametype (const SmartPtr< Gametype > &gametype)
void setLevel (const SmartPtr< Level > &level)
void setLoaderIndentation (const std::string &indentation)
 Sets the indentation of the debug output in the Loader.
void setMainState (bool state)
 Sets the main state of the object to a given boolean value.
void setMainStateName (const std::string &name)
 Sets the name of the main state (used for event reactions).
void setName (const std::string &name)
 Sets the name of the object.
virtual void setNamespace (Namespace *ns)
void setScene (const SmartPtr< Scene > &scene, uint32_t sceneID)
void setVisible (bool bVisible)
 Sets the state of the objects visibility.
virtual void XMLEventPort (Element &xmlelement, XMLPort::Mode mode)
 Defines the possible event states of this object and parses eventsources from an XML file.
virtual void XMLPort (Element &xmlelement, XMLPort::Mode mode)
 XML loading and saving.

Static Public Member Functions

static void loadAllEventStates (Element &xmlelement, XMLPort::Mode mode, BaseObject *object, Identifier *identifier)
 Manually loads all event states, even if the class doesn't officially support them.

Protected Member Functions

void addEventState (const std::string &name, EventState *container)
 Adds a new event-state to the object.
EventStategetEventState (const std::string &name) const
 Returns the event-state with the given name.

Protected Attributes

mbool bActive_
 True = the object is active.
mbool bVisible_
 True = the object is visible.
FunctorPtr mainStateFunctor_
std::string mainStateName_
std::string name_
 The name of the object.
std::set< std::stringnetworkTemplateNames_
std::string oldName_
 The old name of the object.

Private Member Functions

const std::stringgetSingleTemplate (void) const
 Returns the name of the first Template.
TemplategetTemplate (unsigned int index) const
 Returns the Template with the given index.
void registerEventListener (BaseObject *object)
 Adds an object which listens to the events of this object.
void registerEventStates ()
 Calls XMLEventPort with an empty XML-element to register the event states if necessary.
void setXMLName (const std::string &name)
 Loads the name of the object through XML and calls all XMLNameListener.
void unregisterEventListener (BaseObject *object)
 Removes an event listener from this object.

Private Attributes

bool bInitialized_
 True if the object was initialized (passed the object registration).
bool bRegisteredEventStates_
 Becomes true after the object registered its event states (with XMLEventPort).
BaseObjectcreator_
std::set< BaseObject * > eventListeners_
 List of objects which listen to the events of this object.
std::set< BaseObject * > eventListenersXML_
 List of objects which listen to the events of this object through the "eventlisteners" subsection in XML.
std::map< BaseObject
*, std::string
eventSources_
 List of objects which send events to this object, mapped to the state which they affect.
std::map< std::string,
EventState * > 
eventStates_
 Maps the name of the event states to their helper objects.
const XMLFilefile_
 The XMLFile that loaded this object.
SmartPtr< Gametypegametype_
Element * lastLoadedXMLElement_
 Non 0 if the TinyXML attributes have already been copied to our own lowercase map.
SmartPtr< Levellevel_
std::string loaderIndentation_
 Indentation of the debug output in the Loader.
Namespacenamespace_
GametypeoldGametype_
SmartPtr< Scenescene_
uint32_t sceneID_
std::set< Template * > templates_
std::map< std::string,
std::string
xmlAttributes_
 Lowercase XML attributes.

Friends

class XMLPortClassParamContainer

Detailed Description

The BaseObject is the parent of all classes representing an instance in the game.


Constructor & Destructor Documentation

orxonox::BaseObject::BaseObject ( BaseObject creator  ) 

Constructor: Registers the object in the BaseObject-list.

orxonox::BaseObject::~BaseObject (  )  [virtual]

Destructor.


Member Function Documentation

void orxonox::BaseObject::addEventListener ( BaseObject listener  ) 

Adds an object which listens to the events of this object.

The events are sent to the other objects mainstate.

void orxonox::BaseObject::addEventSource ( BaseObject source,
const std::string state 
)

Adds a new event source for a specific state.

Parameters:
source The object which sends events to this object
state The state of this object which will be affected by the events
void orxonox::BaseObject::addEventState ( const std::string name,
EventState state 
) [protected]

Adds a new event-state to the object.

Event-states are states which can be changed by events.

Parameters:
name The name of the event
state The object containing information about the event-state
void orxonox::BaseObject::addTemplate ( Template temp  ) 

Adds a Template to the object.

Parameters:
temp The Template
void orxonox::BaseObject::addTemplate ( const std::string name  ) 

Adds a Template to the object.

Parameters:
name The name of the Template
virtual void orxonox::BaseObject::changedActivity ( void   )  [inline, virtual]
virtual void orxonox::BaseObject::changedGametype (  )  [inline, virtual]
virtual void orxonox::BaseObject::changedLevel (  )  [inline, virtual]
void orxonox::BaseObject::changedMainStateName (  )  [virtual]

This function gets called if the main state name of the object changes.

virtual void orxonox::BaseObject::changedName ( void   )  [inline, virtual]
void orxonox::BaseObject::fireEvent ( Event event  ) 

Fires an event, using the Event struct.

void orxonox::BaseObject::fireEvent ( bool  activate,
BaseObject originator,
const std::string name = "" 
)

Fires an event which activates or deactivates a state with agiven originator (the object which triggered the event).

void orxonox::BaseObject::fireEvent ( bool  activate,
const std::string name = "" 
)

Fires an event which activates or deactivates a state.

void orxonox::BaseObject::fireEvent ( const std::string name = ""  ) 

Fires an event (without a state).

BaseObject* orxonox::BaseObject::getCreator (  )  const [inline]
BaseObject * orxonox::BaseObject::getEventListener ( unsigned int  index  )  const

Returns an event listener with a given index.

BaseObject * orxonox::BaseObject::getEventSource ( unsigned int  index,
const std::string state 
) const

Returns an eventsource with a given index.

EventState * orxonox::BaseObject::getEventState ( const std::string name  )  const [protected]

Returns the event-state with the given name.

const XMLFile* orxonox::BaseObject::getFile (  )  const [inline]

Returns a pointer to the XMLFile that loaded this object.

Returns:
The XMLFile
const std::string & orxonox::BaseObject::getFilename (  )  const

Returns the levelfile that loaded this object.

Returns:
The levelfile
const SmartPtr<Gametype>& orxonox::BaseObject::getGametype (  )  const [inline]
const SmartPtr<Level>& orxonox::BaseObject::getLevel (  )  const [inline]
const std::string& orxonox::BaseObject::getLoaderIndentation (  )  const [inline]

Returns the indentation of the debug output in the Loader.

Returns:
The indentation
const std::string& orxonox::BaseObject::getMainStateName (  )  const [inline]

Returns the name of the main state.

const std::string& orxonox::BaseObject::getName ( void   )  const [inline]

Returns the name of the object.

Reimplemented in orxonox::NotificationQueue.

Namespace* orxonox::BaseObject::getNamespace (  )  const [inline]
Gametype* orxonox::BaseObject::getOldGametype (  )  const [inline]
const std::string& orxonox::BaseObject::getOldName (  )  const [inline]

Returns the old name of the object.

const SmartPtr<Scene>& orxonox::BaseObject::getScene (  )  const [inline]
virtual uint32_t orxonox::BaseObject::getSceneID (  )  const [inline, virtual]

Reimplemented in orxonox::Scene.

const std::string & orxonox::BaseObject::getSingleTemplate ( void   )  const [private]

Returns the name of the first Template.

Returns:
The name as string.
Template * orxonox::BaseObject::getTemplate ( unsigned int  index  )  const [private]

Returns the Template with the given index.

Parameters:
index The index
const std::set<Template*>& orxonox::BaseObject::getTemplates (  )  const [inline]

Returns the set of all aplied templates.

const mbool& orxonox::BaseObject::isActive ( void   )  const [inline]

Returns the state of the objects activity.

Returns:
The state of the activity

Reimplemented in orxonox::MultiTrigger, orxonox::Trigger, and orxonox::TriggerBase.

bool orxonox::BaseObject::isInitialized (  )  const [inline]

Returns if the object was initialized (passed the object registration).

Returns:
True was the object is initialized

Reimplemented in orxonox::Bot, orxonox::HumanPlayer, and orxonox::PlayerInfo.

const mbool& orxonox::BaseObject::isVisible (  )  const [inline]

Returns the state of the objects visibility.

Returns:
The state of the visibility
void orxonox::BaseObject::loadAllEventStates ( Element &  xmlelement,
XMLPort::Mode  mode,
BaseObject object,
Identifier identifier 
) [static]

Manually loads all event states, even if the class doesn't officially support them.

This is needed by some classes like EventDispatcher or EventTarget.

void orxonox::BaseObject::processEvent ( Event event  )  [virtual]

Processing an event by calling the right main state.

Parameters:
event The event struct which contains the information about the event

Reimplemented in orxonox::Attacher, orxonox::EventDispatcher, orxonox::EventFilter, orxonox::EventListener, and orxonox::EventTarget.

void orxonox::BaseObject::registerEventListener ( BaseObject object  )  [private]

Adds an object which listens to the events of this object.

void orxonox::BaseObject::registerEventStates (  )  [private]

Calls XMLEventPort with an empty XML-element to register the event states if necessary.

void orxonox::BaseObject::removeEventSource ( BaseObject source  ) 

Removes an eventsource (but doesn't unregister itself at the source).

void orxonox::BaseObject::setActive ( bool  bActive  )  [inline]

Sets the state of the objects activity.

Parameters:
bActive True = active

Reimplemented in orxonox::QuestEffectBeacon.

void orxonox::BaseObject::setCreator ( BaseObject creator  )  [inline]
void orxonox::BaseObject::setFile ( const XMLFile file  )  [inline]

Sets a pointer to the xml file that loaded this object.

Parameters:
file The pointer to the XMLFile
void orxonox::BaseObject::setGametype ( const SmartPtr< Gametype > &  gametype  )  [inline]
void orxonox::BaseObject::setLevel ( const SmartPtr< Level > &  level  )  [inline]
void orxonox::BaseObject::setLoaderIndentation ( const std::string indentation  )  [inline]

Sets the indentation of the debug output in the Loader.

Parameters:
indentation The indentation
void orxonox::BaseObject::setMainState ( bool  state  ) 

Sets the main state of the object to a given boolean value.

Note: The main state of an object can be set with the setMainStateName function. It's part of the eventsystem and used for event forwarding (when the target object can't specify a specific state, the main state is used by default).

void orxonox::BaseObject::setMainStateName ( const std::string name  )  [inline]

Sets the name of the main state (used for event reactions).

void orxonox::BaseObject::setName ( const std::string name  )  [inline]

Sets the name of the object.

Parameters:
name The name

Reimplemented in orxonox::NotificationQueue.

virtual void orxonox::BaseObject::setNamespace ( Namespace ns  )  [inline, virtual]
void orxonox::BaseObject::setScene ( const SmartPtr< Scene > &  scene,
uint32_t  sceneID 
) [inline]
void orxonox::BaseObject::setVisible ( bool  bVisible  )  [inline]

Sets the state of the objects visibility.

Parameters:
bVisible True = visible
void orxonox::BaseObject::setXMLName ( const std::string name  )  [private]

Loads the name of the object through XML and calls all XMLNameListener.

Parameters:
name The name of the object
void orxonox::BaseObject::unregisterEventListener ( BaseObject object  )  [inline, private]

Removes an event listener from this object.

void orxonox::BaseObject::XMLEventPort ( Element &  xmlelement,
XMLPort::Mode  mode 
) [virtual]

Defines the possible event states of this object and parses eventsources from an XML file.

Parameters:
xmlelement The XML-element
mode The mode defines the operation that is being executed: loading or saving the object (from or to XML respectively)

Reimplemented in orxonox::Dock, orxonox::NotificationDispatcher, orxonox::Script, orxonox::EventMultiTrigger, orxonox::EventTrigger, orxonox::PortalEndPoint, orxonox::QuestEffectBeacon, orxonox::ParticleSpawner, orxonox::WorldAmbientSound, and orxonox::WorldSound.

void orxonox::BaseObject::XMLPort ( Element &  xmlelement,
XMLPort::Mode  mode 
) [virtual]

XML loading and saving.

Parameters:
xmlelement The XML-element
mode The mode defines the operation that is being executed: loading or saving the object (from or to XML respectively)

Reimplemented in orxonox::Namespace, orxonox::Template, orxonox::ResourceCollection, orxonox::ResourceLocation, orxonox::CreateStars, orxonox::Dock, orxonox::DockingTarget, orxonox::DockToShip, orxonox::OldRaceCheckPoint, orxonox::RaceCheckPoint, orxonox::SpaceRaceController, orxonox::SpaceRaceManager, orxonox::CommandNotification, orxonox::SimpleNotification, orxonox::NotificationDispatcher, orxonox::NotificationQueue, orxonox::NotificationQueueCEGUI, orxonox::Attacher, orxonox::BoxCollisionShape, orxonox::ConeCollisionShape, orxonox::PlaneCollisionShape, orxonox::SphereCollisionShape, orxonox::EventDispatcher, orxonox::EventFilter, orxonox::EventListener, orxonox::EventTarget, orxonox::ForceField, orxonox::Planet, orxonox::Script, orxonox::SpaceBoundaries, orxonox::CheckPoint, orxonox::DistanceMultiTrigger, orxonox::DistanceTrigger, orxonox::EventMultiTrigger, orxonox::MultiTrigger, orxonox::Trigger, orxonox::TriggerBase, orxonox::Turret, orxonox::FadeoutText, orxonox::GUIOverlay, orxonox::BarColour, orxonox::HUDBar, orxonox::HUDHealthBar, orxonox::HUDNavigation, orxonox::HUDRadar, orxonox::LastManStandingInfos, orxonox::LastTeamStandingInfos, orxonox::TeamBaseMatchScore, orxonox::OverlayText, orxonox::DamageBoostPickup, orxonox::DronePickup, orxonox::HealthPickup, orxonox::InvisiblePickup, orxonox::MetaPickup, orxonox::ShieldPickup, orxonox::ShrinkPickup, orxonox::SpeedPickup, orxonox::Pickup, orxonox::PickupCollection, orxonox::PickupRepresentation, orxonox::PickupSpawner, orxonox::PongCenterpoint, orxonox::PongScore, orxonox::PortalEndPoint, orxonox::PortalLink, orxonox::AddQuest, orxonox::AddQuestHint, orxonox::AddReward, orxonox::ChangeQuestStatus, orxonox::CompleteQuest, orxonox::FailQuest, orxonox::GlobalQuest, orxonox::LocalQuest, orxonox::Quest, orxonox::QuestDescription, orxonox::QuestEffectBeacon, orxonox::QuestHint, orxonox::QuestItem, orxonox::QuestListener, orxonox::TetrisCenterpoint, orxonox::TetrisScore, orxonox::TowerDefenseCenterpoint, orxonox::TowerDefenseController, orxonox::TowerDefenseHUDController, orxonox::EnergyDrink, orxonox::HsW01, orxonox::CollisionShape, orxonox::CompoundCollisionShape, orxonox::ArtificialController, orxonox::FormationController, orxonox::WaypointPatrolController, orxonox::AnimatedModel, orxonox::Backlight, orxonox::Billboard, orxonox::BlinkingBillboard, orxonox::FadingBillboard, orxonox::GlobalShader, orxonox::Light, orxonox::MeshLodInformation, orxonox::Model, orxonox::ParticleEmitter, orxonox::ParticleSpawner, orxonox::Engine, orxonox::MultiStateEngine, orxonox::Level, orxonox::LevelInfo, orxonox::GUISheet, orxonox::OrxonoxOverlay, orxonox::OverlayGroup, orxonox::Scene, orxonox::WorldAmbientSound, orxonox::WorldSound, orxonox::DefaultWeaponmodeLink, orxonox::Weapon, orxonox::WeaponMode, orxonox::WeaponPack, orxonox::WeaponSet, orxonox::CameraPosition, orxonox::ControllableEntity, orxonox::Drone, orxonox::EffectContainer, orxonox::MobileEntity, orxonox::MovableEntity, orxonox::FpsPlayer, orxonox::Pawn, orxonox::SpaceShip, orxonox::SpawnPoint, orxonox::TeamSpawnPoint, and orxonox::WorldEntity.


Friends And Related Function Documentation

friend class XMLPortClassParamContainer [friend]

Member Data Documentation

True if the object was initialized (passed the object registration).

Becomes true after the object registered its event states (with XMLEventPort).

True = the object is visible.

List of objects which listen to the events of this object.

List of objects which listen to the events of this object through the "eventlisteners" subsection in XML.

List of objects which send events to this object, mapped to the state which they affect.

Maps the name of the event states to their helper objects.

The XMLFile that loaded this object.

Non 0 if the TinyXML attributes have already been copied to our own lowercase map.

Indentation of the debug output in the Loader.

The name of the object.

Reimplemented in orxonox::PickupRepresentation.

The old name of the object.

uint32_t orxonox::BaseObject::sceneID_ [private]

Lowercase XML attributes.


The documentation for this class was generated from the following files:
Generated on Tue May 21 06:35:06 2013 for Orxonox by  doxygen 1.6.3