mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
Recents list, DataTree rewindAll(), Bookmark view updates
This commit is contained in:
parent
560caccbc7
commit
020cef12c9
@ -14,16 +14,11 @@ void BookmarkMgr::loadFromFile(std::string bookmarkFn) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkMgr::addBookmark(std::string group, DemodulatorInstance *demod, std::string folder) {
|
|
||||||
|
void BookmarkMgr::addBookmark(std::string group, DemodulatorInstance *demod) {
|
||||||
std::lock_guard < std::mutex > lock(busy_lock);
|
std::lock_guard < std::mutex > lock(busy_lock);
|
||||||
|
|
||||||
BookmarkEntry *be = new BookmarkEntry;
|
BookmarkEntry *be = demodToBookmarkEntry(demod);
|
||||||
|
|
||||||
be->bandwidth = demod->getBandwidth();
|
|
||||||
be->type = demod->getDemodulatorType();
|
|
||||||
be->label = demod->getLabel();
|
|
||||||
be->frequency = demod->getFrequency();
|
|
||||||
be->folder = folder;
|
|
||||||
|
|
||||||
wxGetApp().getDemodMgr().saveInstance(be->node, demod);
|
wxGetApp().getDemodMgr().saveInstance(be->node, demod);
|
||||||
|
|
||||||
@ -38,22 +33,13 @@ void BookmarkMgr::removeBookmark(std::string group, BookmarkEntry *be) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BookmarkList BookmarkMgr::getBookmarks(std::string group, std::string folder) {
|
BookmarkList BookmarkMgr::getBookmarks(std::string group) {
|
||||||
std::lock_guard < std::mutex > lock(busy_lock);
|
std::lock_guard < std::mutex > lock(busy_lock);
|
||||||
|
|
||||||
BookmarkList results;
|
BookmarkList results;
|
||||||
|
|
||||||
if (folder != "") {
|
for (auto be_i : bmData[group]) {
|
||||||
for (auto be_i : bmData[group]) {
|
results.push_back(be_i);
|
||||||
results.push_back(be_i);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (auto be_i : bmData[group]) {
|
|
||||||
if (be_i->folder != folder) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
results.push_back(be_i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
@ -78,4 +64,33 @@ void BookmarkMgr::updateActiveList() {
|
|||||||
if (bmv) {
|
if (bmv) {
|
||||||
bmv->updateActiveList();
|
bmv->updateActiveList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BookmarkMgr::addRecent(DemodulatorInstance *demod) {
|
||||||
|
std::lock_guard < std::mutex > lock(busy_lock);
|
||||||
|
recents.push_back(demodToBookmarkEntry(demod));
|
||||||
|
if (recents.size() > 10) {
|
||||||
|
delete *(recents.begin());
|
||||||
|
recents.erase(recents.begin(), recents.begin()+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BookmarkList BookmarkMgr::getRecents() {
|
||||||
|
return recents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BookmarkEntry *BookmarkMgr::demodToBookmarkEntry(DemodulatorInstance *demod) {
|
||||||
|
BookmarkEntry *be = new BookmarkEntry;
|
||||||
|
|
||||||
|
be->bandwidth = demod->getBandwidth();
|
||||||
|
be->type = demod->getDemodulatorType();
|
||||||
|
be->label = demod->getLabel();
|
||||||
|
be->frequency = demod->getFrequency();
|
||||||
|
|
||||||
|
be->node = new DataNode;
|
||||||
|
wxGetApp().getDemodMgr().saveInstance(be->node, demod);
|
||||||
|
|
||||||
|
return be;
|
||||||
|
}
|
||||||
|
@ -11,7 +11,6 @@ class BookmarkEntry {
|
|||||||
public:
|
public:
|
||||||
std::mutex busy_lock;
|
std::mutex busy_lock;
|
||||||
|
|
||||||
std::string folder;
|
|
||||||
std::string type;
|
std::string type;
|
||||||
std::string label;
|
std::string label;
|
||||||
|
|
||||||
@ -40,15 +39,25 @@ public:
|
|||||||
void saveToFile(std::string bookmarkFn);
|
void saveToFile(std::string bookmarkFn);
|
||||||
void loadFromFile(std::string bookmarkFn);
|
void loadFromFile(std::string bookmarkFn);
|
||||||
|
|
||||||
void addBookmark(std::string group, DemodulatorInstance *demod, std::string folder = "");
|
void addBookmark(std::string group, DemodulatorInstance *demod);
|
||||||
void removeBookmark(std::string group, BookmarkEntry *be);
|
void removeBookmark(std::string group, BookmarkEntry *be);
|
||||||
BookmarkList getBookmarks(std::string group, std::string folder = "");
|
|
||||||
|
BookmarkList getBookmarks(std::string group);
|
||||||
|
|
||||||
BookmarkGroup getGroup(std::string group);
|
BookmarkGroup getGroup(std::string group);
|
||||||
BookmarkNames getGroups();
|
BookmarkNames getGroups();
|
||||||
|
|
||||||
void updateActiveList();
|
void updateActiveList();
|
||||||
|
|
||||||
|
void addRecent(DemodulatorInstance *demod);
|
||||||
|
BookmarkList getRecents();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
BookmarkEntry *demodToBookmarkEntry(DemodulatorInstance *demod);
|
||||||
|
|
||||||
BookmarkMap bmData;
|
BookmarkMap bmData;
|
||||||
|
BookmarkList recents;
|
||||||
std::mutex busy_lock;
|
std::mutex busy_lock;
|
||||||
};
|
};
|
||||||
|
@ -132,6 +132,8 @@ DemodulatorInstance *DemodulatorMgr::getFirstDemodulator() {
|
|||||||
|
|
||||||
void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
|
void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
|
|
||||||
|
wxGetApp().getBookmarkMgr().addRecent(demod);
|
||||||
|
|
||||||
std::vector<DemodulatorInstance *>::iterator i;
|
std::vector<DemodulatorInstance *>::iterator i;
|
||||||
|
|
||||||
@ -409,6 +411,8 @@ void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstance *inst) {
|
|||||||
DemodulatorInstance *DemodulatorMgr::loadInstance(DataNode *node) {
|
DemodulatorInstance *DemodulatorMgr::loadInstance(DataNode *node) {
|
||||||
DemodulatorInstance *newDemod = nullptr;
|
DemodulatorInstance *newDemod = nullptr;
|
||||||
|
|
||||||
|
node->rewindAll();
|
||||||
|
|
||||||
long bandwidth = *node->getNext("bandwidth");
|
long bandwidth = *node->getNext("bandwidth");
|
||||||
long long freq = *node->getNext("frequency");
|
long long freq = *node->getNext("frequency");
|
||||||
float squelch_level = node->hasAnother("squelch_level") ? (float) *node->getNext("squelch_level") : 0;
|
float squelch_level = node->hasAnother("squelch_level") ? (float) *node->getNext("squelch_level") : 0;
|
||||||
|
@ -2,14 +2,20 @@
|
|||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) {
|
BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) {
|
||||||
|
|
||||||
rootBranch = m_treeView->AddRoot("Root");
|
rootBranch = m_treeView->AddRoot("Root");
|
||||||
activeBranch = m_treeView->AppendItem(rootBranch, "Active");
|
activeBranch = m_treeView->AppendItem(rootBranch, "Active");
|
||||||
bookmarkBranch = m_treeView->AppendItem(rootBranch, "Bookmarks");
|
bookmarkBranch = m_treeView->AppendItem(rootBranch, "Bookmarks");
|
||||||
|
recentBranch = m_treeView->AppendItem(rootBranch, "Recents");
|
||||||
|
|
||||||
doUpdateActive = false;
|
doUpdateActive = false;
|
||||||
activeSel = nullptr;
|
activeSel = nullptr;
|
||||||
m_updateTimer.Start(500);
|
recentSel = nullptr;
|
||||||
|
|
||||||
hideProps();
|
hideProps();
|
||||||
m_propPanel->Hide();
|
m_propPanel->Hide();
|
||||||
|
|
||||||
|
m_updateTimer.Start(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onUpdateTimer( wxTimerEvent& event ) {
|
void BookmarkView::onUpdateTimer( wxTimerEvent& event ) {
|
||||||
@ -56,6 +62,7 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator();
|
DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator();
|
||||||
// DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
// DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
|
// Actives
|
||||||
activeItems.erase(activeItems.begin(),activeItems.end());
|
activeItems.erase(activeItems.begin(),activeItems.end());
|
||||||
m_treeView->DeleteChildren(activeBranch);
|
m_treeView->DeleteChildren(activeBranch);
|
||||||
|
|
||||||
@ -73,10 +80,24 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
selItem = itm;
|
selItem = itm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recents
|
||||||
|
BookmarkList bmRecents = wxGetApp().getBookmarkMgr().getRecents();
|
||||||
|
recentItems.erase(recentItems.begin(),recentItems.end());
|
||||||
|
m_treeView->DeleteChildren(recentBranch);
|
||||||
|
|
||||||
|
for (auto bmr_i: bmRecents) {
|
||||||
|
wxTreeItemId itm = m_treeView->AppendItem(recentBranch, bmr_i->label);
|
||||||
|
recentItems[itm] = bmr_i;
|
||||||
|
if (recentSel == bmr_i) {
|
||||||
|
selItem = itm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (selItem != nullptr) {
|
if (selItem != nullptr) {
|
||||||
m_treeView->SelectItem(selItem);
|
m_treeView->SelectItem(selItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_treeView->Enable();
|
m_treeView->Enable();
|
||||||
m_treeView->ExpandAll();
|
m_treeView->ExpandAll();
|
||||||
}
|
}
|
||||||
@ -90,7 +111,9 @@ void BookmarkView::onTreeEndLabelEdit( wxTreeEvent& event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
||||||
event.Skip();
|
if (recentSel) {
|
||||||
|
activateBookmark(recentSel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
|
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
|
||||||
@ -121,6 +144,7 @@ void BookmarkView::hideProps() {
|
|||||||
|
|
||||||
void BookmarkView::activeSelection(DemodulatorInstance *dsel) {
|
void BookmarkView::activeSelection(DemodulatorInstance *dsel) {
|
||||||
activeSel = dsel;
|
activeSel = dsel;
|
||||||
|
recentSel = nullptr;
|
||||||
|
|
||||||
m_frequencyVal->SetLabelText(frequencyToStr(dsel->getFrequency()));
|
m_frequencyVal->SetLabelText(frequencyToStr(dsel->getFrequency()));
|
||||||
m_bandwidthVal->SetLabelText(frequencyToStr(dsel->getBandwidth()));
|
m_bandwidthVal->SetLabelText(frequencyToStr(dsel->getBandwidth()));
|
||||||
@ -147,21 +171,100 @@ void BookmarkView::activeSelection(DemodulatorInstance *dsel) {
|
|||||||
this->Layout();
|
this->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BookmarkView::activateBookmark(BookmarkEntry *bmEnt) {
|
||||||
|
DemodulatorInstance *newDemod = wxGetApp().getDemodMgr().loadInstance(bmEnt->node);
|
||||||
|
newDemod->run();
|
||||||
|
newDemod->setActive(true);
|
||||||
|
wxGetApp().bindDemodulator(newDemod);
|
||||||
|
if (bmEnt == recentSel) {
|
||||||
|
activeSel = newDemod;
|
||||||
|
recentSel = nullptr;
|
||||||
|
}
|
||||||
|
doUpdateActiveList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkView::bookmarkSelection(BookmarkEntry *bmSel) {
|
||||||
|
bookmarkSel = bmSel;
|
||||||
|
recentSel = nullptr;
|
||||||
|
activeSel = nullptr;
|
||||||
|
|
||||||
|
m_frequencyVal->SetLabelText(frequencyToStr(bmSel->frequency));
|
||||||
|
m_bandwidthVal->SetLabelText(frequencyToStr(bmSel->bandwidth));
|
||||||
|
m_modulationVal->SetLabelText(bmSel->type);
|
||||||
|
m_labelText->SetValue(bmSel->label);
|
||||||
|
|
||||||
|
hideProps();
|
||||||
|
|
||||||
|
m_frequencyVal->Show();
|
||||||
|
m_frequencyLabel->Show();
|
||||||
|
|
||||||
|
m_bandwidthVal->Show();
|
||||||
|
m_bandwidthLabel->Show();
|
||||||
|
|
||||||
|
m_modulationVal->Show();
|
||||||
|
m_modulationLabel->Show();
|
||||||
|
|
||||||
|
m_labelText->Show();
|
||||||
|
m_labelLabel->Show();
|
||||||
|
|
||||||
|
m_activateButton->Show();
|
||||||
|
m_bookmarkButton->Show();
|
||||||
|
m_removeButton->Show();
|
||||||
|
|
||||||
|
this->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BookmarkView::recentSelection(BookmarkEntry *bmSel) {
|
||||||
|
recentSel = bmSel;
|
||||||
|
activeSel = nullptr;
|
||||||
|
bookmarkSel = nullptr;
|
||||||
|
|
||||||
|
m_frequencyVal->SetLabelText(frequencyToStr(bmSel->frequency));
|
||||||
|
m_bandwidthVal->SetLabelText(frequencyToStr(bmSel->bandwidth));
|
||||||
|
m_modulationVal->SetLabelText(bmSel->type);
|
||||||
|
m_labelText->SetValue(bmSel->label);
|
||||||
|
|
||||||
|
hideProps();
|
||||||
|
|
||||||
|
m_frequencyVal->Show();
|
||||||
|
m_frequencyLabel->Show();
|
||||||
|
|
||||||
|
m_bandwidthVal->Show();
|
||||||
|
m_bandwidthLabel->Show();
|
||||||
|
|
||||||
|
m_modulationVal->Show();
|
||||||
|
m_modulationLabel->Show();
|
||||||
|
|
||||||
|
m_labelText->Show();
|
||||||
|
m_labelLabel->Show();
|
||||||
|
|
||||||
|
m_activateButton->Show();
|
||||||
|
m_bookmarkButton->Show();
|
||||||
|
m_removeButton->Hide();
|
||||||
|
|
||||||
|
this->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
|
void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
|
||||||
if (activeItems.find(event.GetItem()) != activeItems.end()) {
|
if (activeItems.find(event.GetItem()) != activeItems.end()) {
|
||||||
DemodulatorInstance *dsel = activeItems[event.GetItem()];
|
DemodulatorInstance *dsel = activeItems[event.GetItem()];
|
||||||
m_propPanel->Show();
|
m_propPanel->Show();
|
||||||
activeSelection(dsel);
|
activeSelection(dsel);
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
||||||
|
} else if (recentItems.find(event.GetItem()) != recentItems.end()) {
|
||||||
|
recentSel = recentItems[event.GetItem()];
|
||||||
|
m_propPanel->Show();
|
||||||
|
recentSelection(recentSel);
|
||||||
} else {
|
} else {
|
||||||
activeSel = nullptr;
|
activeSel = nullptr;
|
||||||
|
recentSel = nullptr;
|
||||||
|
|
||||||
m_propPanel->Hide();
|
m_propPanel->Hide();
|
||||||
hideProps();
|
hideProps();
|
||||||
this->Layout();
|
this->Layout();
|
||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
||||||
event.Skip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +280,6 @@ void BookmarkView::onDoubleClickFreq( wxMouseEvent& event ) {
|
|||||||
if (activeSel) {
|
if (activeSel) {
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
||||||
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT);
|
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT);
|
||||||
} else {
|
|
||||||
event.Skip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +287,6 @@ void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& event ) {
|
|||||||
if (activeSel) {
|
if (activeSel) {
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
||||||
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH);
|
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH);
|
||||||
} else {
|
|
||||||
event.Skip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +295,9 @@ void BookmarkView::onBookmark( wxCommandEvent& event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onActivate( wxCommandEvent& event ) {
|
void BookmarkView::onActivate( wxCommandEvent& event ) {
|
||||||
event.Skip();
|
if (recentSel) {
|
||||||
|
activateBookmark(recentSel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onRemove( wxCommandEvent& event ) {
|
void BookmarkView::onRemove( wxCommandEvent& event ) {
|
||||||
@ -205,8 +306,6 @@ void BookmarkView::onRemove( wxCommandEvent& event ) {
|
|||||||
wxGetApp().removeDemodulator(activeSel);
|
wxGetApp().removeDemodulator(activeSel);
|
||||||
wxGetApp().getDemodMgr().deleteThread(activeSel);
|
wxGetApp().getDemodMgr().deleteThread(activeSel);
|
||||||
activeSel = nullptr;
|
activeSel = nullptr;
|
||||||
} else {
|
|
||||||
event.Skip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,9 @@ public:
|
|||||||
|
|
||||||
void updateActiveList();
|
void updateActiveList();
|
||||||
void activeSelection(DemodulatorInstance *dsel);
|
void activeSelection(DemodulatorInstance *dsel);
|
||||||
|
void bookmarkSelection(BookmarkEntry *bmSel);
|
||||||
|
void activateBookmark(BookmarkEntry *bmEnt);
|
||||||
|
void recentSelection(BookmarkEntry *bmSel);
|
||||||
void updateTheme();
|
void updateTheme();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -34,9 +37,13 @@ protected:
|
|||||||
void onRemove( wxCommandEvent& event );
|
void onRemove( wxCommandEvent& event );
|
||||||
|
|
||||||
bool doUpdateActive;
|
bool doUpdateActive;
|
||||||
wxTreeItemId rootBranch, activeBranch, bookmarkBranch;
|
wxTreeItemId rootBranch, activeBranch, bookmarkBranch, recentBranch;
|
||||||
std::map<std::string, wxTreeItemId> groups;
|
std::map<std::string, wxTreeItemId> groups;
|
||||||
|
|
||||||
std::map<wxTreeItemId, DemodulatorInstance *> activeItems;
|
std::map<wxTreeItemId, DemodulatorInstance *> activeItems;
|
||||||
|
std::map<wxTreeItemId, BookmarkEntry *> recentItems;
|
||||||
DemodulatorInstance *activeSel;
|
DemodulatorInstance *activeSel;
|
||||||
|
BookmarkEntry *recentSel;
|
||||||
|
BookmarkEntry *bookmarkSel;
|
||||||
|
|
||||||
};
|
};
|
@ -565,6 +565,7 @@ DataNode *DataNode::getNext(const char *name_in) {
|
|||||||
|
|
||||||
void DataNode::rewind() {
|
void DataNode::rewind() {
|
||||||
ptr = 0;
|
ptr = 0;
|
||||||
|
childmap_ptr.erase(childmap_ptr.begin(),childmap_ptr.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataNode::rewind(const char *name_in) {
|
void DataNode::rewind(const char *name_in) {
|
||||||
@ -1342,6 +1343,38 @@ long DataTree::getSerializedSize(DataElement &de_node_names, bool debug) /* get
|
|||||||
return total_size;
|
return total_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataNode::rewindAll() {
|
||||||
|
stack<DataNode *> dn_stack;
|
||||||
|
|
||||||
|
/* start at the root */
|
||||||
|
dn_stack.push(this);
|
||||||
|
|
||||||
|
while (!dn_stack.empty()) {
|
||||||
|
dn_stack.top()->rewind();
|
||||||
|
|
||||||
|
/* if it has children, traverse into them */
|
||||||
|
if (dn_stack.top()->hasAnother()) {
|
||||||
|
dn_stack.push(dn_stack.top()->getNext());
|
||||||
|
dn_stack.top()->rewind();
|
||||||
|
} else {
|
||||||
|
/* no more children, back out until we have children, then add next child to the top */
|
||||||
|
while (!dn_stack.empty()) {
|
||||||
|
if (!dn_stack.top()->hasAnother()) {
|
||||||
|
dn_stack.top()->rewind();
|
||||||
|
dn_stack.pop();
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dn_stack.empty()) {
|
||||||
|
dn_stack.push(dn_stack.top()->getNext());
|
||||||
|
dn_stack.top()->rewind();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void DataNode::findAll(const char *name_in, vector<DataNode *> &node_list_out) {
|
void DataNode::findAll(const char *name_in, vector<DataNode *> &node_list_out) {
|
||||||
stack<DataNode *> dn_stack;
|
stack<DataNode *> dn_stack;
|
||||||
|
|
||||||
|
@ -260,7 +260,8 @@ public:
|
|||||||
DataNode *getNext(); /* get next child */
|
DataNode *getNext(); /* get next child */
|
||||||
void rewind(const char *name_in); /* rewind specific */
|
void rewind(const char *name_in); /* rewind specific */
|
||||||
void rewind(); /* rewind generic */
|
void rewind(); /* rewind generic */
|
||||||
|
void rewindAll();
|
||||||
|
|
||||||
void findAll(const char *name_in, vector<DataNode *> &node_list_out);
|
void findAll(const char *name_in, vector<DataNode *> &node_list_out);
|
||||||
|
|
||||||
// operator string () { string s; element()->get(s); return s; }
|
// operator string () { string s; element()->get(s); return s; }
|
||||||
@ -316,7 +317,6 @@ public:
|
|||||||
bool operator() () { return hasAnother(); }
|
bool operator() () { return hasAnother(); }
|
||||||
|
|
||||||
DataNode *operator ^(const char *name_in) { return newChild(name_in); }
|
DataNode *operator ^(const char *name_in) { return newChild(name_in); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user