mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Draft searchFileVisitor
This commit is contained in:
@@ -39,3 +39,52 @@ void SearchVisitor::visit(Scene &n)
|
||||
// search only in workspace
|
||||
n.ws()->accept(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SearchFileVisitor::SearchFileVisitor(std::string filename) : Visitor(), filename_(filename), found_(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SearchFileVisitor::visit(Node &n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SearchFileVisitor::visit(Group &n)
|
||||
{
|
||||
if (found_)
|
||||
return;
|
||||
|
||||
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
||||
(*node)->accept(*this);
|
||||
if (found_)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchFileVisitor::visit(Switch &n)
|
||||
{
|
||||
if (n.numChildren()>0)
|
||||
n.activeChild()->accept(*this);
|
||||
}
|
||||
|
||||
|
||||
void SearchFileVisitor::visit(Scene &n)
|
||||
{
|
||||
// search only in workspace
|
||||
n.ws()->accept(*this);
|
||||
}
|
||||
|
||||
|
||||
void SearchFileVisitor::visit (MediaSource& s)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SearchFileVisitor::visit (SessionFileSource& s)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SEARCHVISITOR_H
|
||||
#define SEARCHVISITOR_H
|
||||
|
||||
#include <string>
|
||||
#include "Visitor.h"
|
||||
|
||||
class SearchVisitor: public Visitor
|
||||
@@ -14,12 +15,33 @@ public:
|
||||
inline Node *node() const { return found_ ? node_ : nullptr; }
|
||||
|
||||
// Elements of Scene
|
||||
void visit(Scene& n);
|
||||
void visit(Node& n);
|
||||
void visit(Primitive&) {}
|
||||
void visit(Group& n);
|
||||
void visit(Switch& n);
|
||||
void visit(Scene& n) override;
|
||||
void visit(Node& n) override;
|
||||
void visit(Primitive&) override {}
|
||||
void visit(Group& n) override;
|
||||
void visit(Switch& n) override;
|
||||
|
||||
};
|
||||
|
||||
class SearchFileVisitor: public Visitor
|
||||
{
|
||||
std::string filename_;
|
||||
bool found_;
|
||||
|
||||
public:
|
||||
SearchFileVisitor(std::string filename);
|
||||
inline bool found() const { return found_; }
|
||||
|
||||
// Elements of Scene
|
||||
void visit(Scene& n) override;
|
||||
void visit(Node& n) override;
|
||||
void visit(Primitive&) override {}
|
||||
void visit(Group& n) override;
|
||||
void visit(Switch& n) override;
|
||||
|
||||
// Sources
|
||||
void visit (MediaSource& s) override;
|
||||
void visit (SessionFileSource& s) override;
|
||||
};
|
||||
|
||||
#endif // SEARCHVISITOR_H
|
||||
|
||||
Reference in New Issue
Block a user