[dasher] Tidy up ConversionManager and use a single instance per Factory. (7-Jul-2009)
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dasher] Tidy up ConversionManager and use a single instance per Factory. (7-Jul-2009)
- Date: Sat, 15 Aug 2009 14:22:37 +0000 (UTC)
commit b271d9c68b21eb4fbcf2cf065e13430e8af7ed29
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Sat Aug 8 22:15:22 2009 +0200
Tidy up ConversionManager and use a single instance per Factory. (7-Jul-2009)
ChangeLog | 4 ++++
Src/DasherCore/ConversionManager.cpp | 10 ----------
Src/DasherCore/ConversionManager.h | 13 -------------
Src/DasherCore/ConversionManagerFactory.cpp | 14 +++++++-------
Src/DasherCore/ConversionManagerFactory.h | 7 +++++--
5 files changed, 16 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7af9359..81dae25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-08 Alan Lawrence <acl33 inf phy cam ac uk>
+
+ * Tidy up ConversionManager and use a single instance per Factory.
+
2009-08-07 Alan Lawrence <acl33 inf phy cam ac uk>
* MacOSX build now includes Mandarin Dasher training texts,
diff --git a/Src/DasherCore/ConversionManager.cpp b/Src/DasherCore/ConversionManager.cpp
index 64b28bd..d9ed54f 100644
--- a/Src/DasherCore/ConversionManager.cpp
+++ b/Src/DasherCore/ConversionManager.cpp
@@ -44,7 +44,6 @@ CConversionManager::CConversionManager(CNodeCreationManager *pNCManager, CConver
m_pNCManager = pNCManager;
m_pHelper = pHelper;
m_pAlphabet = pAlphabet;
- m_pRoot = NULL;
//DOESN'T SEEM INTRINSIC
//and check why pHelper may be empty
@@ -58,9 +57,6 @@ CConversionManager::CConversionManager(CNodeCreationManager *pNCManager, CConver
m_iRefCount = 1;
- m_bTreeBuilt = false;
-
-
//Testing for alphabet details, delete if needed:
/*
int alphSize = pNCManager->GetAlphabet()->GetNumberSymbols();
@@ -70,12 +66,6 @@ CConversionManager::CConversionManager(CNodeCreationManager *pNCManager, CConver
*/
}
-CConversionManager::~CConversionManager(){
- if(m_pRoot && *m_pRoot)
- (*m_pRoot)->Unref();
-}
-
-
CDasherNode *CConversionManager::GetRoot(CDasherNode *pParent, int iLower, int iUpper, void *pUserData) {
CDasherNode *pNewNode;
diff --git a/Src/DasherCore/ConversionManager.h b/Src/DasherCore/ConversionManager.h
index 301696c..f53e8f8 100644
--- a/Src/DasherCore/ConversionManager.h
+++ b/Src/DasherCore/ConversionManager.h
@@ -65,7 +65,6 @@ namespace Dasher {
public:
// TODO: We shouldn't need to know about this stuff, but the code is somewhat in knots at the moment
CConversionManager(CNodeCreationManager *pNCManager, CConversionHelper *pHelper, CAlphabet *pAlphabet);
- ~CConversionManager();
///
/// Increment reference count
@@ -183,18 +182,6 @@ namespace Dasher {
void RecursiveDumpTree(SCENode *pCurrent, unsigned int iDepth);
///
- /// Flag whether the tree has already been built
- ///
-
- bool m_bTreeBuilt;
-
- ///
- /// Root of the tree (TODO: Why is this a double pointer?)
- ///
-
- SCENode **m_pRoot;
-
- ///
/// Dasher model (TODO: We ideally shouldn't need to know about this)
///
diff --git a/Src/DasherCore/ConversionManagerFactory.cpp b/Src/DasherCore/ConversionManagerFactory.cpp
index e704af0..3398af5 100644
--- a/Src/DasherCore/ConversionManagerFactory.cpp
+++ b/Src/DasherCore/ConversionManagerFactory.cpp
@@ -30,8 +30,9 @@ CConversionManagerFactory::CConversionManagerFactory(Dasher::CEventHandler *pEve
m_pAlphabet = pAlphabet;
// TODO: Need to deal with the case of GetHelper returning NULL
- m_pHelper = GetHelper(pEventHandler, pSettingsStore, iID, pCAlphIO);
-
+ CConversionHelper *pHelper = GetHelper(pEventHandler, pSettingsStore, iID, pCAlphIO);
+ m_pMgr = new CConversionManager(m_pNCManager, pHelper, m_pAlphabet);
+
//To clean up:
// TODO: These shouldn't be here - need to figure out exactly how it all works
pagecount = 0; // TODO: Doesn't actually appear to do anything
@@ -39,12 +40,11 @@ CConversionManagerFactory::CConversionManagerFactory(Dasher::CEventHandler *pEve
}
CDasherNode *CConversionManagerFactory::GetRoot(CDasherNode *pParent, int iLower, int iUpper, void *pUserData) {
- CConversionManager *pConversionManager(new CConversionManager(m_pNCManager, m_pHelper, m_pAlphabet));
-
- CDasherNode *pNewRoot = pConversionManager->GetRoot(pParent, iLower, iUpper, pUserData);
- pConversionManager->Unref();
+ return m_pMgr->GetRoot(pParent, iLower, iUpper, pUserData);
+}
- return pNewRoot;
+CConversionManagerFactory::~CConversionManagerFactory() {
+ m_pMgr->Unref();
}
// TODO: Japanese/Chinese are currently disabled in Win32 - see 'exclude from build' on individual files' property pages, plus preprocessor defines
diff --git a/Src/DasherCore/ConversionManagerFactory.h b/Src/DasherCore/ConversionManagerFactory.h
index 3200aec..1cccb21 100644
--- a/Src/DasherCore/ConversionManagerFactory.h
+++ b/Src/DasherCore/ConversionManagerFactory.h
@@ -2,6 +2,7 @@
#define __conversion_manager_factory_h__
#include "ConversionHelper.h"
+#include "ConversionManager.h"
//#include "DasherModel.h"
#include "LanguageModelling/LanguageModel.h" // Urgh - we really shouldn't need to know about language models here
@@ -9,6 +10,7 @@
namespace Dasher {
class CDasherModel; // Forward declaraion
+ class CConversionManager;
/// \ingroup Model
/// @{
@@ -16,14 +18,15 @@ namespace Dasher {
public:
CConversionManagerFactory(Dasher::CEventHandler *pEventHandler, CSettingsStore *pSettingsStore, CNodeCreationManager *pNCManager, int iID, Dasher::CAlphIO *pCAlphIO, CAlphabet *pAlphabet);
virtual CDasherNode *GetRoot(CDasherNode *pParent, int iLower, int iUpper, void *pUserData);
-
+ ~CConversionManagerFactory();
+
private:
CConversionHelper *GetHelper(Dasher::CEventHandler *pEventHandler, CSettingsStore *pSettingsStore, int iID, Dasher::CAlphIO *pCAlphIO);
CConversionHelper *GetHelperChinese(Dasher::CEventHandler *pEventHandler, CSettingsStore *pSettingsStore, Dasher::CAlphIO *pCAlphIO);
CNodeCreationManager *m_pNCManager;
- CConversionHelper *m_pHelper;
+ CConversionManager *m_pMgr;
CAlphabet *m_pAlphabet;
int m_iCMCount;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]