orxonox::QuestListener Class Reference

Provides a way to react to the starting, completing and failing of Quests. More...

#include <src/orxonox/objects/quest/QuestListener.h>

Inheritance diagram for orxonox::QuestListener:

orxonox::BaseObject orxonox::OrxonoxClass

List of all members.

Public Member Functions

bool execute (void)
 Executes the QuestListener, resp. fires an Event.
std::string getMode (void)
 Get the mode of the QuestListener.
const std::stringgetQuestId (void)
 Get the questId of the Quest the QuestListener reacts to.
 QuestListener (BaseObject *creator)
 Constructor. Registers the object and initializes variables.
bool setMode (const std::string &mode)
 Sets the mode of the QuestListener.
bool setQuestId (const std::string &id)
 Sets the questId of the Quest the QuestListener reacts to.
virtual void XMLPort (Element &xmlelement, XMLPort::Mode mode)
 Method for creating a QuestListener object through XML.
virtual ~QuestListener ()
 Destructor.

Static Public Member Functions

static void advertiseStatusChange (std::list< QuestListener * > &listeners, const std::string &status)
 Makes all QuestListener in the list aware that a certain status change has occured.

Private Attributes

QuestListenerMode::Value mode_
 The mode of the QuestListener.
Questquest_
 A pointer to the Quest the QuestListener is reacting to.


Detailed Description

Provides a way to react to the starting, completing and failing of Quests.

The XML representation goes as follows: You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes.

<BaseObject> // The object that should react to the status change of a Quest. <events> <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity. <QuestListener questid="someQuestId" mode="someMode"> // Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail). </function> </events> </BaseObject>

Author:
Damian 'Mozork' Frick

Constructor & Destructor Documentation

orxonox::QuestListener::QuestListener ( BaseObject creator  ) 

Constructor. Registers the object and initializes variables.

References orxonox::QuestListenerMode::All, mode_, quest_, and RegisterObject.

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

Destructor.


Member Function Documentation

void orxonox::QuestListener::advertiseStatusChange ( std::list< QuestListener * > &  listeners,
const std::string status 
) [static]

Makes all QuestListener in the list aware that a certain status change has occured.

Makes all QuestListener in the list aware that a certain status change has occured and executes them if the status change affects them.

Parameters:
listeners The list of QuestListeners that have to be made aware of the status change.
status The status that has changed. Can be 'start' (if the Quest was started), 'complete' (if the Quest was completed) or 'fail' (if the Quest was failed).

< Iterate through all QuestListeners

< Check whether the status change affects the give QuestListener.

References execute(), and getMode().

Referenced by orxonox::Quest::complete(), orxonox::Quest::fail(), and orxonox::Quest::start().

bool orxonox::QuestListener::execute ( void   ) 

Executes the QuestListener, resp. fires an Event.

Returns:
Returns true if successful.

References orxonox::BaseObject::fireEvent().

Referenced by advertiseStatusChange().

std::string orxonox::QuestListener::getMode ( void   ) 

Get the mode of the QuestListener.

Returns:
Return the mode of the QuestListener. Can be eighter 'all', 'start', 'fail' or 'complete'.

References orxonox::QuestListenerMode::All, orxonox::QuestListenerMode::Complete, COUT, orxonox::QuestListenerMode::Fail, mode_, and orxonox::QuestListenerMode::Start.

Referenced by advertiseStatusChange(), and XMLPort().

const std::string & orxonox::QuestListener::getQuestId ( void   ) 

Get the questId of the Quest the QuestListener reacts to.

Returns:
Returns the questId of the Quest the QuestListener reacts to.

References orxonox::QuestItem::getId(), and quest_.

Referenced by XMLPort().

bool orxonox::QuestListener::setMode ( const std::string mode  ) 

Sets the mode of the QuestListener.

Parameters:
mode The mode to be set. Can be eighter 'all', 'start', 'fail' or 'complete'.
Returns:
Returns true if successful.

References orxonox::QuestListenerMode::All, orxonox::QuestListenerMode::Complete, COUT, orxonox::QuestListenerMode::Fail, mode_, and orxonox::QuestListenerMode::Start.

Referenced by XMLPort().

bool orxonox::QuestListener::setQuestId ( const std::string id  ) 

Sets the questId of the Quest the QuestListener reacts to.

Parameters:
id The questId of the Quest the QUestListener reacts to.
Returns:
Returns true if successful.

< Find the Quest corresponding to the given questId.

< If there is no such Quest.

References orxonox::QuestManager::findQuest(), orxonox::QuestManager::getInstance(), quest_, and ThrowException.

Referenced by XMLPort().

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

Method for creating a QuestListener object through XML.

Method for creating a Quest object through XML.

< Adds the QuestListener to the Quests list of listeners.

Reimplemented from orxonox::BaseObject.

References orxonox::Quest::addListener(), COUT, orxonox::QuestItem::getId(), getMode(), getQuestId(), quest_, setMode(), setQuestId(), SUPER, and XMLPortParam.


Member Data Documentation

The mode of the QuestListener.

Referenced by getMode(), QuestListener(), and setMode().

A pointer to the Quest the QuestListener is reacting to.

Referenced by getQuestId(), QuestListener(), setQuestId(), and XMLPort().


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

Generated on Tue Jul 28 16:22:59 2009 for Orxonox by  doxygen 1.5.6