Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 5, 2008, 9:50:26 PM (16 years ago)
Author:
rgrieder
Message:
  • getInstance is probably more suitable than getSingleton (as x3n has already done so in most of his classes) I changed it in Orxonox and GraphicsEngine. Maybe more to come.
  • Removed derivation from BaseObject in InputState (templates work well too, don't need a factory at all)
Location:
code/branches/gui/src/core/input
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/input/ExtendedInputState.cc

    r1642 r1653  
    3737#include <assert.h>
    3838#include "core/Debug.h"
    39 #include "core/CoreIncludes.h"
    4039
    4140namespace orxonox
    4241{
    43     CreateFactory(ExtendedInputState);
    44 
    4542    using namespace InputDevice;
    46 
    47     ExtendedInputState::ExtendedInputState()
    48     {
    49         RegisterObject(ExtendedInputState);
    50     }
    5143
    5244    void ExtendedInputState::numberOfJoySticksChanged(unsigned int n)
  • code/branches/gui/src/core/input/ExtendedInputState.h

    r1646 r1653  
    4848    {
    4949        friend class InputManager;
    50         friend class ClassFactory<ExtendedInputState>;
    5150
    5251    public:
     
    6867
    6968    private:
    70         ExtendedInputState();
     69        ExtendedInputState() { }
    7170        ~ExtendedInputState() { }
    7271
  • code/branches/gui/src/core/input/InputManager.cc

    r1646 r1653  
    161161            setConfigValues();
    162162
    163             stateEmpty_ = createSimpleInputState("empty", -1);
     163            stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
    164164            stateEmpty_->setHandler(new EmptyHandler());
    165165            activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
    166166
    167             stateDetector_ = createSimpleInputState("detector", 101);
     167            stateDetector_ = createInputState<SimpleInputState>("detector", 101);
    168168            KeyDetector* temp = new KeyDetector();
    169169            temp->loadBindings("storeKeyStroke");
    170170            stateDetector_->setHandler(temp);
    171171
    172             stateCalibrator_ = createSimpleInputState("calibrator", 100);
     172            stateCalibrator_ = createInputState<SimpleInputState>("calibrator", 100);
    173173            stateCalibrator_->setHandler(new EmptyHandler());
    174174            InputBuffer* buffer = new InputBuffer();
     
    10371037    /**
    10381038    @brief
    1039         Returns a new SimpleInputState and configures it first.
    1040     */
    1041     SimpleInputState* InputManager::createSimpleInputState(const std::string &name, int priority)
    1042     {
    1043         SimpleInputState* state = new SimpleInputState();
    1044         if (_configureInputState(state, name, priority))
    1045             return state;
    1046         else
    1047         {
    1048             delete state;
    1049             return 0;
    1050         }
    1051     }
    1052 
    1053     /**
    1054     @brief
    1055         Returns a new ExtendedInputState and configures it first.
    1056     */
    1057     ExtendedInputState* InputManager::createExtendedInputState(const std::string &name, int priority)
    1058     {
    1059         ExtendedInputState* state = new ExtendedInputState();
    1060         if (_configureInputState(state, name, priority))
    1061             return state;
    1062         else
    1063         {
    1064             delete state;
    1065             return 0;
    1066         }
    1067     }
    1068 
    1069     /**
    1070     @brief
    1071         Returns a new InputState of type 'type' and configures it first.
    1072     @param type
    1073         String name of the class (used by the factory)
    1074     */
    1075     InputState* InputManager::createInputState(const std::string& type, const std::string &name, int priority)
    1076     {
    1077         InputState* state = dynamic_cast<InputState*>(Factory::getIdentifier(type)->fabricate());
    1078         if (_configureInputState(state, name, priority))
    1079             return state;
    1080         else
    1081         {
    1082             delete state;
    1083             return 0;
    1084         }
    1085     }
    1086 
    1087     /**
    1088     @brief
    10891039        Removes an input state internally.
    10901040    @param name
  • code/branches/gui/src/core/input/InputManager.h

    r1645 r1653  
    102102        void setWindowExtents(const int width, const int height);
    103103
    104         SimpleInputState*   createSimpleInputState  (const std::string& name, int priority);
    105         ExtendedInputState* createExtendedInputState(const std::string& name, int priority);
    106         InputState*         createInputState(const std::string& type, const std::string &name, int priority);
     104        template <class T>
     105        T* createInputState(const std::string& name, int priority)
     106        {
     107            T* state = new T;
     108            if (_configureInputState(state, name, priority))
     109                return state;
     110            else
     111            {
     112                delete state;
     113                return 0;
     114            }
     115        }
     116
    107117        bool destroyState          (const std::string& name);
    108118        InputState* getState       (const std::string& name);
  • code/branches/gui/src/core/input/InputState.h

    r1646 r1653  
    4040#include <vector>
    4141#include "core/Executor.h"
    42 #include "core/BaseObject.h"
    43 #include "core/CoreIncludes.h"
    4442#include "InputInterfaces.h"
    4543
    4644namespace orxonox
    4745{
    48     class _CoreExport InputState : public BaseObject
     46    class _CoreExport InputState
    4947    {
    5048        friend class InputManager;
     
    8987
    9088    protected:
    91         InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0)
    92         { RegisterObject(InputState); }
     89        InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0) { }
    9390        virtual ~InputState() { }
    9491
  • code/branches/gui/src/core/input/KeyDetector.cc

    r1638 r1653  
    6868    void KeyDetector::loadBindings(const std::string& command)
    6969    {
     70        this->command_ = command;
    7071        clearBindings();
    7172        setConfigValues();
    72         this->command_ = command;
    7373    }
    7474
  • code/branches/gui/src/core/input/SimpleInputState.cc

    r1642 r1653  
    3838#include "core/Debug.h"
    3939#include "core/Executor.h"
    40 #include "core/CoreIncludes.h"
    4140
    4241namespace orxonox
    4342{
    44     CreateFactory(SimpleInputState);
    45 
    4643    using namespace InputDevice;
    4744
     
    5148        , joyStickHandlerAll_(0)
    5249    {
    53         RegisterObject(SimpleInputState);
    5450    }
    5551
  • code/branches/gui/src/core/input/SimpleInputState.h

    r1646 r1653  
    4646    {
    4747        friend class InputManager;
    48         friend class ClassFactory<SimpleInputState>;
    4948
    5049    public:
Note: See TracChangeset for help on using the changeset viewer.