~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to Tools/LayoutEditor/CommandManager.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
        @file
3
 
        @author         Albert Semenov
4
 
        @date           08/2010
5
 
*/
6
 
#include "Precompiled.h"
7
 
#include "CommandManager.h"
8
 
 
9
 
template <> tools::CommandManager* MyGUI::Singleton<tools::CommandManager>::msInstance = nullptr;
10
 
template <> const char* MyGUI::Singleton<tools::CommandManager>::mClassTypeName("CommandManager");
11
 
 
12
 
namespace tools
13
 
{
14
 
 
15
 
        CommandManager::CommandManager()
16
 
        {
17
 
        }
18
 
 
19
 
        CommandManager::~CommandManager()
20
 
        {
21
 
        }
22
 
 
23
 
        void CommandManager::initialise()
24
 
        {
25
 
        }
26
 
 
27
 
        void CommandManager::shutdown()
28
 
        {
29
 
        }
30
 
 
31
 
        bool CommandManager::executeCommand(const MyGUI::UString& _command)
32
 
        {
33
 
                bool result = false;
34
 
                MyGUI::UString command = _command;
35
 
                size_t index = _command.find('.');
36
 
                if (index != MyGUI::UString::npos)
37
 
                {
38
 
                        command = _command.substr(0, index);
39
 
                        mData = _command.substr(index + 1);
40
 
                }
41
 
 
42
 
                MapDelegate::iterator iter = mDelegates.find(command);
43
 
                if (iter != mDelegates.end())
44
 
                {
45
 
                        iter->second(command, result);
46
 
                }
47
 
                else
48
 
                {
49
 
                        MYGUI_LOG(Warning, "Command '" << command << "' not found");
50
 
                }
51
 
 
52
 
                mData.clear();
53
 
 
54
 
                return result;
55
 
        }
56
 
 
57
 
        void CommandManager::registerCommand(const MyGUI::UString& _command, CommandDelegate::IDelegate* _delegate)
58
 
        {
59
 
                MapDelegate::iterator iter = mDelegates.find(_command);
60
 
                if (iter == mDelegates.end())
61
 
                        iter = mDelegates.insert(std::make_pair(_command, CommandDelegate())).first;
62
 
                (*iter).second += _delegate;
63
 
        }
64
 
 
65
 
        void CommandManager::unregisterCommand(const MyGUI::UString& _command, CommandDelegate::IDelegate* _delegate)
66
 
        {
67
 
                MapDelegate::iterator iter = mDelegates.find(_command);
68
 
                if (iter != mDelegates.end())
69
 
                {
70
 
                        (*iter).second -= _delegate;
71
 
                        if ((*iter).second.empty())
72
 
                                mDelegates.erase(iter);
73
 
                }
74
 
        }
75
 
 
76
 
        void CommandManager::setCommandData(const MyGUI::UString& _data)
77
 
        {
78
 
                mData = _data;
79
 
        }
80
 
 
81
 
        const MyGUI::UString& CommandManager::getCommandData() const
82
 
        {
83
 
                return mData;
84
 
        }
85
 
 
86
 
} // namespace tools