[dasher] Move iOffset field into DasherNode (now m_iOffset).
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dasher] Move iOffset field into DasherNode (now m_iOffset).
- Date: Mon, 24 Aug 2009 17:59:45 +0000 (UTC)
commit caee9bbcc9db1fa1a2ba1ea0c65f41b12af3e4e4
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Sat Aug 22 13:08:55 2009 +0100
Move iOffset field into DasherNode (now m_iOffset).
ChangeLog | 4 ++++
Src/DasherCore/AlphabetManager.cpp | 22 +++++++++++-----------
Src/DasherCore/AlphabetManager.h | 1 -
Src/DasherCore/ControlManager.cpp | 8 ++++----
Src/DasherCore/ControlManager.h | 1 -
Src/DasherCore/ConversionHelper.cpp | 6 +++---
Src/DasherCore/ConversionManager.cpp | 16 ++++++++--------
Src/DasherCore/ConversionManager.h | 1 -
Src/DasherCore/DasherModel.cpp | 6 ++----
Src/DasherCore/DasherNode.h | 1 +
Src/DasherCore/MandarinAlphMgr.cpp | 4 +---
11 files changed, 34 insertions(+), 36 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 233d00d..5222f47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-22 Alan Lawrence <acl33 inf phy cam ac uk>
+
+ * Move iOffset field into DasherNode (now m_iOffset).
+
2009-08-21 Alan Lawrence <acl33 inf phy cam ac uk>
* Move handling of double/long/etc. clicks into subclasses.
diff --git a/Src/DasherCore/AlphabetManager.cpp b/Src/DasherCore/AlphabetManager.cpp
index 3debacd..8170b82 100644
--- a/Src/DasherCore/AlphabetManager.cpp
+++ b/Src/DasherCore/AlphabetManager.cpp
@@ -105,7 +105,7 @@ CDasherNode *CAlphabetManager::GetRoot(CDasherNode *pParent, int iLower, int iUp
SAlphabetData *pNodeUserData = new SAlphabetData;
pNewNode->m_pUserData = pNodeUserData;
- pNodeUserData->iOffset = iOffset;
+ pNewNode->m_iOffset = iOffset;
pNodeUserData->iPhase = 0;
pNodeUserData->iSymbol = iSymbol;
@@ -165,7 +165,7 @@ CDasherNode *CAlphabetManager::CreateGroupNode(CDasherNode *pParent, SGroupInfo
pNewNode->m_pUserData = pNodeUserData;
// When creating a group node...
- pNodeUserData->iOffset = pParentData->iOffset; // ...the offset is the same as the parent...
+ pNewNode->m_iOffset = pParent->m_iOffset; // ...the offset is the same as the parent...
pNodeUserData->iPhase = pParentData->iPhase;
// TODO: Sort out symbol for groups
pNodeUserData->iSymbol = 0; //...but the Symbol is just a 0.
@@ -220,12 +220,12 @@ CDasherNode *CAlphabetManager::CreateSymbolNode(CDasherNode *pParent, symbol iSy
pNewNode->SetRange(iLbnd, iHbnd);
pNewNode->SetParent(pParent);
- DASHER_ASSERT(static_cast<SAlphabetData *>(pExistingChild->m_pUserData)->iOffset == pParentData->iOffset + 1);
+ DASHER_ASSERT(pExistingChild->m_iOffset == pParentData->m_iOffset + 1);
}
// TODO: Need to fix fact that this is created even when control mode is switched off
else if(iSymbol == m_pNCManager->GetControlSymbol()) {
- pNewNode = m_pNCManager->GetCtrlRoot(pParent, iLbnd, iHbnd, pParentData->iOffset);
+ pNewNode = m_pNCManager->GetCtrlRoot(pParent, iLbnd, iHbnd, pParent->m_iOffset);
// For now, just hack it so we get a normal root node here
if(!pNewNode) {
@@ -236,7 +236,7 @@ CDasherNode *CAlphabetManager::CreateSymbolNode(CDasherNode *pParent, symbol iSy
// else if(iSymbol == m_pNCManager->GetSpaceSymbol()) {
// TODO: Need to consider the case where there is no compile-time support for this
- pNewNode = m_pNCManager->GetConvRoot(pParent, iLbnd, iHbnd, pParentData->iOffset);
+ pNewNode = m_pNCManager->GetConvRoot(pParent, iLbnd, iHbnd, pParent->m_iOffset);
}
else {
int iPhase = (pParentData->iPhase + 1) % 2;
@@ -266,7 +266,7 @@ CDasherNode *CAlphabetManager::CreateSymbolNode(CDasherNode *pParent, symbol iSy
SAlphabetData *pNodeUserData = new SAlphabetData;
pNewNode->m_pUserData = pNodeUserData;
- pNodeUserData->iOffset = pParentData->iOffset + 1;
+ pNewNode->m_iOffset = pParent->m_iOffset + 1;
pNodeUserData->iPhase = iPhase;
pNodeUserData->iSymbol = iSymbol;
@@ -369,10 +369,10 @@ void CAlphabetManager::ClearNode( CDasherNode *pNode ) {
void CAlphabetManager::Output( CDasherNode *pNode, Dasher::VECTOR_SYMBOL_PROB* pAdded, int iNormalization) {
symbol t = static_cast<SAlphabetData *>(pNode->m_pUserData)->iSymbol;
- //std::cout << pNode << " " << pNode->Parent() << ": Output at offset " << static_cast<SAlphabetData *>(pNode->m_pUserData)->iOffset << " *" << m_pNCManager->GetAlphabet()->GetText(t) << "* " << std::endl;
+ //std::cout << pNode << " " << pNode->Parent() << ": Output at offset " << pNode->m_iOffset << " *" << m_pNCManager->GetAlphabet()->GetText(t) << "* " << std::endl;
if(t) { // Ignore symbol 0 (root node)
- Dasher::CEditEvent oEvent(1, m_pNCManager->GetAlphabet()->GetText(t), static_cast<SAlphabetData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oEvent(1, m_pNCManager->GetAlphabet()->GetText(t), pNode->m_iOffset);
m_pNCManager->InsertEvent(&oEvent);
// Track this symbol and its probability for logging purposes
@@ -390,14 +390,14 @@ void CAlphabetManager::Undo( CDasherNode *pNode ) {
symbol t = static_cast<SAlphabetData *>(pNode->m_pUserData)->iSymbol;
if(t) { // Ignore symbol 0 (root node)
- Dasher::CEditEvent oEvent(2, m_pNCManager->GetAlphabet()->GetText(t), static_cast<SAlphabetData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oEvent(2, m_pNCManager->GetAlphabet()->GetText(t), pNode->m_iOffset);
m_pNCManager->InsertEvent(&oEvent);
}
}
// TODO: Sort out node deletion etc.
CDasherNode *CAlphabetManager::RebuildParent(CDasherNode *pNode) {
- int iOffset(static_cast<SAlphabetData *>(pNode->m_pUserData)->iOffset);
+ int iOffset(pNode->m_iOffset);
int iNewOffset = iOffset - 1;
CDasherNode *pNewNode;
@@ -463,7 +463,7 @@ CDasherNode *CAlphabetManager::RebuildParent(CDasherNode *pNode) {
SAlphabetData *pNodeUserData = new SAlphabetData;
pNewNode->m_pUserData = pNodeUserData;
- pNodeUserData->iOffset = iNewOffset;
+ pNewNode->m_iOffset = iNewOffset;
pNodeUserData->iPhase = iNewPhase;
pNodeUserData->iSymbol = iNewSymbol;
pNodeUserData->pLanguageModel = m_pLanguageModel;
diff --git a/Src/DasherCore/AlphabetManager.h b/Src/DasherCore/AlphabetManager.h
index 52ef484..55b418d 100644
--- a/Src/DasherCore/AlphabetManager.h
+++ b/Src/DasherCore/AlphabetManager.h
@@ -93,7 +93,6 @@ namespace Dasher {
CLanguageModel::Context iContext;
int iGameOffset;
- int iOffset;
};
protected:
diff --git a/Src/DasherCore/ControlManager.cpp b/Src/DasherCore/ControlManager.cpp
index 000d63f..9a444df 100644
--- a/Src/DasherCore/ControlManager.cpp
+++ b/Src/DasherCore/ControlManager.cpp
@@ -288,7 +288,7 @@ CDasherNode *CControlManager::GetRoot(CDasherNode *pParent, int iLower, int iUpp
SControlData *pNodeUserData = new SControlData;
pNodeUserData->pControlNode = m_mapControlMap[0];
- pNodeUserData->iOffset = iOffset;
+ pNewNode->m_iOffset = iOffset;
pNewNode->m_pUserData = pNodeUserData;
@@ -315,7 +315,7 @@ void CControlManager::PopulateChildren( CDasherNode *pNode ) {
if( *it == NULL ) {
// Escape back to alphabet
- pNewNode = m_pNCManager->GetAlphRoot(pNode, iLbnd, iHbnd, NULL/*TODO fix this*/, static_cast<SControlData *>(pNode->m_pUserData)->iOffset);
+ pNewNode = m_pNCManager->GetAlphRoot(pNode, iLbnd, iHbnd, NULL/*TODO fix this*/, pNode->m_iOffset);
pNewNode->SetFlag(NF_SEEN, false);
}
else {
@@ -340,7 +340,7 @@ void CControlManager::PopulateChildren( CDasherNode *pNode ) {
SControlData *pNodeUserData = new SControlData;
pNodeUserData->pControlNode = *it;
- pNodeUserData->iOffset = (static_cast<SControlData *>(pNode->m_pUserData))->iOffset;
+ pNewNode->m_iOffset = pNode->m_iOffset;
pNewNode->m_pUserData = pNodeUserData;
@@ -428,5 +428,5 @@ void CControlManager::XmlCDataHandler(void *pUserData, const XML_Char *szData, i
}
void CControlManager::SetControlOffset(CDasherNode *pNode, int iOffset) {
- (static_cast<SControlData *>(pNode->m_pUserData))->iOffset = iOffset;
+ pNode->m_iOffset = iOffset;
}
diff --git a/Src/DasherCore/ControlManager.h b/Src/DasherCore/ControlManager.h
index b48053f..63bf858 100644
--- a/Src/DasherCore/ControlManager.h
+++ b/Src/DasherCore/ControlManager.h
@@ -137,7 +137,6 @@ namespace Dasher {
struct SControlData {
CControlNode *pControlNode;
- int iOffset;
};
///Whether we'd temporarily disabled Automatic Speed Control
diff --git a/Src/DasherCore/ConversionHelper.cpp b/Src/DasherCore/ConversionHelper.cpp
index 6d5221a..18d22eb 100644
--- a/Src/DasherCore/ConversionHelper.cpp
+++ b/Src/DasherCore/ConversionHelper.cpp
@@ -269,7 +269,7 @@ void CConversionHelper::PopulateChildren( CDasherNode *pNode ) {
pNodeUserData->bisRoot = false;
pNodeUserData->pSCENode = pCurrentSCEChild;
pNodeUserData->pLanguageModel = pCurrentDataNode->pLanguageModel;
- pNodeUserData->iOffset = pCurrentDataNode->iOffset + 1;
+ pNewNode->m_iOffset = pNode->m_iOffset + 1;
if(pCurrentDataNode->pLanguageModel) {
CLanguageModel::Context iContext;
@@ -300,7 +300,7 @@ void CConversionHelper::PopulateChildren( CDasherNode *pNode ) {
int iLbnd(0);
int iHbnd(m_pNCManager->GetLongParameter(LP_NORMALIZATION));
- pNewNode = m_pNCManager->GetAlphRoot(pNode, iLbnd, iHbnd, NULL, pCurrentDataNode->iOffset);
+ pNewNode = m_pNCManager->GetAlphRoot(pNode, iLbnd, iHbnd, NULL, pNode->m_iOffset);
pNewNode->SetFlag(NF_SEEN, false);
pNode->Children().push_back(pNewNode);
@@ -334,7 +334,7 @@ void CConversionHelper::PopulateChildren( CDasherNode *pNode ) {
pNodeUserData->bType = true;
pNodeUserData->pSCENode = NULL;
pNodeUserData->pLanguageModel = pCurrentDataNode->pLanguageModel;
- pNodeUserData->iOffset = pCurrentDataNode->iOffset + 1;
+ pNewNode->m_iOffset = pNode->m_iOffset + 1;
pNewNode->m_pUserData = pNodeUserData;
diff --git a/Src/DasherCore/ConversionManager.cpp b/Src/DasherCore/ConversionManager.cpp
index 17c5a01..b2e9b2e 100644
--- a/Src/DasherCore/ConversionManager.cpp
+++ b/Src/DasherCore/ConversionManager.cpp
@@ -81,7 +81,7 @@ CDasherNode *CConversionManager::GetRoot(CDasherNode *pParent, int iLower, int i
SConversionData *pNodeUserData = new SConversionData;
pNewNode->m_pUserData = pNodeUserData;
pNodeUserData->bisRoot = true;
- pNodeUserData->iOffset = iOffset + 1;
+ pNewNode->m_iOffset = iOffset + 1;
pNodeUserData->pLanguageModel = NULL;
@@ -104,7 +104,7 @@ void CConversionManager::PopulateChildren( CDasherNode *pNode ) {
int iLbnd(0);
int iHbnd(m_pNCManager->GetLongParameter(LP_NORMALIZATION));
- pNewNode = m_pNCManager->GetAlphRoot(pNode, iLbnd, iHbnd, NULL, pCurrentDataNode->iOffset + 1);
+ pNewNode = m_pNCManager->GetAlphRoot(pNode, iLbnd, iHbnd, NULL, pNode->m_iOffset + 1);
pNewNode->SetFlag(NF_SEEN, false);
pNode->Children().push_back(pNewNode);
@@ -150,7 +150,7 @@ void CConversionManager::Output( CDasherNode *pNode, Dasher::VECTOR_SYMBOL_PROB*
SCENode *pCurrentSCENode((static_cast<SConversionData *>(pNode->m_pUserData))->pSCENode);
if(pCurrentSCENode){
- Dasher::CEditEvent oEvent(1, pCurrentSCENode->pszConversion, static_cast<SConversionData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oEvent(1, pCurrentSCENode->pszConversion, pNode->m_iOffset);
m_pNCManager->InsertEvent(&oEvent);
if((pNode->GetChildren())[0]->m_pNodeManager != this) {
@@ -160,11 +160,11 @@ void CConversionManager::Output( CDasherNode *pNode, Dasher::VECTOR_SYMBOL_PROB*
}
else {
if(!((static_cast<SConversionData *>(pNode->m_pUserData))->bisRoot)) {
- Dasher::CEditEvent oOPEvent(1, "|", static_cast<SConversionData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oOPEvent(1, "|", pNode->m_iOffset);
m_pNCManager->InsertEvent(&oOPEvent);
}
else {
- Dasher::CEditEvent oOPEvent(1, ">", static_cast<SConversionData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oOPEvent(1, ">", pNode->m_iOffset);
m_pNCManager->InsertEvent(&oOPEvent);
}
@@ -178,17 +178,17 @@ void CConversionManager::Undo( CDasherNode *pNode ) {
if(pCurrentSCENode) {
if(pCurrentSCENode->pszConversion && (strlen(pCurrentSCENode->pszConversion) > 0)) {
- Dasher::CEditEvent oEvent(2, pCurrentSCENode->pszConversion, static_cast<SConversionData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oEvent(2, pCurrentSCENode->pszConversion, pNode->m_iOffset);
m_pNCManager->InsertEvent(&oEvent);
}
}
else {
if(!((static_cast<SConversionData *>(pNode->m_pUserData))->bisRoot)) {
- Dasher::CEditEvent oOPEvent(2, "|", static_cast<SConversionData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oOPEvent(2, "|", pNode->m_iOffset);
m_pNCManager->InsertEvent(&oOPEvent);
}
else {
- Dasher::CEditEvent oOPEvent(2, ">", static_cast<SConversionData *>(pNode->m_pUserData)->iOffset);
+ Dasher::CEditEvent oOPEvent(2, ">", pNode->m_iOffset);
m_pNCManager->InsertEvent(&oOPEvent);
}
}
diff --git a/Src/DasherCore/ConversionManager.h b/Src/DasherCore/ConversionManager.h
index 9fea557..c8e5572 100644
--- a/Src/DasherCore/ConversionManager.h
+++ b/Src/DasherCore/ConversionManager.h
@@ -145,7 +145,6 @@ namespace Dasher {
CLanguageModel::Context iContext;
SCENode * pSCENode;
bool bisRoot; // True for root conversion nodes
- int iOffset;
//int iGameOffset;
};
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index 9379412..7fd9af7 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -696,10 +696,7 @@ void CDasherModel::Push_Node(CDasherNode *pNode) {
{
std::string strTargetUtf8Char;
- CAlphabetManager::SAlphabetData * pAlphabetData =
- static_cast<CAlphabetManager::SAlphabetData *>(pNode->m_pUserData);
-
- strTargetUtf8Char = pTeacher->GetSymbolAtOffset(pAlphabetData->iOffset+1);
+ strTargetUtf8Char = pTeacher->GetSymbolAtOffset(pNode->m_iOffset + 1);
CDasherNode::ChildMap::iterator i, j;
// Check if this is the last node in the sentence...
@@ -708,6 +705,7 @@ void CDasherModel::Push_Node(CDasherNode *pNode) {
pNode->SetFlag(NF_END_GAME, true);
goto multibreak;
}
+ CAlphabetManager::SAlphabetData * pAlphabetData;
// ...if it is not then find which child is next in line.
for(i = pNode->Children().begin(); i != pNode->Children().end(); i++)
{
diff --git a/Src/DasherCore/DasherNode.h b/Src/DasherCore/DasherNode.h
index 0cea8cb..fa14f99 100644
--- a/Src/DasherCore/DasherNode.h
+++ b/Src/DasherCore/DasherNode.h
@@ -237,6 +237,7 @@ class Dasher::CDasherNode:private NoClones {
/// node size, colour and display text.
/// \todo Make private, read only access?
void *m_pUserData;
+ int m_iOffset;
// A hack, to allow this node to be tied to a particular number of symbols;
int m_iNumSymbols;
diff --git a/Src/DasherCore/MandarinAlphMgr.cpp b/Src/DasherCore/MandarinAlphMgr.cpp
index feb0399..895269e 100644
--- a/Src/DasherCore/MandarinAlphMgr.cpp
+++ b/Src/DasherCore/MandarinAlphMgr.cpp
@@ -68,11 +68,9 @@ CDasherNode *CMandarinAlphMgr::GetRoot(CDasherNode *pParent, int iLower, int iUp
CDasherNode *CMandarinAlphMgr::CreateSymbolNode(CDasherNode *pParent, symbol iSymbol, unsigned int iLbnd, unsigned int iHbnd, symbol iExistingSymbol, CDasherNode *pExistingChild) {
if (iSymbol <= 1288) {
- SAlphabetData *pParentData = static_cast<SAlphabetData *>(pParent->m_pUserData);
-
//Modified for Mandarin Dasher
//The following logic switch allows punctuation nodes in Mandarin to be treated in the same way as English (i.e. display and populate next round) instead of invoking a conversion node
- CDasherNode *pNewNode = m_pNCManager->GetConvRoot(pParent, iLbnd, iHbnd, pParentData->iOffset);
+ CDasherNode *pNewNode = m_pNCManager->GetConvRoot(pParent, iLbnd, iHbnd, pParent->m_iOffset);
static_cast<SAlphabetData *>(pNewNode->m_pUserData)->iSymbol = iSymbol;
return pNewNode;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]