Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2015, 10:44:57 PM (9 years ago)
Author:
landauf
Message:

Loader is now a singleton instead of a static class. fixes issue with statically initialized ClassTreeMask (which again requires a BaseObject-Identifier)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/Loader.cc

    r10278 r10392  
    4848namespace orxonox
    4949{
    50     std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
    51     ClassTreeMask Loader::currentMask_s;
     50    Loader* Loader::singletonPtr_s = 0;
    5251
    5352    bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
    5453    {
    55         Loader::add(file, mask);
    56         return Loader::load(file, mask, bVerbose);
     54        this->add(file, mask);
     55        return this->load(file, mask, bVerbose);
    5756    }
    5857
    5958    void Loader::close()
    6059    {
    61         Loader::unload();
    62         Loader::files_s.clear();
     60        this->unload();
     61        this->files_.clear();
    6362    }
    6463
    6564    void Loader::close(const XMLFile* file)
    6665    {
    67         Loader::unload(file);
    68         Loader::remove(file);
     66        this->unload(file);
     67        this->remove(file);
    6968    }
    7069
     
    7372        if (!file)
    7473            return;
    75         Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
     74        this->files_.insert(this->files_.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
    7675    }
    7776
     
    8079        if (!file)
    8180            return;
    82         for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
     81        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = this->files_.begin(); it != this->files_.end(); ++it)
    8382        {
    8483            if (it->first == file)
    8584            {
    86                 Loader::files_s.erase(it);
     85                this->files_.erase(it);
    8786                break;
    8887            }
     
    103102    {
    104103        bool success = true;
    105         for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
    106             if (!Loader::load(it->first, it->second * mask, bVerbose))
     104        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = this->files_.begin(); it != this->files_.end(); ++it)
     105            if (!this->load(it->first, it->second * mask, bVerbose))
    107106                success = false;
    108107
     
    133132    bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
    134133    {
    135         Loader::unload(mask);
    136         return Loader::load(mask, bVerbose);
     134        this->unload(mask);
     135        return this->load(mask, bVerbose);
    137136    }
    138137
     
    156155            return false;
    157156
    158         Loader::currentMask_s = file->getMask() * mask;
     157        this->currentMask_ = file->getMask() * mask;
    159158
    160159        std::string xmlInput;
     
    189188                // start of the program.
    190189                // Assumption: the LevelInfo tag does not use Lua scripting
    191                 xmlInput = removeLuaTags(xmlInput);
     190                xmlInput = Loader::removeLuaTags(xmlInput);
    192191            }
    193192        }
     
    198197            {
    199198                orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl;
    200                 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
     199                orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl;
    201200            }
    202201            else
    203202            {
    204203                orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
    205                 orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl;
     204                orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl;
    206205            }
    207206
     
    319318    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
    320319    {
    321         Loader::unload(file, mask);
    322         return Loader::load(file, mask, bVerbose);
     320        this->unload(file, mask);
     321        return this->load(file, mask, bVerbose);
    323322    }
    324323
Note: See TracChangeset for help on using the changeset viewer.