[dasher] ModuleManager: static types 4 {Get, Set}DefaultInput{Device, Method}
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] ModuleManager: static types 4 {Get, Set}DefaultInput{Device, Method}
- Date: Tue, 18 Jan 2011 17:17:00 +0000 (UTC)
commit 2915492ae4eb320aeaa3389f8a42456fbea5f037
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Sat Nov 20 18:58:36 2010 +0000
ModuleManager: static types 4 {Get,Set}DefaultInput{Device,Method}
Rm CDasherInterfaceBase::GetDefaultInput{Device,Method}, easy 2 call ModMgr!
Src/DasherCore/DasherInterfaceBase.cpp | 22 +++++++---------------
Src/DasherCore/DasherInterfaceBase.h | 6 ++----
Src/DasherCore/ModuleManager.cpp | 24 ++++++++++--------------
Src/DasherCore/ModuleManager.h | 14 ++++++++------
Src/iPhone/Classes/CDasherInterfaceBridge.mm | 4 +++-
5 files changed, 30 insertions(+), 40 deletions(-)
---
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 3dd3d72..99c0907 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -463,7 +463,7 @@ void CDasherInterfaceBase::CreateInput() {
m_pInput = (CDasherInput *)GetModuleByName(GetStringParameter(SP_INPUT_DEVICE));
if (m_pInput == NULL)
- m_pInput = (CDasherInput *)GetDefaultInputDevice();
+ m_pInput = m_oModuleManager.GetDefaultInputDevice();
if(m_pInput) {
m_pInput->Activate();
@@ -787,7 +787,7 @@ void CDasherInterfaceBase::CreateInputFilter()
#endif
if (m_pInputFilter == NULL)
- m_pInputFilter = (CInputFilter *)GetDefaultInputMethod();
+ m_pInputFilter = m_oModuleManager.GetDefaultInputMethod();
m_pInputFilter->Activate();
}
@@ -804,26 +804,18 @@ CDasherModule *CDasherInterfaceBase::GetModuleByName(const std::string &strName)
return m_oModuleManager.GetModuleByName(strName);
}
-CDasherModule *CDasherInterfaceBase::GetDefaultInputDevice() {
- return m_oModuleManager.GetDefaultInputDevice();
-}
-
-CDasherModule *CDasherInterfaceBase::GetDefaultInputMethod() {
- return m_oModuleManager.GetDefaultInputMethod();
-}
-
-void CDasherInterfaceBase::SetDefaultInputDevice(CDasherModule *pModule) {
+void CDasherInterfaceBase::SetDefaultInputDevice(CDasherInput *pModule) {
m_oModuleManager.SetDefaultInputDevice(pModule);
}
-void CDasherInterfaceBase::SetDefaultInputMethod(CDasherModule *pModule) {
+void CDasherInterfaceBase::SetDefaultInputMethod(CInputFilter *pModule) {
m_oModuleManager.SetDefaultInputMethod(pModule);
}
void CDasherInterfaceBase::CreateModules() {
- SetDefaultInputMethod(
- RegisterModule(new CDefaultFilter(m_pEventHandler, m_pSettingsStore, this, 3, _("Normal Control")))
- );
+ CInputFilter *defFil = new CDefaultFilter(m_pEventHandler, m_pSettingsStore, this, 3, _("Normal Control"));
+ RegisterModule(defFil);
+ SetDefaultInputMethod(defFil);
RegisterModule(new COneDimensionalFilter(m_pEventHandler, m_pSettingsStore, this));
#ifndef _WIN32_WCE
RegisterModule(new CClickFilter(m_pEventHandler, m_pSettingsStore, this));
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index 53ee436..b486c41 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -359,10 +359,8 @@ public:
CDasherModule *RegisterModule(CDasherModule *pModule);
CDasherModule *GetModule(ModuleID_t iID);
CDasherModule *GetModuleByName(const std::string &strName);
- CDasherModule *GetDefaultInputDevice();
- CDasherModule *GetDefaultInputMethod();
- void SetDefaultInputDevice(CDasherModule *);
- void SetDefaultInputMethod(CDasherModule *);
+ void SetDefaultInputDevice(CDasherInput *);
+ void SetDefaultInputMethod(CInputFilter *);
void StartShutdown();
diff --git a/Src/DasherCore/ModuleManager.cpp b/Src/DasherCore/ModuleManager.cpp
index 1204452..40ed899 100644
--- a/Src/DasherCore/ModuleManager.cpp
+++ b/Src/DasherCore/ModuleManager.cpp
@@ -22,6 +22,8 @@
#include <stdexcept>
#include "ModuleManager.h"
+#include "DasherInput.h"
+#include "InputFilter.h"
using namespace Dasher;
@@ -88,26 +90,20 @@ CModuleManager::~CModuleManager() {
*/
}
-CDasherModule *CModuleManager::GetDefaultInputDevice() {
+CDasherInput *CModuleManager::GetDefaultInputDevice() {
return m_pDefaultInputDevice;
}
-CDasherModule *CModuleManager::GetDefaultInputMethod() {
+CInputFilter *CModuleManager::GetDefaultInputMethod() {
return m_pDefaultInputMethod;
}
-void CModuleManager::SetDefaultInputDevice(CDasherModule *p) {
- if (p->GetType() == InputDevice)
- m_pDefaultInputDevice = p;
- else
- std::cerr << "Tried to register " << p->GetName()
- << " as an input device" << std::endl;
+void CModuleManager::SetDefaultInputDevice(CDasherInput *p) {
+ DASHER_ASSERT(p->GetType() == InputDevice);
+ m_pDefaultInputDevice = p;
}
-void CModuleManager::SetDefaultInputMethod(CDasherModule *p) {
- if (p->GetType() == InputMethod)
- m_pDefaultInputMethod = p;
- else
- std::cerr << "Tried to register " << p->GetName()
- << " as an input method" << std::endl;
+void CModuleManager::SetDefaultInputMethod(CInputFilter *p) {
+ DASHER_ASSERT(p->GetType() == InputMethod);
+ m_pDefaultInputMethod = p;
}
diff --git a/Src/DasherCore/ModuleManager.h b/Src/DasherCore/ModuleManager.h
index 8e0bf77..116e25b 100644
--- a/Src/DasherCore/ModuleManager.h
+++ b/Src/DasherCore/ModuleManager.h
@@ -28,6 +28,8 @@
#include <vector>
namespace Dasher {
+ class CDasherInput;
+ class CInputFilter;
enum ModuleType {InputDevice = 0, InputMethod = 1};
@@ -39,18 +41,18 @@ class CModuleManager {
CDasherModule *RegisterModule(CDasherModule *pModule);
CDasherModule *GetModule(ModuleID_t iID);
CDasherModule *GetModuleByName(const std::string strName);
- CDasherModule *GetDefaultInputDevice();
- CDasherModule *GetDefaultInputMethod();
- void SetDefaultInputDevice(CDasherModule *);
- void SetDefaultInputMethod(CDasherModule *);
+ CDasherInput *GetDefaultInputDevice();
+ CInputFilter *GetDefaultInputMethod();
+ void SetDefaultInputDevice(CDasherInput *);
+ void SetDefaultInputMethod(CInputFilter *);
void ListModules(int iType, std::vector<std::string> &vList);
private:
std::vector<CDasherModule *> m_vModules;
std::map<std::string, ModuleID_t> m_mapNameToID;
- CDasherModule *m_pDefaultInputDevice;
- CDasherModule *m_pDefaultInputMethod;
+ CDasherInput *m_pDefaultInputDevice;
+ CInputFilter *m_pDefaultInputMethod;
};
/// \}
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.mm b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
index c73a85d..e96451f 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.mm
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
@@ -46,7 +46,9 @@ void CDasherInterfaceBridge::CreateModules() {
new CIPhone1DFilter(m_pEventHandler, m_pSettingsStore, this, 16));
RegisterModule(m_pPolarFilter =
new CIPhonePolarFilter(m_pEventHandler, m_pSettingsStore, this, 17));
- SetDefaultInputMethod(GetModuleByName("Stylus Control"));
+ CDasherModule *stylus = GetModuleByName("Stylus Control");
+ DASHER_ASSERT(stylus && stylus->GetType() == InputMethod);
+ SetDefaultInputMethod(static_cast<CInputFilter *>(stylus));
SetDefaultInputDevice(m_pMouseDevice);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]