@@ -148,10 +148,15 @@ namespace SCIRun
148148 private:
149149 Module* module_;
150150 public:
151- ModuleImpl (Module* module , bool hasUi, ModuleStateFactoryHandle stateFactory)
151+ ModuleImpl (Module* module ,
152+ const ModuleLookupInfo& info,
153+ bool hasUi,
154+ ModuleStateFactoryHandle stateFactory)
152155 : module_(module ),
156+ info_ (info),
157+ id_(info.module_name_, DefaultModuleFactories::idGenerator_->makeId (info.module_name_)),
153158 has_ui_(hasUi),
154- state_(stateFactory ? stateFactory->make_state (module -> info_.module_name_) : new NullModuleState),
159+ state_(stateFactory ? stateFactory->make_state (info_.module_name_) : new NullModuleState),
155160 metadata_(state_),
156161 executionState_(boost::make_shared<detail::ModuleExecutionStateImpl>())
157162 {
@@ -161,6 +166,8 @@ namespace SCIRun
161166
162167 boost::atomic<bool > inputsChanged_ { false };
163168
169+ const ModuleLookupInfo info_;
170+ ModuleId id_;
164171 bool has_ui_;
165172 AlgorithmHandle algo_;
166173
@@ -200,25 +207,22 @@ Module::Module(const ModuleLookupInfo& info,
200207 bool hasUi,
201208 AlgorithmFactoryHandle algoFactory,
202209 ModuleStateFactoryHandle stateFactory,
203- ReexecuteStrategyFactoryHandle reexFactory,
204- const std::string& version)
205- : info_(info),
206- id_(info.module_name_, DefaultModuleFactories::idGenerator_->makeId (info.module_name_))
210+ ReexecuteStrategyFactoryHandle reexFactory)
207211{
208- impl_ = boost::make_shared<ModuleImpl>(this , hasUi, stateFactory);
212+ impl_ = boost::make_shared<ModuleImpl>(this , info, hasUi, stateFactory);
209213
210214 setLogger (DefaultModuleFactories::defaultLogger_);
211215 setUpdaterFunc ([](double x) {});
212216
213217 auto & log = Log::get ();
214218
215- log << DEBUG_LOG << " Module created: " << info_ .module_name_ << " with id: " << id_;
219+ log << DEBUG_LOG << " Module created: " << info .module_name_ << " with id: " << impl_-> id_ ;
216220
217221 if (algoFactory)
218222 {
219223 impl_->algo_ = algoFactory->create (get_module_name (), this );
220224 if (impl_->algo_ )
221- log << DEBUG_LOG << " Module algorithm initialized: " << info_ .module_name_ ;
225+ log << DEBUG_LOG << " Module algorithm initialized: " << info .module_name_ ;
222226 }
223227 log.flush ();
224228
@@ -235,7 +239,7 @@ void Module::set_id(const std::string& id)
235239 ModuleId newId (id);
236240 if (!DefaultModuleFactories::idGenerator_->takeId (newId.name_ , newId.idNumber_ ))
237241 THROW_INVALID_ARGUMENT (" Duplicate module IDs, invalid network file." );
238- id_ = newId;
242+ impl_-> id_ = newId;
239243}
240244
241245Module::~Module ()
@@ -251,6 +255,31 @@ bool Module::has_ui() const
251255 return impl_->has_ui_ ;
252256}
253257
258+ const ModuleLookupInfo& Module::get_info () const
259+ {
260+ return impl_->info_ ;
261+ }
262+
263+ std::string Module::get_module_name () const
264+ {
265+ return get_info ().module_name_ ;
266+ }
267+
268+ std::string Module::get_categoryname () const
269+ {
270+ return get_info ().category_name_ ;
271+ }
272+
273+ std::string Module::get_packagename () const
274+ {
275+ return get_info ().package_name_ ;
276+ }
277+
278+ ModuleId Module::get_id () const
279+ {
280+ return impl_->id_ ;
281+ }
282+
254283bool Module::executionDisabled () const
255284{
256285 return impl_->executionDisabled_ ;
@@ -263,7 +292,7 @@ void Module::setExecutionDisabled(bool disable)
263292
264293void Module::error (const std::string& msg) const
265294{
266- impl_->errorSignal_ (id_ );
295+ impl_->errorSignal_ (get_id () );
267296 getLogger ()->error (msg);
268297}
269298
@@ -334,7 +363,7 @@ void Module::copyStateToMetadata()
334363
335364bool Module::executeWithSignals () NOEXCEPT
336365{
337- auto starting = " STARTING MODULE: " + id_ .id_ ;
366+ auto starting = " STARTING MODULE: " + get_id () .id_ ;
338367#ifdef BUILD_HEADLESS // TODO: better headless logging
339368 static Mutex executeLogLock (" headlessExecution" );
340369 if (!Log::get ().verbose ())
@@ -343,7 +372,7 @@ bool Module::executeWithSignals() NOEXCEPT
343372 std::cout << starting << std::endl;
344373 }
345374#endif
346- impl_->executeBegins_ (id_ );
375+ impl_->executeBegins_ (get_id () );
347376 boost::timer executionTimer;
348377 {
349378 auto isoString = boost::posix_time::to_simple_string (boost::posix_time::microsec_clock::universal_time ());
@@ -420,7 +449,8 @@ bool Module::executeWithSignals() NOEXCEPT
420449 }
421450
422451 std::ostringstream finished;
423- finished << " MODULE " << id_.id_ << " FINISHED " << (returnCode ? " successfully " : " with errors " ) << " in " << executionTime << " seconds." ;
452+ finished << " MODULE " << get_id ().id_ << " FINISHED " <<
453+ (returnCode ? " successfully " : " with errors " ) << " in " << executionTime << " seconds." ;
424454 status (finished.str ());
425455#ifdef BUILD_HEADLESS // TODO: better headless logging
426456 if (!Log::get ().verbose ())
@@ -442,7 +472,7 @@ bool Module::executeWithSignals() NOEXCEPT
442472 impl_->inputsChanged_ = false ;
443473 }
444474
445- impl_->executeEnds_ (executionTime, id_ );
475+ impl_->executeEnds_ (executionTime, get_id () );
446476 return returnCode;
447477}
448478
@@ -550,7 +580,7 @@ std::vector<DatatypeHandleOption> Module::get_dynamic_input_handles(const PortId
550580 // NOTE: don't use short-circuited boolean OR here, we need to call hasChanged each time since it updates the port's cache flag.
551581 bool startingVal = impl_->inputsChanged_ ;
552582 impl_->inputsChanged_ = std::accumulate (portsWithName.begin (), portsWithName.end (), startingVal, [](bool acc, InputPortHandle input) { return input->hasChanged () || acc; });
553- LOG_DEBUG (id_ << " :: inputsChanged is now " << inputsChanged_);
583+ LOG_DEBUG (get_id () << " :: inputsChanged is now " << inputsChanged_);
554584 }
555585
556586 std::vector<DatatypeHandleOption> options;
0 commit comments