Skip to content

Commit d212be7

Browse files
committed
Load metadata on file load
1 parent 67c89d8 commit d212be7

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/Dataflow/Network/Module.cc

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -222,26 +222,29 @@ size_t Module::num_output_ports() const
222222
return oports_.size();
223223
}
224224

225-
namespace //TODO requirements for state metadata reporting
225+
//TODO requirements for state metadata reporting
226+
std::string Module::stateMetaInfo() const
226227
{
227-
std::string stateMetaInfo(ModuleStateHandle state)
228+
if (!state_)
229+
return "Null state map.";
230+
auto keys = state_->getKeys();
231+
size_t i = 0;
232+
std::ostringstream ostr;
233+
ostr << "\n\t{";
234+
for (const auto& key : keys)
228235
{
229-
if (!state)
230-
return "Null state map.";
231-
auto keys = state->getKeys();
232-
size_t i = 0;
233-
std::ostringstream ostr;
234-
ostr << "\n\t{";
235-
for (const auto& key : keys)
236-
{
237-
ostr << "[" << key.name() << ", " << state->getValue(key).value() << "]";
238-
i++;
239-
if (i < keys.size())
240-
ostr << ",\n\t";
241-
}
242-
ostr << "}";
243-
return ostr.str();
236+
ostr << "[" << key.name() << ", " << state_->getValue(key).value() << "]";
237+
i++;
238+
if (i < keys.size())
239+
ostr << ",\n\t";
244240
}
241+
ostr << "}";
242+
return ostr.str();
243+
}
244+
245+
void Module::copyStateToMetadata()
246+
{
247+
metadata_.setMetadata("Module state", stateMetaInfo());
245248
}
246249

247250
bool Module::executeWithSignals() NOEXCEPT
@@ -253,7 +256,7 @@ bool Module::executeWithSignals() NOEXCEPT
253256
{
254257
std::string isoString = boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::universal_time());
255258
metadata_.setMetadata("Last execution timestamp", isoString);
256-
metadata_.setMetadata("Module state", stateMetaInfo(get_state()));
259+
copyStateToMetadata();
257260
}
258261
/// @todo: status() calls should be logged everywhere, need to change legacy loggers. issue #nnn
259262
status("STARTING MODULE: " + id_.id_);
@@ -362,6 +365,7 @@ void Module::set_state(ModuleStateHandle state)
362365
}
363366
initStateObserver(state_.get());
364367
postStateChangeInternalSignalHookup();
368+
copyStateToMetadata();
365369
}
366370

367371
AlgorithmBase& Module::algo()

src/Dataflow/Network/Module.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ namespace Networks {
277277
virtual void postStateChangeInternalSignalHookup() {}
278278
void sendFeedbackUpstreamAlongIncomingConnections(const Core::Datatypes::ModuleFeedback& feedback) const;
279279

280+
std::string stateMetaInfo() const;
281+
void copyStateToMetadata();
282+
280283
private:
281284
template <class T>
282285
boost::shared_ptr<T> getRequiredInputAtIndex(const PortId& id);

0 commit comments

Comments
 (0)