Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.cc @ 10538

Last change on this file since 10538 was 10538, checked in by landauf, 9 years ago

now that the order of initialization is well defined (first identifiers, then singletons) we can safely create singletons right after they are registered (and unload them again when they are unregistered). this reverts changes from r10517

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "CoreStaticInitializationHandler.h"
30
31#include "module/ModuleInstance.h"
32#include "class/IdentifierManager.h"
33
34namespace orxonox
35{
36    void CoreStaticInitializationHandler::setupHandler()
37    {
38        // TODO
39    }
40
41    void CoreStaticInitializationHandler::shutdownHandler()
42    {
43        // TODO
44    }
45
46    void CoreStaticInitializationHandler::loadModule(ModuleInstance* module)
47    {
48        this->loadInstances(module);
49        if (this->bInitInstances_)
50            this->initInstances(module);
51    }
52
53    void CoreStaticInitializationHandler::loadInstances(ModuleInstance* module)
54    {
55        // the order of initialization is important
56        module->loadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER);
57        module->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
58        module->loadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER);
59        module->loadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT);
60        module->loadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
61    }
62
63    void CoreStaticInitializationHandler::initInstances(ModuleInstance* module)
64    {
65        IdentifierManager::getInstance().createClassHierarchy();
66    }
67
68    void CoreStaticInitializationHandler::unloadModule(ModuleInstance* module)
69    {
70        // inverted order of initialization
71        module->unloadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
72        module->unloadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT);
73        module->unloadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER);
74        module->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
75        module->unloadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER);
76    }
77}
Note: See TracBrowser for help on using the repository browser.