Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (9 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/Loader.cc

    r10278 r10624  
    4848namespace orxonox
    4949{
    50     std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
    51     ClassTreeMask Loader::currentMask_s;
    52 
    53     bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
    54     {
    55         Loader::add(file, mask);
    56         return Loader::load(file, mask, bVerbose);
    57     }
    58 
    59     void Loader::close()
    60     {
    61         Loader::unload();
    62         Loader::files_s.clear();
    63     }
    64 
    65     void Loader::close(const XMLFile* file)
    66     {
    67         Loader::unload(file);
    68         Loader::remove(file);
    69     }
    70 
    71     void Loader::add(const XMLFile* file, const ClassTreeMask& mask)
    72     {
    73         if (!file)
    74             return;
    75         Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
    76     }
    77 
    78     void Loader::remove(const XMLFile* file)
    79     {
    80         if (!file)
    81             return;
    82         for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
    83         {
    84             if (it->first == file)
    85             {
    86                 Loader::files_s.erase(it);
    87                 break;
    88             }
    89         }
    90     }
    91 
    92     /**
    93     @brief
    94         Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
    95     @param mask
    96         A ClassTreeMask, which defines which types of classes are loaded and which aren't.
    97     @param bVerbose
    98         Whether the loader is verbose (prints its progress in a low output level) or not.
    99     @return
    100         Returns true if successful.
    101     */
    102     bool Loader::load(const ClassTreeMask& mask, bool bVerbose)
    103     {
    104         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))
    107                 success = false;
    108 
    109         return success;
    110     }
    111 
    112     void Loader::unload(const ClassTreeMask& mask)
    113     {
    114         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
    115         {
    116             if (mask.isIncluded(it->getIdentifier()))
    117                 (it++)->destroy();
    118             else
    119                 ++it;
    120         }
    121     }
    122 
    123     /**
    124     @brief
    125         Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
    126     @param mask
    127         A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
    128     @param bVerbose
    129         Whether the loader is verbose (prints its progress in a low output level) or not.
    130     @return
    131         Returns true if successful.
    132     */
    133     bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
    134     {
    135         Loader::unload(mask);
    136         return Loader::load(mask, bVerbose);
    137     }
     50    Loader* Loader::singletonPtr_s = 0;
    13851
    13952    /**
     
    15669            return false;
    15770
    158         Loader::currentMask_s = file->getMask() * mask;
     71        this->currentMask_ = file->getMask() * mask;
    15972
    16073        std::string xmlInput;
     
    189102                // start of the program.
    190103                // Assumption: the LevelInfo tag does not use Lua scripting
    191                 xmlInput = removeLuaTags(xmlInput);
     104                xmlInput = Loader::removeLuaTags(xmlInput);
    192105            }
    193106        }
     
    198111            {
    199112                orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl;
    200                 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
     113                orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl;
    201114            }
    202115            else
    203116            {
    204117                orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
    205                 orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl;
     118                orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl;
    206119            }
    207120
     
    220133            rootNamespace->setLoaderIndentation("    ");
    221134            rootNamespace->setFile(file);
    222             rootNamespace->setNamespace(rootNamespace);
    223135            rootNamespace->setRoot(true);
    224136            rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
     
    303215                ++it;
    304216        }
    305     }
    306 
    307     /**
    308     @brief
    309         Reloads the input file, while conforming to the restrictions given by the input ClassTreeMask.
    310     @param file
    311         The file to be reloaded.
    312     @param mask
    313         A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
    314     @param bVerbose
    315         Whether the loader is verbose (prints its progress in a low output level) or not.
    316     @return
    317         Returns true if successful.
    318     */
    319     bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
    320     {
    321         Loader::unload(file, mask);
    322         return Loader::load(file, mask, bVerbose);
    323217    }
    324218
Note: See TracChangeset for help on using the changeset viewer.