Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2015, 10:56:26 PM (9 years ago)
Author:
landauf
Message:

made ConsoleCommandManager a singleton.

File:
1 edited

Legend:

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

    r10354 r10484  
    4040{
    4141    /**
    42      * A static class that stores all existing ConsoleCommands.
     42     * A singleton that stores all existing ConsoleCommands.
    4343     */
    4444    class _CoreExport ConsoleCommandManager
    4545    {
    4646        public:
    47             static void registerCommand(ConsoleCommand* command);
    48             static void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
    49             static void unregisterCommand(ConsoleCommand* command);
     47            static ConsoleCommandManager& getInstance();
     48
     49            void registerCommand(ConsoleCommand* command);
     50            void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
     51            void unregisterCommand(ConsoleCommand* command);
    5052
    5153            /// Returns the map with all groups and commands.
    52             static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
    53                 { return ConsoleCommandManager::getCommandMap(); }
     54            inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
     55                { return this->commandMap_; }
    5456            /// Returns the map with all groups and commands in lowercase.
    55             static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
    56                 { return ConsoleCommandManager::getCommandMapLC(); }
     57            inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
     58                { return this->commandMapLC_; }
    5759
    5860            /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
    59             static inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
    60                 { return ConsoleCommandManager::getCommand("", name, bPrintError); }
     61            inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
     62                { return this->getCommand("", name, bPrintError); }
    6163            /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
    62             static inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
    63                 { return ConsoleCommandManager::getCommandLC("", name, bPrintError); }
     64            inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
     65                { return this->getCommandLC("", name, bPrintError); }
    6466
    65             static ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
    66             static ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
     67            ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
     68            ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
    6769
    68             static void destroyAll();
     70            void destroyAll();
    6971
    7072        private:
    71             static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMap();
    72             static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMapLC();
     73            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap_;
     74            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC_;
    7375    };
    7476}
Note: See TracChangeset for help on using the changeset viewer.