[dasher] Remove global 'using namespace Dasher' from top-level of header files
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Subject: [dasher] Remove global 'using namespace Dasher' from top-level of header files
- Date: Thu, 2 Jul 2009 11:19:23 +0000 (UTC)
commit 17bfc8f260befa979eeca84618ae721f75aee456
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Thu Jul 2 12:12:12 2009 +0100
Remove global 'using namespace Dasher' from top-level of header files
and move CFrameRate class into namespace Dasher.
ChangeLog | 5 ++++
Src/DasherCore/AutoSpeedControl.h | 3 --
Src/DasherCore/DasherGameMode.h | 1 -
Src/DasherCore/DasherNode.h | 12 ++--------
Src/DasherCore/DasherViewSquare.cpp | 1 +
Src/DasherCore/DefaultFilter.cpp | 2 +-
Src/DasherCore/FrameRate.cpp | 4 ++-
Src/DasherCore/FrameRate.h | 5 +--
Src/DasherCore/NodeCreationManager.h | 33 +++++++++++++++--------------
Src/DasherCore/OneButtonDynamicFilter.cpp | 4 +-
Src/DasherCore/SocketInput.h | 5 +--
Src/DasherCore/SocketInputBase.h | 9 +++----
Src/Gtk2/Preferences.cpp | 2 +
13 files changed, 42 insertions(+), 44 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 47f17bd..7ed0bd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-02 Alan Lawrence <acl33 inf phy cam ac uk>
+
+ * Remove global 'using namespace Dasher' from top-level of header
+ files and move CFrameRate class into namespace Dasher.
+
2009-07-02 Patrick Welche <prlw1 cam ac uk>
* CTWLanguageModel.cpp: Fix out of range array assignment reported
diff --git a/Src/DasherCore/AutoSpeedControl.h b/Src/DasherCore/AutoSpeedControl.h
index 7534c1e..36d0b7b 100644
--- a/Src/DasherCore/AutoSpeedControl.h
+++ b/Src/DasherCore/AutoSpeedControl.h
@@ -7,9 +7,6 @@
#include <deque>
-// Why is this using-directive in global scope in a header file?
-using namespace Dasher;
-
/// \defgroup AutoSpeed Auto speed control
/// @{
class CAutoSpeedControl : public Dasher::CDasherComponent {
diff --git a/Src/DasherCore/DasherGameMode.h b/Src/DasherCore/DasherGameMode.h
index 1a48fd8..ff24418 100644
--- a/Src/DasherCore/DasherGameMode.h
+++ b/Src/DasherCore/DasherGameMode.h
@@ -19,7 +19,6 @@ namespace Dasher {
class CDasherView;
namespace GameMode {
- using namespace Dasher;
class CDasherGameMode;
class Level;
class Scorer;
diff --git a/Src/DasherCore/DasherNode.h b/Src/DasherCore/DasherNode.h
index d88122f..1691d09 100644
--- a/Src/DasherCore/DasherNode.h
+++ b/Src/DasherCore/DasherNode.h
@@ -24,7 +24,7 @@
#include "../Common/Common.h"
#include "../Common/NoClones.h"
#include "DasherTypes.h"
-
+#include "DasherModel.h"
#include "NodeManager.h"
// These includes no longer required? - pconlon
@@ -271,12 +271,7 @@ class Dasher::CDasherNode:private NoClones {
// Inline functions
/////////////////////////////////////////////////////////////////////////////
-// Why are these using-directives in a header file?
-using namespace Dasher;
-using namespace Opts;
-// TODO: move to the top of file.
-#include "DasherModel.h"
-
+namespace Dasher {
inline CDasherNode::CDasherNode(CDasherNode *pParent, int iLbnd, int iHbnd, SDisplayInfo *pDisplayInfo) {
// TODO: Check that these are disabled for debug builds, and that we're not shipping such a build
DASHER_ASSERT(iHbnd >= iLbnd);
@@ -334,6 +329,5 @@ inline void CDasherNode::SetRange(int iLower, int iUpper) {
m_iLbnd = iLower;
m_iHbnd = iUpper;
}
-
-
+}
#endif /* #ifndef __DasherNode_h__ */
diff --git a/Src/DasherCore/DasherViewSquare.cpp b/Src/DasherCore/DasherViewSquare.cpp
index a204503..0fe9f06 100644
--- a/Src/DasherCore/DasherViewSquare.cpp
+++ b/Src/DasherCore/DasherViewSquare.cpp
@@ -39,6 +39,7 @@
#include <stdlib.h>
using namespace Dasher;
+using namespace Opts;
// Track memory leaks on Windows to the line that new'd the memory
#ifdef _WIN32
diff --git a/Src/DasherCore/DefaultFilter.cpp b/Src/DasherCore/DefaultFilter.cpp
index c85f7ea..9dc6f55 100644
--- a/Src/DasherCore/DefaultFilter.cpp
+++ b/Src/DasherCore/DefaultFilter.cpp
@@ -136,7 +136,7 @@ void CDefaultFilter::DrawMouse(CDasherView *pView) {
ApplyAutoCalibration(iDasherX, iDasherY, false);
ApplyTransform(iDasherX, iDasherY);
- pView->DasherDrawCentredRectangle(iDasherX, iDasherY, 5, 2, Opts::ColorSchemes(Objects), false);
+ pView->DasherDrawCentredRectangle(iDasherX, iDasherY, 5, 2, Opts::ColorSchemes(Opts::Objects), false);
}
void CDefaultFilter::DrawMouseLine(CDasherView *pView) {
diff --git a/Src/DasherCore/FrameRate.cpp b/Src/DasherCore/FrameRate.cpp
index 4c4fe6a..86696a6 100644
--- a/Src/DasherCore/FrameRate.cpp
+++ b/Src/DasherCore/FrameRate.cpp
@@ -1,5 +1,5 @@
#include "FrameRate.h"
-
+namespace Dasher {
CFrameRate::CFrameRate(CEventHandler *pEventHandler, CSettingsStore *pSettingsStore) :
CDasherComponent(pEventHandler, pSettingsStore) {
@@ -76,3 +76,5 @@ void CFrameRate::HandleEvent(Dasher::CEvent *pEvent) {
}
}
}
+
+}
diff --git a/Src/DasherCore/FrameRate.h b/Src/DasherCore/FrameRate.h
index 6c008f3..6438a7b 100644
--- a/Src/DasherCore/FrameRate.h
+++ b/Src/DasherCore/FrameRate.h
@@ -15,11 +15,9 @@
#include "Parameters.h"
#include "DasherComponent.h"
-// Should this using directive really be in a header file?
-using namespace Dasher;
-
const double LN2 = log(2.0);
+namespace Dasher {
/// \ingroup Model
/// \{
@@ -82,5 +80,6 @@ private:
int m_iSteps; // the 'Steps' parameter. See djw thesis.
};
/// \}
+}
#endif /* #ifndef __FrameRate_h__ */
diff --git a/Src/DasherCore/NodeCreationManager.h b/Src/DasherCore/NodeCreationManager.h
index a30419d..c21b114 100644
--- a/Src/DasherCore/NodeCreationManager.h
+++ b/Src/DasherCore/NodeCreationManager.h
@@ -17,6 +17,7 @@ namespace Dasher {
class CDasherNode;
class CDasherInterfaceBase;
};
+//TODO why is CNodeCreationManager _not_ in namespace Dasher?!?!
/// \ingroup Model
/// @{
class CNodeCreationManager : public Dasher::CDasherComponent {
@@ -31,7 +32,7 @@ class CNodeCreationManager : public Dasher::CDasherComponent {
/// Get a root node of a given type
///
- CDasherNode *GetRoot(int iType, Dasher::CDasherNode *pParent, int iLower, int iUpper, void *pUserData);
+ Dasher::CDasherNode *GetRoot(int iType, Dasher::CDasherNode *pParent, int iLower, int iUpper, void *pUserData);
///
/// Resgister a control node
@@ -64,19 +65,19 @@ class CNodeCreationManager : public Dasher::CDasherComponent {
/// Temporary methods: TODO: remove
///
- CLanguageModel *GetLanguageModel() {
+ Dasher::CLanguageModel *GetLanguageModel() {
return m_pLanguageModel;
};
- CLanguageModel::Context GetLearnContext() {
+ Dasher::CLanguageModel::Context GetLearnContext() {
return m_pAlphabetManagerFactory->GetLearnContext();
}
- void GetProbs(CLanguageModel::Context context, std::vector <symbol >&NewSymbols, std::vector <unsigned int >&Probs, int iNorm) const;
- void LearnText(CLanguageModel::Context context, std::string *TheText, bool IsMore);
- void EnterText(CLanguageModel::Context context, std::string TheText) const;
+ void GetProbs(Dasher::CLanguageModel::Context context, std::vector <Dasher::symbol >&NewSymbols, std::vector <unsigned int >&Probs, int iNorm) const;
+ void LearnText(Dasher::CLanguageModel::Context context, std::string *TheText, bool IsMore);
+ void EnterText(Dasher::CLanguageModel::Context context, std::string TheText) const;
- inline int GetColour(symbol s, int iPhase) const {
+ inline int GetColour(Dasher::symbol s, int iPhase) const {
return m_pAlphabet->GetColour(s, iPhase);
};
@@ -84,7 +85,7 @@ class CNodeCreationManager : public Dasher::CDasherComponent {
/// Get the symbol ID representing space
///
- symbol GetSpaceSymbol() const {
+ Dasher::symbol GetSpaceSymbol() const {
return m_pAlphabet->GetSpaceSymbol();
}
@@ -92,7 +93,7 @@ class CNodeCreationManager : public Dasher::CDasherComponent {
/// Get the symbol ID representing the control node
///
- symbol GetControlSymbol() const {
+ Dasher::symbol GetControlSymbol() const {
return m_pAlphabet->GetControlSymbol();
}
@@ -100,7 +101,7 @@ class CNodeCreationManager : public Dasher::CDasherComponent {
/// Get the symbol ID representing the conversion pseudo-character
///
- symbol GetStartConversionSymbol() const {
+ Dasher::symbol GetStartConversionSymbol() const {
return m_pAlphabet->GetStartConversionSymbol();
}
@@ -116,19 +117,19 @@ class CNodeCreationManager : public Dasher::CDasherComponent {
/// Get a reference to the alphabet
///
- CAlphabet *GetAlphabet() {
+ Dasher::CAlphabet *GetAlphabet() {
return m_pAlphabet;
}
void ImportTrainingText(const std::string &strPath);
private:
- CLanguageModel *m_pLanguageModel; // pointer to the language model
- CAlphabet *m_pAlphabet; // pointer to the alphabet
+ Dasher::CLanguageModel *m_pLanguageModel; // pointer to the language model
+ Dasher::CAlphabet *m_pAlphabet; // pointer to the alphabet
- CAlphabetManagerFactory *m_pAlphabetManagerFactory;
- CControlManagerFactory *m_pControlManagerFactory;
- CConversionManagerFactory *m_pConversionManagerFactory;
+ Dasher::CAlphabetManagerFactory *m_pAlphabetManagerFactory;
+ Dasher::CControlManagerFactory *m_pControlManagerFactory;
+ Dasher::CConversionManagerFactory *m_pConversionManagerFactory;
};
/// @}
diff --git a/Src/DasherCore/OneButtonDynamicFilter.cpp b/Src/DasherCore/OneButtonDynamicFilter.cpp
index 727232b..7911747 100644
--- a/Src/DasherCore/OneButtonDynamicFilter.cpp
+++ b/Src/DasherCore/OneButtonDynamicFilter.cpp
@@ -79,7 +79,7 @@ bool COneButtonDynamicFilter::DecorateView(CDasherView *pView) {
pView->Dasher2Screen(-200, 4096, x2, y2);
}
- pScreen->DrawRectangle(x1, y1, x2, y2, 1, 1, Opts::ColorSchemes(Objects), true, false, 2);
+ pScreen->DrawRectangle(x1, y1, x2, y2, 1, 1, Opts::ColorSchemes(Opts::Objects), true, false, 2);
if(m_iTarget == 1) {
pView->Dasher2Screen(-100, 3096, x1, y1);
@@ -90,7 +90,7 @@ bool COneButtonDynamicFilter::DecorateView(CDasherView *pView) {
pView->Dasher2Screen(-200, 1000, x2, y2);
}
- pScreen->DrawRectangle(x1, y1, x2, y2, 2, 2, Opts::ColorSchemes(Objects), true, false, 1);
+ pScreen->DrawRectangle(x1, y1, x2, y2, 2, 2, Opts::ColorSchemes(Opts::Objects), true, false, 1);
bool bRV(m_bDecorationChanged);
m_bDecorationChanged = false;
diff --git a/Src/DasherCore/SocketInput.h b/Src/DasherCore/SocketInput.h
index 3fccc1a..f6c2a7a 100644
--- a/Src/DasherCore/SocketInput.h
+++ b/Src/DasherCore/SocketInput.h
@@ -25,13 +25,11 @@ namespace Dasher {
#if GCC_VERSION >= 40100
void *ThreadLauncherStub(void *_myClass);
#endif
-}
-using namespace Dasher;
using namespace std;
/// \ingroup Input
/// \{
-class Dasher::CSocketInput:public CSocketInputBase {
+class CSocketInput:public CSocketInputBase {
// This non-member launcher stub function is required because pthreads can't launch a non-static member method.
friend void *ThreadLauncherStub(void *_myClass) {
@@ -61,5 +59,6 @@ private:
// TODO: should probably override ReportErrnoError() to popup a Gtk error message
};
+}
/// \}
#endif
diff --git a/Src/DasherCore/SocketInputBase.h b/Src/DasherCore/SocketInputBase.h
index b2e610c..c90f459 100644
--- a/Src/DasherCore/SocketInputBase.h
+++ b/Src/DasherCore/SocketInputBase.h
@@ -18,13 +18,11 @@
namespace Dasher {
class CSocketInputBase;
-}
-// Namespace pollution...
-using namespace Dasher;
+
using namespace std;
/// \ingroup Input
/// \{
-class Dasher::CSocketInputBase : public CDasherInput {
+class CSocketInputBase : public CDasherInput {
public:
@@ -32,7 +30,7 @@ public:
virtual ~CSocketInputBase();
- virtual void HandleEvent(Dasher::CEvent * pEvent);
+ virtual void HandleEvent(CEvent * pEvent);
virtual void SetDebug(bool _debug);
@@ -131,6 +129,7 @@ protected:
virtual void SocketDebugMsg(const char *pszFormat, ...);
};
+}
/// \}
#endif
diff --git a/Src/Gtk2/Preferences.cpp b/Src/Gtk2/Preferences.cpp
index b56a79c..ad1d0a8 100644
--- a/Src/Gtk2/Preferences.cpp
+++ b/Src/Gtk2/Preferences.cpp
@@ -15,6 +15,8 @@
#define DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf) (DasherPreferencesDialoguePrivate *)(pSelf->private_data);
+using namespace Dasher;
+
/* Static global member - use to deal with callbacks */
static DasherPreferencesDialogue *g_pPreferencesDialogue = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]