@@ -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
247250bool 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
367371AlgorithmBase& Module::algo ()
0 commit comments