Skip to content

Commit

Permalink
serveral minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylannl committed Jun 14, 2020
1 parent 70efd34 commit bf84681
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/geoflow/core_nodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ namespace geoflow::nodes::core {
for (auto& data : output_term->get_data_vec()) {
vector_output(node_name+"."+term_name).push_back_any(data);
}
} else {
vector_output(node_name+"."+term_name).push_back_any(std::any());
}
} else {
auto output_term = (gfMultiFeatureOutputTerminal*)(output_term_.get());
Expand Down
17 changes: 9 additions & 8 deletions src/geoflow/geoflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ std::string Node::debug_info() {
void NodeManager::queue(std::shared_ptr<Node> n) {
node_queue.push(n);
}
bool NodeManager::run_all() {
size_t NodeManager::run_all() {
// find all root nodes with autorun enabled
std::vector<NodeHandle> to_run;
for (auto& [name, node] : nodes) {
Expand All @@ -426,15 +426,16 @@ bool NodeManager::run_all() {
for (auto& node : to_run){
node->notify_children();
}
bool ran_something = false;
size_t run_count = 0;
for (auto& node : to_run){
ran_something |= run(node);
run_count += run(node);
}
return ran_something;
return run_count;
}
bool NodeManager::run(Node &node, bool notify_children) {
size_t NodeManager::run(Node &node, bool notify_children) {
std::queue<std::shared_ptr<Node>>().swap(node_queue); // clear to prevent double processing of nodes ()
node.update_status();
size_t run_count = 0;
if (node.queue()) {
if (notify_children) node.notify_children();
while (!node_queue.empty()) {
Expand All @@ -452,11 +453,11 @@ bool NodeManager::run(Node &node, bool notify_children) {
std::clock_t c_end = std::clock(); // CPU time
std::cerr << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << "ms\n";
n->status_ = GF_NODE_DONE;
++run_count;
n->propagate_outputs();
}
return true;
}
return false;
}
return run_count;
}
NodeHandle NodeManager::create_node(NodeRegisterHandle node_register, std::string type_name) {
// add node through a node register
Expand Down
19 changes: 16 additions & 3 deletions src/geoflow/geoflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ namespace geoflow {
touch();
}

bool has_value(size_t i=0) {
return !data_[i].has_value();
}

// multi element
size_t size() { return data_.size(); };
template<typename T>void resize(size_t n) {
Expand Down Expand Up @@ -364,6 +368,15 @@ namespace geoflow {
return *terminals_.at(term_name).get();
};

void operator=(gfMultiFeatureInputTerminal& gfMFInput) {
clear();
for(const auto& iterm : gfMFInput.sub_terminals()) {
auto& oterm = add_vector(iterm->get_name(), iterm->get_type());
oterm = iterm->get_data_vec();
}
touch();
}

// void connect(gfInputTerminal& in);
// void disconnect(gfInputTerminal& in);

Expand Down Expand Up @@ -702,9 +715,9 @@ namespace geoflow {

std::string substitute_globals(const std::string& text) const;

bool run_all();
bool run(Node &node, bool notify_children=true);
bool run(NodeHandle node, bool notify_children=true) {
size_t run_all();
size_t run(Node &node, bool notify_children=true);
size_t run(NodeHandle node, bool notify_children=true) {
return run(*node, notify_children);
};

Expand Down

0 comments on commit bf84681

Please sign in to comment.