Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 11, 2010, 11:21:28 AM (14 years ago)
Author:
dafrick
Message:

Adding restriction to possible tags.

Location:
code/branches/releasetodo/src/orxonox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/releasetodo/src/orxonox/LevelInfo.cc

    r7626 r7638  
    4242
    4343    // LevelInfoItem
     44   
     45    //! The list of allowed tags.
     46    /*static*/ std::set<std::string> LevelInfoItem::possibleTags_s = std::set<std::string>();
    4447
    4548    /**
     
    7376    {
    7477
     78    }
     79   
     80    void LevelInfoItem::initializeTags(void)
     81    {
     82        if(!LevelInfoItem::initialized_s)
     83        {
     84            LevelInfoItem::possibleTags_s.insert("test");
     85            LevelInfoItem::possibleTags_s.insert("singleplayer");
     86            LevelInfoItem::possibleTags_s.insert("multiplayer");
     87            LevelInfoItem::possibleTags_s.insert("showcase");
     88            LevelInfoItem::possibleTags_s.insert("tutorial");
     89        }
    7590    }
    7691
     
    103118    bool LevelInfoItem::addTag(const std::string& tag, bool update)
    104119    {
     120        if(!this->validateTag(tag))
     121        {
     122            COUT(2) << "Bad tag '" << tag << "' in " << this->getXMLFilename() << ". Ignoring..." << std::endl;
     123            return false;
     124        }
    105125        bool success = this->tags_.insert(std::string(tag)).second;
    106126        if(update && success)
  • code/branches/releasetodo/src/orxonox/LevelInfo.h

    r7626 r7638  
    3838#include "OrxonoxPrereqs.h"
    3939
     40#include <map>
    4041#include <set>
    4142#include <string>
     
    120121        private:
    121122            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
     123           
     124            static std::set<std::string> possibleTags_s;
     125            static const bool initialized_s = false;
     126            void initializeTags(void);
     127            bool validateTag(const std::string& tag)
     128                { this->initializeTags(); return LevelInfoItem::possibleTags_s.find(tag) != LevelInfoItem::possibleTags_s.end(); }
    122129
    123130            std::string name_; //!< The name of the Level.
Note: See TracChangeset for help on using the changeset viewer.