[dasher: 3/11] ControlManager pause/stop nodes set BP_DASHER_PAUSED / call Stop directly
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 3/11] ControlManager pause/stop nodes set BP_DASHER_PAUSED / call Stop directly
- Date: Sat, 31 Jul 2010 14:07:26 +0000 (UTC)
commit eaabf724fd6b8336b72252ef72ffcf02ae9b0eeb
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Fri Jun 4 17:35:24 2010 +0100
ControlManager pause/stop nodes set BP_DASHER_PAUSED / call Stop directly
...rather than broadcasting CTL_PAUSE/CTL_STOP events for DasherIntf to pick up
Src/DasherCore/ControlManager.cpp | 20 +++++++++++++++++---
Src/DasherCore/ControlManager.h | 19 ++++++++++++++++---
Src/DasherCore/DasherInterfaceBase.cpp | 14 --------------
Src/DasherCore/NodeCreationManager.cpp | 2 +-
4 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/Src/DasherCore/ControlManager.cpp b/Src/DasherCore/ControlManager.cpp
index 04e43c5..84dce9c 100644
--- a/Src/DasherCore/ControlManager.cpp
+++ b/Src/DasherCore/ControlManager.cpp
@@ -134,7 +134,7 @@ void CControlBase::CContNode::Leave() {
}
}
-COrigNodes::COrigNodes(CNodeCreationManager *pNCManager) : CControlBase(pNCManager) {
+COrigNodes::COrigNodes(CNodeCreationManager *pNCManager, CDasherInterfaceBase *pInterface) : CControlBase(pNCManager), m_pInterface(pInterface) {
m_iNextID = 0;
// TODO: Need to fix this on WinCE build
@@ -178,6 +178,18 @@ bool COrigNodes::LoadLabelsFromFile(string strFileName) {
return 0;
}
+COrigNodes::Pause::Pause(const string &strLabel, int iColour) : NodeTemplate(strLabel,iColour) {
+}
+void COrigNodes::Pause::happen(CContNode *pNode) {
+ static_cast<COrigNodes *>(pNode->mgr())->m_pNCManager->SetBoolParameter(BP_DASHER_PAUSED,true);
+}
+
+COrigNodes::Stop::Stop(const string &strLabel, int iColour) : NodeTemplate(strLabel, iColour) {
+}
+void COrigNodes::Stop::happen(CContNode *pNode) {
+ static_cast<COrigNodes *>(pNode->mgr())->m_pInterface->Stop();
+}
+
bool COrigNodes::LoadDefaultLabels() {
//hmmm. This is probably not the most flexible policy...
if (!m_perId.empty()) return false;
@@ -322,7 +334,9 @@ COrigNodes::~COrigNodes() {
void COrigNodes::RegisterNode( int iID, std::string strLabel, int iColour ) {
DASHER_ASSERT(m_perId.count(iID)==0);
- m_perId[iID] = new EventBroadcast(iID,strLabel,iColour);
+ if (iID == CTL_STOP) m_perId[iID] = new Stop(strLabel,iColour);
+ else if (iID == CTL_PAUSE) m_perId[iID] = new Pause(strLabel, iColour);
+ else m_perId[iID] = new EventBroadcast(iID,strLabel,iColour);
}
void COrigNodes::ConnectNode(int iChild, int iParent, int iAfter) {
@@ -375,5 +389,5 @@ void COrigNodes::XmlEndHandler(void *pUserData, const XML_Char *szName) {
void COrigNodes::XmlCDataHandler(void *pUserData, const XML_Char *szData, int iLength){
}
-CControlManager::CControlManager(CNodeCreationManager *pNCMgr) : COrigNodes(pNCMgr) {
+CControlManager::CControlManager(CNodeCreationManager *pNCMgr, CDasherInterfaceBase *pInterface) : COrigNodes(pNCMgr,pInterface) {
}
diff --git a/Src/DasherCore/ControlManager.h b/Src/DasherCore/ControlManager.h
index 395ccb7..f5a2bde 100644
--- a/Src/DasherCore/ControlManager.h
+++ b/Src/DasherCore/ControlManager.h
@@ -21,10 +21,11 @@
#ifndef __controlmanager_h__
#define __controlmanager_h__
-#include "DasherModel.h"
#include "DasherNode.h"
#include "Event.h"
#include "NodeManager.h"
+#include "NodeCreationManager.h"
+#include "DasherInterfaceBase.h"
#include <vector>
#include <map>
@@ -141,7 +142,7 @@ namespace Dasher {
///subclass attempts to recreate interface of previous control manager...
class COrigNodes : public CControlBase {
public:
- COrigNodes(CNodeCreationManager *pNCManager);
+ COrigNodes(CNodeCreationManager *pNCManager, CDasherInterfaceBase *pInterface);
~COrigNodes();
//keep these around for now, as this might let Win32/Gtk2 work?
@@ -149,6 +150,17 @@ namespace Dasher {
void ConnectNode(int iChild, int iParent, int iAfter);
void DisconnectNode(int iChild, int iParent);
+ class Pause : public NodeTemplate {
+ public:
+ Pause(const std::string &strLabel, int iColour);
+ void happen(CContNode *pNode);
+ };
+ class Stop : public NodeTemplate {
+ public:
+ Stop(const std::string &strLabel, int iColour);
+ void happen(CContNode *pNode);
+ };
+
private:
//For now, make all the loading routines private:
// they are called from the constructor in the same fashion as in old ControlManager.
@@ -173,12 +185,13 @@ namespace Dasher {
int m_iNextID;
protected:
std::map<int,NodeTemplate *> m_perId;
+ CDasherInterfaceBase *m_pInterface;
};
///subclass which we actually construct - more of a marker than anything for now.
class CControlManager : public COrigNodes {
public:
- CControlManager(CNodeCreationManager *pNCManager);
+ CControlManager(CNodeCreationManager *pNCManager, CDasherInterfaceBase *pInterface);
};
/// @}
}
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index cdc0a5a..2f552aa 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -351,20 +351,6 @@ void CDasherInterfaceBase::InterfaceEventHandler(Dasher::CEvent *pEvent) {
strTrainfileBuffer = strTrainfileBuffer.substr( 0, strTrainfileBuffer.size() - pEditEvent->m_sText.size());
}
}
- else if(pEvent->m_iEventType == EV_CONTROL) {
- CControlEvent *pControlEvent(static_cast <CControlEvent*>(pEvent));
-
- switch(pControlEvent->m_iID) {
- case CControlManager::CTL_STOP:
- Stop();
- break;
- case CControlManager::CTL_PAUSE:
- //Halt Dasher - without a stop event, so does not result in speech etc.
- SetBoolParameter(BP_DASHER_PAUSED, true);
-
- m_pDasherModel->TriggerSlowdown();
- }
- }
}
void CDasherInterfaceBase::WriteTrainFileFull() {
diff --git a/Src/DasherCore/NodeCreationManager.cpp b/Src/DasherCore/NodeCreationManager.cpp
index 99ff864..506beda 100644
--- a/Src/DasherCore/NodeCreationManager.cpp
+++ b/Src/DasherCore/NodeCreationManager.cpp
@@ -120,7 +120,7 @@ CNodeCreationManager::CNodeCreationManager(Dasher::CDasherInterfaceBase *pInterf
}
#endif
#ifndef _WIN32_WCE
- m_pControlManager = new CControlManager(this);
+ m_pControlManager = new CControlManager(this,pInterface);
#else
m_pControlManager = 0;
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]