@@ -38,21 +38,26 @@ using namespace SCIRun::Dataflow::Networks;
3838using namespace SCIRun ::Core::Algorithms;
3939using namespace SCIRun ::Core::Logging;
4040
41- SimpleMapModuleState::SimpleMapModuleState ()
41+ SimpleMapModuleState::SimpleMapModuleState (const std::string& name) : name_(name)
4242{
43+ // std::cout << "SMMS ctor " << name_ << std::endl;
4344}
4445
4546SimpleMapModuleState::SimpleMapModuleState (SimpleMapModuleState&& rhs)
46- : stateMap_(std::move(rhs.stateMap_)),
47- transientStateMap_(std::move(rhs.transientStateMap_))
47+ : stateMap_(std::move(rhs.stateMap_)),
48+ transientStateMap_(std::move(rhs.transientStateMap_)),
49+ name_(std::move(rhs.name_))
4850{
51+ // std::cout << "SMMS move ctor " << name_ << std::endl;
4952 stateChangedSignal_.swap (rhs.stateChangedSignal_ );
5053}
5154
5255SimpleMapModuleState::SimpleMapModuleState (const SimpleMapModuleState& rhs)
53- : stateMap_(rhs.stateMap_),
54- transientStateMap_(rhs.transientStateMap_) // / @todo: I think this is wrong, transient shouldn't be copied
56+ : stateMap_(rhs.stateMap_),
57+ transientStateMap_(rhs.transientStateMap_), // / @todo: I think this is wrong, transient shouldn't be copied
58+ name_(rhs.name_)
5559{
60+ // std::cout << "SMMS copy ctor " << name_ << std::endl;
5661}
5762
5863SimpleMapModuleState& SimpleMapModuleState::operator =(const SimpleMapModuleState& rhs)
@@ -61,6 +66,8 @@ SimpleMapModuleState& SimpleMapModuleState::operator=(const SimpleMapModuleState
6166 {
6267 stateMap_ = rhs.stateMap_ ;
6368 transientStateMap_ = rhs.transientStateMap_ ; // / @todo: I think this is wrong, transient shouldn't be copied
69+ name_ = rhs.name_ ;
70+ // std::cout << "SMMS copy assign " << name_<< std::endl;
6471 // / @todo??
6572 // stateChangedSignal_.disconnect_all_slots();
6673 }
@@ -69,6 +76,7 @@ SimpleMapModuleState& SimpleMapModuleState::operator=(const SimpleMapModuleState
6976
7077ModuleStateHandle SimpleMapModuleState::clone () const
7178{
79+ // std::cout << "SMMS clone " << name_ << std::endl;
7280 return boost::make_shared<SimpleMapModuleState>(*this );
7381}
7482
@@ -89,7 +97,7 @@ void SimpleMapModuleState::setValue(const Name& parameterName, const SCIRun::Cor
8997 bool newValue = oldLocation == stateMap_.end () || !(oldLocation->second .value () == value);
9098
9199 stateMap_[parameterName] = AlgorithmParameter (parameterName, value);
92-
100+
93101 if (newValue)
94102 {
95103 LOG_DEBUG (" ----signaling from state map: (" << parameterName.name_ << " , " << SCIRun::Core::to_string (value) << " ), num_slots = " << stateChangedSignal_.num_slots () << std::endl);
@@ -112,15 +120,27 @@ ModuleStateInterface::Keys SimpleMapModuleState::getKeys() const
112120 return keys;
113121}
114122
123+ void SimpleMapModuleState::print () const
124+ {
125+ std::cout << " Printing transient map: " << this << " name: " << name_ << std::endl;
126+ for (auto q = transientStateMap_.begin (); q != transientStateMap_.end (); ++q)
127+ {
128+ std::cout << " \t " << q->first << " : " << " any" << std::endl;
129+ }
130+ std::cout << " Done" << std::endl;
131+ }
132+
115133SimpleMapModuleState::TransientValueOption SimpleMapModuleState::getTransientValue (const Name& name) const
116134{
117- TransientStateMap::const_iterator i = transientStateMap_.find (name.name ());
135+ // print();
136+ auto i = transientStateMap_.find (name.name ());
118137 return i != transientStateMap_.end () ? boost::make_optional (i->second ) : TransientValueOption ();
119138}
120139
121140void SimpleMapModuleState::setTransientValue (const Name& name, const TransientValue& value, bool fireSignal)
122141{
123142 transientStateMap_[name.name ()] = value;
143+ // print();
124144
125145 if (fireSignal)
126146 fireTransientStateChangeSignal ();
@@ -133,5 +153,5 @@ void SimpleMapModuleState::fireTransientStateChangeSignal()
133153
134154ModuleStateInterface* SimpleMapModuleStateFactory::make_state (const std::string& name) const
135155{
136- return new SimpleMapModuleState;
156+ return new SimpleMapModuleState (name) ;
137157}
0 commit comments