Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2015, 11:15:11 PM (9 years ago)
Author:
landauf
Message:

wrap ConsoleCommands in StaticallyInitializedInstances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h

    r10348 r10352  
    223223#include "ConsoleCommandManager.h"
    224224#include "util/VA_NARGS.h"
     225#include "core/module/StaticallyInitializedInstance.h"
    225226
    226227
     
    264265/// Internal macro
    265266#define SetConsoleCommandGeneric(group, name, functor) \
    266     static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor)))
     267    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
     268        = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))))->getCommand()
    267269
    268270
     
    299301/// Internal macro
    300302#define DeclareConsoleCommandGeneric(group, name, functor) \
    301     static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false))
     303    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
     304        = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)))->getCommand()
    302305
    303306
    304307namespace orxonox
    305308{
     309    class _CoreExport StaticallyInitializedConsoleCommand : public StaticallyInitializedInstance
     310    {
     311        public:
     312            StaticallyInitializedConsoleCommand(ConsoleCommand* command) : command_(command) {}
     313
     314            virtual void load();
     315
     316            inline ConsoleCommand& getCommand()
     317                { return *this->command_; }
     318
     319        private:
     320            ConsoleCommand* command_;
     321    };
     322
     323    typedef StaticallyInitializedConsoleCommand SI_CC;
     324
    306325    /**
    307326        @brief Returns a manipulator for a command with the given name.
Note: See TracChangeset for help on using the changeset viewer.