[Orxonox-commit 2229] r6945 - in code/branches/presentation3/src: modules/questsystem modules/questsystem/notifications orxonox/interfaces
dafrick at orxonox.net
dafrick at orxonox.net
Thu May 20 22:36:49 CEST 2010
Author: dafrick
Date: 2010-05-20 22:36:48 +0200 (Thu, 20 May 2010)
New Revision: 6945
Modified:
code/branches/presentation3/src/modules/questsystem/AddQuest.cc
code/branches/presentation3/src/modules/questsystem/AddQuestHint.cc
code/branches/presentation3/src/modules/questsystem/AddReward.cc
code/branches/presentation3/src/modules/questsystem/CompleteQuest.cc
code/branches/presentation3/src/modules/questsystem/FailQuest.cc
code/branches/presentation3/src/modules/questsystem/GlobalQuest.cc
code/branches/presentation3/src/modules/questsystem/LocalQuest.cc
code/branches/presentation3/src/modules/questsystem/Quest.cc
code/branches/presentation3/src/modules/questsystem/QuestDescription.cc
code/branches/presentation3/src/modules/questsystem/QuestDescription.h
code/branches/presentation3/src/modules/questsystem/QuestEffectBeacon.cc
code/branches/presentation3/src/modules/questsystem/QuestGUI.cc
code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc
code/branches/presentation3/src/modules/questsystem/QuestHint.cc
code/branches/presentation3/src/modules/questsystem/QuestItem.cc
code/branches/presentation3/src/modules/questsystem/QuestItem.h
code/branches/presentation3/src/modules/questsystem/QuestListener.cc
code/branches/presentation3/src/modules/questsystem/QuestManager.cc
code/branches/presentation3/src/modules/questsystem/QuestNotification.cc
code/branches/presentation3/src/modules/questsystem/QuestNotification.h
code/branches/presentation3/src/modules/questsystem/notifications/Notification.cc
code/branches/presentation3/src/modules/questsystem/notifications/Notification.h
code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc
code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.h
code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.cc
code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.h
code/branches/presentation3/src/orxonox/interfaces/NotificationListener.h
Log:
A lot of cleanup, mostly increasing output levels, which means, that the console is no longer cluttered by lots and lots of Quest-stuff (the log file still is, but that should be ok...).
Also some possible bugs (or let's say pitfalls) removed, which have been around for a long time and didn't cause any problems so far. Now they never will.
Also, regarding my previous commit. Quests seem tu work just fine, even the second time the level is loaded, which is awesome.
Ergo: Questsystem/Notificationsystem segfault upon loading a level with Quests/Notifications in it twice is now officially resolved.
Modified: code/branches/presentation3/src/modules/questsystem/AddQuest.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/AddQuest.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/AddQuest.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -67,7 +67,7 @@
{
SUPER(AddQuest, XMLPort, xmlelement, mode);
- COUT(3) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
+ COUT(4) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
}
/**
@@ -86,7 +86,7 @@
return false;
}
- COUT(3) << "AddQuest on player: " << player << " ." << std::endl;
+ COUT(5) << "AddQuest on player: " << player << " ." << std::endl;
try
{
@@ -102,7 +102,7 @@
return false;
}
- COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl;
+ COUT(4) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/AddQuestHint.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/AddQuestHint.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/AddQuestHint.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -71,7 +71,7 @@
XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
- COUT(3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;
+ COUT(4) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;
}
/**
@@ -110,7 +110,7 @@
return false;
}
- COUT(3) << "AddQuestHint on player: " << player << " ." << std::endl;
+ COUT(5) << "AddQuestHint on player: " << player << " ." << std::endl;
try
{
@@ -126,7 +126,7 @@
return false;
}
- COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl;
+ COUT(4) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/AddReward.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/AddReward.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/AddReward.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -67,7 +67,7 @@
XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
- COUT(3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;
+ COUT(4) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;
}
/**
@@ -102,7 +102,7 @@
*/
bool AddReward::invoke(PlayerInfo* player)
{
- COUT(3) << "AddReward on player: " << player << " ." << std::endl;
+ COUT(5) << "AddReward on player: " << player << " ." << std::endl;
bool check = true;
for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
@@ -110,7 +110,7 @@
check = check && (*reward)->reward(player);
}
- COUT(3) << "Rewardable successfully added to player." << player << " ." << std::endl;
+ COUT(4) << "Rewardable successfully added to player." << player << " ." << std::endl;
return check;
}
Modified: code/branches/presentation3/src/modules/questsystem/CompleteQuest.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/CompleteQuest.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/CompleteQuest.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -67,7 +67,7 @@
{
SUPER(CompleteQuest, XMLPort, xmlelement, mode);
- COUT(3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
+ COUT(4) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
}
/**
@@ -86,7 +86,7 @@
return false;
}
- COUT(3) << "CompleteQuest on player: " << player << " ." << std::endl;
+ COUT(5) << "CompleteQuest on player: " << player << " ." << std::endl;
Quest* quest;
@@ -104,7 +104,7 @@
return false;
}
- COUT(3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;
+ COUT(4) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/FailQuest.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/FailQuest.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/FailQuest.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -67,7 +67,7 @@
{
SUPER(FailQuest, XMLPort, xmlelement, mode);
- COUT(3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
+ COUT(4) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
}
/**
@@ -86,7 +86,7 @@
return false;
}
- COUT(3) << "FailQuest on player: " << player << " ." << std::endl;
+ COUT(4) << "FailQuest on player: " << player << " ." << std::endl;
Quest* quest;
try
@@ -103,7 +103,7 @@
return false;
}
- COUT(3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
+ COUT(4) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/GlobalQuest.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/GlobalQuest.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/GlobalQuest.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -69,7 +69,7 @@
XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode);
- COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
+ COUT(4) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
}
/**
@@ -252,7 +252,7 @@
this->rewards_.push_back(effect); //!< Add the QuestEffect to the list.
- COUT(3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;
+ COUT(4) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/LocalQuest.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/LocalQuest.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/LocalQuest.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -67,7 +67,7 @@
{
SUPER(LocalQuest, XMLPort, xmlelement, mode);
- COUT(3) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
+ COUT(4) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
}
/**
Modified: code/branches/presentation3/src/modules/questsystem/Quest.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/Quest.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/Quest.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -98,7 +98,7 @@
this->parentQuest_ = quest;
- COUT(3) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+ COUT(4) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
@@ -121,7 +121,7 @@
quest->setParentQuest(this); //!< Sets the currentQuest (this) as parentquest for the added subquest.
this->subQuests_.push_back(quest); //!< Adds the Quest to the end of the list of subquests.
- COUT(3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+ COUT(4) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
@@ -145,7 +145,7 @@
hint->setQuest(this); //!< Sets the current Quest (this) as Quest for the added QuestHint.
this->hints_.push_back(hint); //!< Adds the QuestHint to the end of the list of QuestHints.
- COUT(3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+ COUT(4) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
@@ -167,7 +167,7 @@
this->failEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of fail QuestEffects.
- COUT(3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;
+ COUT(4) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
@@ -189,7 +189,7 @@
this->completeEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of complete QuestEffects.
- COUT(3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;
+ COUT(4) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/QuestDescription.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestDescription.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestDescription.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -73,7 +73,7 @@
XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
- COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
+ COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
}
/**
@@ -88,7 +88,7 @@
@todo
Make sure the messages meet the conditions.
*/
- bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
+ bool QuestDescription::notificationHelper(const std::string & item, const std::string & status)
{
std::string message;
if(item == "hint")
@@ -121,7 +121,7 @@
return false;
}
- QuestNotification* notification = new QuestNotification(message);
+ QuestNotification* notification = new QuestNotification(this, message);
notification->send();
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/QuestDescription.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestDescription.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestDescription.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -82,42 +82,42 @@
@brief Returns the fail message.
@return Returns a string containing the fail message of the QuestDescription.
*/
- inline const std::string & getFailMessage(void) const
+ inline const std::string & getFailMessage(void)
{ return this->failMessage_; }
/**
@brief Returns the complete message.
@return Returns a string containing the complete message of the QuestDescription.
*/
- inline const std::string & getCompleteMessage(void) const
+ inline const std::string & getCompleteMessage(void)
{ return this->completeMessage_; }
/**
@brief Sends a Notification displaying that a QuestHint was added.
@return Returns true if successful.
*/
- inline bool sendAddHintNotification(void) const
+ inline bool sendAddHintNotification(void)
{ return notificationHelper("hint", ""); }
/**
@brief Sends a Notification displaying that a Quest was added.
@return Returns true if successful.
*/
- inline bool sendAddQuestNotification(void) const
+ inline bool sendAddQuestNotification(void)
{ return notificationHelper("quest", "start"); }
/**
@brief Sends a Notification displaying that a Quest was failed.
@return Returns true if successful.
*/
- inline bool sendFailQuestNotification(void) const
+ inline bool sendFailQuestNotification(void)
{ return notificationHelper("quest", "fail"); }
/**
@brief Sends a Notification displaying that a Quest was completed.
@return Returns true if successful.
*/
- inline bool sendCompleteQuestNotification(void) const
+ inline bool sendCompleteQuestNotification(void)
{ return notificationHelper("quest", "complete"); }
private:
@@ -126,7 +126,7 @@
std::string failMessage_; //!< The message displayed when the Quest is failed.
std::string completeMessage_; //!< The message displayed when the Quest is completed.
- bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications.
+ bool notificationHelper(const std::string & item, const std::string & status); //!< Helper for sending QuestDescriptions as Notifications.
/**
@brief Sets the title.
Modified: code/branches/presentation3/src/modules/questsystem/QuestEffectBeacon.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestEffectBeacon.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestEffectBeacon.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -77,7 +77,7 @@
XMLPortEventSink(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers.
- COUT(3) << "New QuestEffectBeacon created." << std::endl;
+ COUT(4) << "New QuestEffectBeacon created." << std::endl;
}
void QuestEffectBeacon::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -133,7 +133,7 @@
if(pawn == NULL)
{
- COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+ COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
return false;
}
@@ -146,7 +146,7 @@
return false;
}
- COUT(3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;
+ COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;
bool check = QuestEffect::invokeEffects(player, this->effects_); //!< Invoke the QuestEffects on the PlayerInfo.
if(check)
@@ -248,7 +248,7 @@
this->effects_.push_back(effect);
- COUT(3) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;
+ COUT(4) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;
return true;
}
Modified: code/branches/presentation3/src/modules/questsystem/QuestGUI.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestGUI.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestGUI.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -100,7 +100,7 @@
*/
void QuestGUI::update(void)
{
- COUT(3) << "Updating QuestGUI..." << std::endl;
+ COUT(4) << "Updating QuestGUI..." << std::endl;
this->clear(); //!< Clear the GUI.
@@ -121,7 +121,7 @@
index = createNode(this->root_, quest, depth, index);
}
}
- COUT(3) << "Updating QuestGUI done." << std::endl;
+ COUT(4) << "Updating QuestGUI done." << std::endl;
}
/**
@@ -130,7 +130,7 @@
*/
void QuestGUI::clear(void)
{
- COUT(3) << "Clearing QuestGUI..." << std::endl;
+ COUT(4) << "Clearing QuestGUI..." << std::endl;
//! Clear all nodes.
for(std::map<CEGUI::Window*, QuestGUINode*>::iterator it = this->nodes_.begin(); it != this->nodes_.end(); it++)
Modified: code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -80,7 +80,7 @@
this->createWindow();
- COUT(3) << "New QuestGUINode '" << this->window_->getName() << "' created." << std::endl;
+ COUT(4) << "New QuestGUINode '" << this->window_->getName() << "' created." << std::endl;
}
/**
@@ -268,7 +268,7 @@
}
}
- COUT(3) << "Show Details: " << this->details_->getName() << std::endl;
+ COUT(4) << "Show Details: " << this->details_->getName() << std::endl;
}
return this->details_;
@@ -280,7 +280,7 @@
*/
bool QuestGUINode::openDetails(const CEGUI::EventArgs& e)
{
- COUT(3) << "Open QuestItem..." << std::endl;
+ COUT(4) << "Open QuestItem..." << std::endl;
//CEGUI::Window* window = this->gui_->getRootWindow();
CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
Modified: code/branches/presentation3/src/modules/questsystem/QuestHint.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestHint.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestHint.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -72,7 +72,7 @@
QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager.
- COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
+ COUT(4) << "New QuestHint {" << this->getId() << "} created." << std::endl;
}
@@ -125,12 +125,12 @@
}
else
{
- COUT(2) << "An already active questHint was trying to get activated." << std::endl;
+ COUT(4) << "An already active questHint was trying to get activated." << std::endl;
return false;
}
}
- COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
+ COUT(4) << "A hint of a non-active quest was trying to get activated." << std::endl;
return false;
}
Modified: code/branches/presentation3/src/modules/questsystem/QuestItem.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestItem.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestItem.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -39,6 +39,9 @@
namespace orxonox
{
+
+ CreateUnloadableFactory(QuestItem);
+
/**
@brief
Constructor. Registers and initializes the object.
Modified: code/branches/presentation3/src/modules/questsystem/QuestItem.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestItem.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestItem.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -71,7 +71,7 @@
@brief Returns the QuestDescription of the QuestItem.
@return Returns a pointer to the QuestDescription object of the QuestItem.
*/
- inline const QuestDescription* getDescription(void) const
+ inline QuestDescription* getDescription(void) const
{ return this->description_; }
/**
Modified: code/branches/presentation3/src/modules/questsystem/QuestListener.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestListener.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestListener.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -76,7 +76,7 @@
if(this->quest_ != NULL)
this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners.
- COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl;
+ COUT(4) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl;
}
/**
Modified: code/branches/presentation3/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestManager.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestManager.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -114,7 +114,7 @@
if(result.second) //!< If inserting was a success.
{
quest->setRegistered();
- COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl;
+ COUT(4) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl;
return true;
}
else
@@ -156,7 +156,7 @@
if(result.second) //!< If inserting was a success.
{
hint->setRegistered();
- COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl;
+ COUT(4) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl;
return true;
}
else
Modified: code/branches/presentation3/src/modules/questsystem/QuestNotification.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestNotification.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestNotification.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -31,32 +31,49 @@
namespace orxonox {
- const std::string QuestNotification::SENDER("questsystem");
+ /*static*/ const std::string QuestNotification::SENDER("questsystem");
+ CreateUnloadableFactory(QuestNotification);
+
+ /**
+ @brief
+ Default Constructor. Creates a useless QuestNotification.
+ */
QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator)
{
- this->initialize();
+ RegisterObject(QuestNotification);
}
- QuestNotification::QuestNotification(const std::string & message) : Notification(message)
+ /**
+ @brief
+ Creates a QuestNotification with the input message.
+ @param message
+ The message to be sent.
+ */
+ QuestNotification::QuestNotification(BaseObject* creator, const std::string & message) : Notification(creator, message)
{
- this->initialize();
+ RegisterObject(QuestNotification);
}
+ /**
+ @brief
+ Destructor.
+ */
QuestNotification::~QuestNotification()
{
}
+ /**
+ @brief
+ Send the QuestNotification.
+ @return
+ Returns true if successful.
+ */
bool QuestNotification::send(void)
{
return this->Notification::send(QuestNotification::SENDER);
}
- void QuestNotification::initialize(void)
- {
- RegisterObject(QuestNotification);
- }
-
}
Modified: code/branches/presentation3/src/modules/questsystem/QuestNotification.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestNotification.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/QuestNotification.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -38,24 +38,22 @@
/**
@brief
-
+ The QuestNotification is a special Notification that has the single property that it is only sent by the questsystem.
@author
Damian 'Mozork' Frick
*/
class _QuestsystemExport QuestNotification : public Notification
{
public:
- QuestNotification(BaseObject* creator);
- QuestNotification(const std::string & message);
- virtual ~QuestNotification();
+ QuestNotification(BaseObject* creator); //!< Default Constructor.
+ QuestNotification(BaseObject* creator, const std::string & message); //!< Constructor.
+ virtual ~QuestNotification(); //!< Destructor.
- bool send(void);
+ bool send(void); //!< Send the QuestNotification.
private:
- static const std::string SENDER;
+ static const std::string SENDER; //!< A string identifying the questsystem as the sender.
- void initialize(void);
-
};
}
Modified: code/branches/presentation3/src/modules/questsystem/notifications/Notification.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/notifications/Notification.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/notifications/Notification.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -39,6 +39,8 @@
namespace orxonox
{
+ CreateUnloadableFactory(Notification);
+
/**
@brief
Default constructor. Initializes the object.
@@ -55,7 +57,7 @@
@param message
The message of the Notification.
*/
- Notification::Notification(const std::string & message) : BaseObject(NULL)
+ Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator)
{
this->message_ = message;
}
@@ -66,6 +68,7 @@
*/
Notification::~Notification()
{
+
}
/**
Modified: code/branches/presentation3/src/modules/questsystem/notifications/Notification.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/notifications/Notification.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/notifications/Notification.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -52,7 +52,7 @@
{
public:
Notification(BaseObject* creator);
- Notification(const std::string & message);
+ Notification(BaseObject* creator, const std::string & message);
virtual ~Notification();
bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE;
Modified: code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -117,17 +117,25 @@
/**
@brief
Unregisters a Notification within the NotificationManager.
+ @param notification
+ A pointer to the Notification to be unregistered.
+ @param listener
+ A pointer to the NotificationListener the Notification is unregistered for.
*/
void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener)
{
assert(notification);
assert(listener);
+ // If the Notification was removed from the list of Notifications of the input NotificationListener, the counter for the Notification of the number of NotificationListeners it is present in is decremented.
if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second)))
this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1;
+
+ // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed.
if(this->listenerCounter_[notification] == (unsigned int) 0)
{
this->removeNotification(notification, this->allNotificationsList_);
+ this->listenerCounter_.erase(notification);
notification->destroy();
}
@@ -137,9 +145,17 @@
/**
@brief
Helper method that removes an input notification form an input map.
+ @param notification
+ A pointer to the notification to be removed.
+ @param map
+ The map the notification should be removed from.
+ @return
+ Returns true if successful.
*/
bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map)
{
+ // Iterates through all items in the map until the Notification is found.
+ //TODO: Do more efficiently?
for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++)
{
if(it->second == notification)
@@ -221,8 +237,11 @@
this->listenerList_.erase(listener);
this->notificationLists_.erase(identifier);
- delete map;
+ // If the map is not the map of all notifications, delete it.
+ if(map != &this->allNotificationsList_)
+ delete map;
+
COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
}
Modified: code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -59,8 +59,8 @@
NotificationManager();
virtual ~NotificationManager();
- static const std::string ALL;
- static const std::string NONE;
+ static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
+ static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager.
@@ -98,9 +98,8 @@
std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with.
- bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map);
+ bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
-
};
}
Modified: code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.cc 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.cc 2010-05-20 20:36:48 UTC (rev 6945)
@@ -123,7 +123,7 @@
XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlElement, mode);
XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
- COUT(3) << "NotificationQueue created." << std::endl;
+ COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
}
/**
@@ -178,7 +178,7 @@
delete notifications;
- COUT(3) << "NotificationQueue updated." << std::endl;
+ COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl;
}
/**
@@ -201,7 +201,7 @@
this->scroll(Vector2(0.0f,-(1.1f*this->getFontSize())));
}
- COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
+ COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl;
}
/**
@@ -428,6 +428,7 @@
if(this->size_ == 0) //!< You cannot remove anything if the queue is empty.
return false;
+ // Unregister the NotificationQueue with the NotificationManager.
NotificationManager::getInstance().unregisterNotification(container->notification, this);
this->removeElement(container->overlay);
Modified: code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -70,6 +70,7 @@
Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.)
Creating a NotificationQueue through XML goes as follows:
+ Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen.
<NotificationQueue
name = "SuperQueue" //Name of your OverlayQueue.
maxSize = "5" //The maximum size of Notifications displayed.
Modified: code/branches/presentation3/src/orxonox/interfaces/NotificationListener.h
===================================================================
--- code/branches/presentation3/src/orxonox/interfaces/NotificationListener.h 2010-05-20 19:43:45 UTC (rev 6944)
+++ code/branches/presentation3/src/orxonox/interfaces/NotificationListener.h 2010-05-20 20:36:48 UTC (rev 6945)
@@ -46,6 +46,12 @@
{
class Notification;
+ /**
+ @brief
+ NotificationListener interface.
+ @author
+ Fabian 'x3n' Landau
+ */
class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
{
public:
More information about the Orxonox-commit
mailing list