Skip to content

Commit

Permalink
Merge changes from 'hotfix/5.13.7' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento committed Feb 5, 2025
2 parents 49ab4d1 + 98b22d3 commit b6f0e64
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 17 deletions.
3 changes: 3 additions & 0 deletions libs/node/src/ecflow/node/MirrorAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void MirrorAttr::mirror() {

// ** Node Variables
std::vector<Variable> all_variables = notification.data().regular_variables;
for (const auto& variable : notification.data().inherited_variables) {
all_variables.push_back(variable);
}
for (const auto& variable : notification.data().generated_variables) {
all_variables.push_back(variable);
}
Expand Down
45 changes: 33 additions & 12 deletions libs/node/src/ecflow/node/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2653,18 +2653,6 @@ size_t Node::position() const {
return std::numeric_limits<std::size_t>::max();
}

std::vector<Variable> Node::get_all_generated_variables() const {
std::vector<Variable> all;
const Node* current = this;

while (current) {
current->gen_variables(all);
current = current->parent();
}

return all;
}

void Node::gen_variables(std::vector<Variable>& vec) const {
repeat_.gen_variables(vec); // if repeat_ is empty vec is unchanged
}
Expand Down Expand Up @@ -2940,6 +2928,39 @@ std::vector<GenericAttr>::const_iterator Node::generic_end() const {
return generics_.end();
}

namespace ecf {
std::vector<Variable> inherited_variables(const Node& node) {
std::vector<Variable> all;
const Node* current = &node;

std::set<std::string> cache;
while (current) {
for (const Variable& var : current->variables()) {
if (auto found = std::find(std::begin(cache), std::end(cache), var.name()); found == std::end(cache)) {
cache.insert(var.name());
all.push_back(var);
}
}
current = current->parent();
}

return all;
}

std::vector<Variable> generated_variables(const Node& node) {
std::vector<Variable> all;
const Node* current = &node;

while (current) {
current->gen_variables(all);
current = current->parent();
}

return all;
}

} // namespace ecf

template <class Archive>
void Node::serialize(Archive& ar, std::uint32_t const version) {
ar(CEREAL_NVP(n_));
Expand Down
32 changes: 30 additions & 2 deletions libs/node/src/ecflow/node/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,6 @@ class Node : public std::enable_shared_from_this<Node> {
void replace_meters(const std::vector<Meter>& meters);
void replace_events(const std::vector<Event>& events);

std::vector<Variable> get_all_generated_variables() const;

// Add functions: ===============================================================
void addVerify(const VerifyAttr&); // for testing and verification Can throw std::runtime_error
void addVariable(const Variable&); // will update if duplicate
Expand Down Expand Up @@ -965,4 +963,34 @@ class Node : public std::enable_shared_from_this<Node> {
void serialize(Archive& ar, std::uint32_t const version);
};

namespace ecf {

/**
* Retrieve the set of (regular) variables of the given node.
*
* @param node The node being queried
* @return The set of variables
*/
inline const std::vector<Variable>& variables(const Node& node) {
return node.variables();
}

/**
* Retrieve the set of inherited variables of the given node.
*
* @param node The node being queried
* @return The set of variables
*/
std::vector<Variable> inherited_variables(const Node& node);

/**
* Retrieve the set of generated (including inherited) variables of the given node.
*
* @param node The node being queried
* @return The set of variables
*/
std::vector<Variable> generated_variables(const Node& node);

} // namespace ecf

#endif /* ecflow_node_Node_HPP */
5 changes: 3 additions & 2 deletions libs/service/src/ecflow/service/mirror/MirrorClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ MirrorData MirrorClient::get_node_status(const std::string& remote_host,
data.state = node->state();

// ** Node Variables
data.regular_variables = node->variables();
data.generated_variables = node->get_all_generated_variables();
data.regular_variables = ecf::variables(*node);
data.inherited_variables = ecf::inherited_variables(*node);
data.generated_variables = ecf::generated_variables(*node);

// Filter out the Definitions structural variables (SUITE, to avoid conflicts with "local" side definitions
data.generated_variables.erase(
Expand Down
11 changes: 10 additions & 1 deletion libs/service/src/ecflow/service/mirror/MirrorClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ namespace ecf::service::mirror {

struct MirrorData
{
MirrorData() : state{0}, regular_variables{}, generated_variables{}, labels{}, meters{}, events{} {}
MirrorData()
: state{0},
regular_variables{},
inherited_variables{},
generated_variables{},
labels{},
meters{},
events{} {}

explicit MirrorData(int state)
: state{state},
regular_variables{},
inherited_variables{},
generated_variables{},
labels{},
meters{},
Expand All @@ -35,6 +43,7 @@ struct MirrorData
int state;

std::vector<Variable> regular_variables;
std::vector<Variable> inherited_variables;
std::vector<Variable> generated_variables;

std::vector<Label> labels;
Expand Down

0 comments on commit b6f0e64

Please sign in to comment.