[dasher: 182/217] Control Manager is resolving forward referrences correctly now
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 182/217] Control Manager is resolving forward referrences correctly now
- Date: Sat, 27 Feb 2016 12:15:37 +0000 (UTC)
commit 464bda9ec4f539924d8ea1f58076971725373fa2
Author: Ada Majorek <amajorek google com>
Date: Fri Jan 22 12:55:28 2016 -0800
Control Manager is resolving forward referrences correctly now
fixes https://github.com/ipomoena/dasher/issues/73
Src/DasherCore/ControlManager.cpp | 18 +++++++++---------
Src/DasherCore/ControlManager.h | 11 ++++++-----
2 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/Src/DasherCore/ControlManager.cpp b/Src/DasherCore/ControlManager.cpp
index a8edd7a..d831af6 100644
--- a/Src/DasherCore/ControlManager.cpp
+++ b/Src/DasherCore/ControlManager.cpp
@@ -77,11 +77,11 @@ void CControlBase::ChangeScreen(CDasherScreen *pScreen) {
templateQueue.pop_front();
delete head->m_pLabel;
head->m_pLabel = pScreen->MakeLabel(head->m_strLabel);
- for (vector<NodeTemplate *>::iterator it = head->successors.begin(); it!=head->successors.end(); it++) {
- if (!(*it)) continue; //an escape back to the alphabet, no label/successors here
- if (allTemplates.find(*it)==allTemplates.end()) {
- allTemplates.insert(*it);
- templateQueue.push_back(*it);
+ for (auto child : head->successors) {
+ if (!child) continue; //an escape back to the alphabet, no label/successors here
+ if (allTemplates.find(child)==allTemplates.end()) {
+ allTemplates.insert(child);
+ templateQueue.push_back(child);
}
}
}
@@ -110,17 +110,17 @@ void CControlBase::CContNode::PopulateChildren() {
unsigned int iLbnd(0), iIdx(0);
int newOffset = m_pTemplate->calculateNewOffset(this, offset());
- for (vector<NodeTemplate *>::iterator it = m_pTemplate->successors.begin();
it!=m_pTemplate->successors.end(); it++) {
+ for (auto child : m_pTemplate->successors) {
const unsigned int iHbnd((++iIdx*CDasherModel::NORMALIZATION)/iNChildren);
- if( *it == NULL ) {
+ if( child == NULL ) {
// Escape back to alphabet
pNewNode = m_pMgr->m_pNCManager->GetAlphabetManager()->GetRoot(this, false, newOffset + 1);
}
else {
- pNewNode = new CContNode(newOffset, m_pMgr->getColour(*it, this), *it, m_pMgr);
+ pNewNode = new CContNode(newOffset, m_pMgr->getColour(child, this), child, m_pMgr);
}
pNewNode->Reparent(this, iLbnd, iHbnd);
iLbnd=iHbnd;
@@ -136,7 +136,7 @@ void CControlBase::CContNode::Output() {
m_pTemplate->happen(this);
}
-const vector<CControlBase::NodeTemplate *> &CControlParser::parsedNodes() {
+const list<CControlBase::NodeTemplate *> &CControlParser::parsedNodes() {
return m_vParsed;
}
diff --git a/Src/DasherCore/ControlManager.h b/Src/DasherCore/ControlManager.h
index a341d43..ac495f5 100644
--- a/Src/DasherCore/ControlManager.h
+++ b/Src/DasherCore/ControlManager.h
@@ -26,6 +26,7 @@
#include "NodeManager.h"
#include "NodeCreationManager.h"
+#include <list>
#include <vector>
#include <map>
#include <fstream>
@@ -93,7 +94,7 @@ namespace Dasher {
virtual ~NodeTemplate();
const std::string m_strLabel;
const int m_iColour;
- std::vector<NodeTemplate *> successors;
+ std::list<NodeTemplate *> successors;
private:
friend class CControlBase;
@@ -148,7 +149,7 @@ namespace Dasher {
bool ParseFile(const std::string &strFilename, bool bUser);
protected:
/// \return all node definitions that have been loaded by this CControlParser.
- const vector<CControlBase::NodeTemplate*> &parsedNodes();
+ const list<CControlBase::NodeTemplate*> &parsedNodes();
///Subclasses may override to parse other nodes (besides "node", "ref" and "alph").
///The default implementation always returns NULL.
/// \return A node template, if the name was recognised; NULL if not recognised.
@@ -166,14 +167,14 @@ namespace Dasher {
void XmlEndHandler(const XML_Char *szName);
private:
///all top-level parsed nodes
- vector<CControlBase::NodeTemplate *> m_vParsed;
+ std::list<CControlBase::NodeTemplate *> m_vParsed;
///whether parsed nodes were from user file or not
bool m_bUser;
///Following only used as temporary variables during parsing...
map<string,CControlBase::NodeTemplate*> namedNodes;
- vector<pair<CControlBase::NodeTemplate**,string> > unresolvedRefs;
- vector<CControlBase::NodeTemplate*> nodeStack;
+ list<pair<CControlBase::NodeTemplate**,string> > unresolvedRefs;
+ list<CControlBase::NodeTemplate*> nodeStack;
};
///subclass which we actually construct! Parses editing node definitions from a file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]