Changeset 2909 for code/trunk/src/orxonox/objects/quest/QuestManager.cc
- Timestamp:
- Apr 8, 2009, 1:07:27 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/quest/QuestManager.cc
r2896 r2909 28 28 29 29 /** 30 @file 30 @file QuestManager.cc 31 31 @brief Implementation of the QuestManager class. 32 32 */ … … 43 43 namespace orxonox 44 44 { 45 //! All Quests registered by their id's. 46 std::map<std::string, Quest*> QuestManager::questMap_s; 47 //! All QuestHints registered by their id's. 48 std::map<std::string, QuestHint*> QuestManager::hintMap_s; 45 //! Pointer to the current (and single) instance of this class. 46 QuestManager* QuestManager::singletonRef_s = NULL; 49 47 50 48 /** 51 49 @brief 52 50 Constructor. Registers the object. 53 */ 54 QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator) 55 { 56 RegisterObject(QuestManager); 51 @todo 52 Is inheriting from BaseObject proper? 53 */ 54 QuestManager::QuestManager() 55 { 56 RegisterRootObject(QuestManager); 57 58 assert(singletonRef_s == 0); 59 singletonRef_s = this; 57 60 } 58 61 … … 64 67 { 65 68 69 } 70 71 /** 72 @brief 73 Returns a reference to the current (and single) instance of the QuestManager, and creates one if there isn't one to begin with. 74 @return 75 Returns a reference to the single instance of the Quest Manager. 76 */ 77 /*static*/ QuestManager & QuestManager::getInstance() 78 { 79 assert(singletonRef_s); 80 return *singletonRef_s; 66 81 } 67 82 … … 75 90 Returns true if successful, false if not. 76 91 */ 77 /*static*/bool QuestManager::registerQuest(Quest* quest)92 bool QuestManager::registerQuest(Quest* quest) 78 93 { 79 94 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. … … 84 99 85 100 std::pair<std::map<std::string, Quest*>::iterator,bool> result; 86 result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.101 result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest. 87 102 88 103 if(result.second) //!< If inserting was a success. … … 107 122 Returns true if successful, false if not. 108 123 */ 109 /*static*/bool QuestManager::registerHint(QuestHint* hint)124 bool QuestManager::registerHint(QuestHint* hint) 110 125 { 111 126 if(hint == NULL) //!< Still not liking NULL-pointers. … … 116 131 117 132 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; 118 result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.133 result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint. 119 134 120 135 if(result.second) //!< If inserting was a success. … … 141 156 Throws an exception if the given questId is invalid. 142 157 */ 143 /*static*/Quest* QuestManager::findQuest(const std::string & questId)158 Quest* QuestManager::findQuest(const std::string & questId) 144 159 { 145 160 if(!QuestItem::isId(questId)) //!< Check vor validity of the given id. … … 149 164 150 165 Quest* quest; 151 std::map<std::string, Quest*>::iterator it = questMap_s.find(questId);152 if (it != questMap_s.end()) //!< If the Quest is registered.166 std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId); 167 if (it != this->questMap_.end()) //!< If the Quest is registered. 153 168 { 154 169 quest = it->second; … … 175 190 Throws an exception if the given hintId is invalid. 176 191 */ 177 /*static*/QuestHint* QuestManager::findHint(const std::string & hintId)192 QuestHint* QuestManager::findHint(const std::string & hintId) 178 193 { 179 194 if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id. … … 183 198 184 199 QuestHint* hint; 185 std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId);186 if (it != hintMap_s.end()) //!< If the QuestHint is registered.200 std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId); 201 if (it != this->hintMap_.end()) //!< If the QuestHint is registered. 187 202 { 188 203 hint = it->second;
Note: See TracChangeset
for help on using the changeset viewer.