| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2015 Frederik Heber. All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | *
|
|---|
| 7 | * This file is part of MoleCuilder.
|
|---|
| 8 | *
|
|---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
|---|
| 10 | * it under the terms of the GNU General Public License as published by
|
|---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
|---|
| 12 | * (at your option) any later version.
|
|---|
| 13 | *
|
|---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | * GNU General Public License for more details.
|
|---|
| 18 | *
|
|---|
| 19 | * You should have received a copy of the GNU General Public License
|
|---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | * QtInstanceInformationBoard.cpp
|
|---|
| 25 | *
|
|---|
| 26 | * Created on: Oct 17, 2015
|
|---|
| 27 | * Author: heber
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | // include config.h
|
|---|
| 32 | #ifdef HAVE_CONFIG_H
|
|---|
| 33 | #include <config.h>
|
|---|
| 34 | #endif
|
|---|
| 35 |
|
|---|
| 36 | #include "QtInstanceInformationBoard.hpp"
|
|---|
| 37 |
|
|---|
| 38 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp"
|
|---|
| 39 | #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp"
|
|---|
| 40 |
|
|---|
| 41 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 42 |
|
|---|
| 43 | #include "CodePatterns/Log.hpp"
|
|---|
| 44 |
|
|---|
| 45 | #include "Atom/atom.hpp"
|
|---|
| 46 | #include "Descriptors/AtomIdDescriptor.hpp"
|
|---|
| 47 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
|---|
| 48 | #include "molecule.hpp"
|
|---|
| 49 | #include "World.hpp"
|
|---|
| 50 |
|
|---|
| 51 | QtInstanceInformationBoard::QtInstanceInformationBoard(QWidget * _parent) :
|
|---|
| 52 | QWidget(_parent),
|
|---|
| 53 | Observer("QtInstanceInformationBoard"),
|
|---|
| 54 | WorldSignedOn(false),
|
|---|
| 55 | atomSubjectKilled(
|
|---|
| 56 | boost::bind(&QtInstanceInformationBoard::atomcountsubjectKilled, this, _1)),
|
|---|
| 57 | moleculeSubjectKilled(
|
|---|
| 58 | boost::bind(&QtInstanceInformationBoard::moleculecountsubjectKilled, this, _1)),
|
|---|
| 59 | lastremovedatom((atomId_t)-1),
|
|---|
| 60 | lastremovedatomsmolecule( std::make_pair((moleculeId_t)-1,(atomId_t)-1) ),
|
|---|
| 61 | lastremovedmolecule((moleculeId_t)-1)
|
|---|
| 62 | {
|
|---|
| 63 | // be first (besides ObservedValues to know about new insertions)
|
|---|
| 64 | World::getInstance().signOn(this, World::AtomInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
|
|---|
| 65 | World::getInstance().signOn(this, World::AtomRemoved, GlobalObservableInfo::PriorityLevel(int(-10)));
|
|---|
| 66 | World::getInstance().signOn(this, World::MoleculeInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
|
|---|
| 67 | World::getInstance().signOn(this, World::MoleculeRemoved, GlobalObservableInfo::PriorityLevel(int(-10)));
|
|---|
| 68 | WorldSignedOn = true;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | QtInstanceInformationBoard::~QtInstanceInformationBoard()
|
|---|
| 72 | {
|
|---|
| 73 | if (WorldSignedOn) {
|
|---|
| 74 | World::getInstance().signOff(this, World::AtomInserted);
|
|---|
| 75 | World::getInstance().signOff(this, World::AtomRemoved);
|
|---|
| 76 | World::getInstance().signOff(this, World::MoleculeInserted);
|
|---|
| 77 | World::getInstance().signOff(this, World::MoleculeRemoved);
|
|---|
| 78 | }
|
|---|
| 79 | // sign off from all remaining molecules and atoms
|
|---|
| 80 | for (SignedOn_t::iterator iter = AtomSignedOn.begin(); !AtomSignedOn.empty();
|
|---|
| 81 | iter = AtomSignedOn.begin()) {
|
|---|
| 82 | (*iter)->signOff(this, atom::IndexChanged);
|
|---|
| 83 | AtomSignedOn.erase(iter);
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | for (SignedOn_t::iterator iter = MoleculeSignedOn.begin(); !MoleculeSignedOn.empty();
|
|---|
| 87 | iter = MoleculeSignedOn.begin()) {
|
|---|
| 88 | (*iter)->signOff(this, molecule::IndexChanged);
|
|---|
| 89 | (*iter)->signOff(this, molecule::AtomInserted);
|
|---|
| 90 | (*iter)->signOff(this, molecule::AtomRemoved);
|
|---|
| 91 | MoleculeSignedOn.erase(*iter); //erase all instances
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | void QtInstanceInformationBoard::update(Observable *publisher)
|
|---|
| 96 | {
|
|---|
| 97 | ASSERT(0,
|
|---|
| 98 | "QtInstanceInformationBoard::update() - we are not signed on to general updates.");
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | void QtInstanceInformationBoard::subjectKilled(Observable *publisher)
|
|---|
| 102 | {
|
|---|
| 103 | SignedOn_t::iterator iter = AtomSignedOn.find(publisher);
|
|---|
| 104 | if ( iter != AtomSignedOn.end()) {
|
|---|
| 105 | LOG(3, "DEBUG: InstanceBoard got subjectKilled() from atom " << publisher);
|
|---|
| 106 | AtomSignedOn.erase(iter);
|
|---|
| 107 | } else {
|
|---|
| 108 | iter = MoleculeSignedOn.find(publisher);
|
|---|
| 109 | if ( iter != MoleculeSignedOn.end()) {
|
|---|
| 110 | LOG(3, "DEBUG: InstanceBoard got subjectKilled() from molecule " << publisher);
|
|---|
| 111 | MoleculeSignedOn.erase(iter);
|
|---|
| 112 | } else {
|
|---|
| 113 | ASSERT(0,
|
|---|
| 114 | "QtObservedInstanceBoard::subjectKilled() - could not find signedOn for atom/molecule "+toString(publisher));
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | void QtInstanceInformationBoard::recieveNotification(Observable *publisher, Notification_ptr notification)
|
|---|
| 120 | {
|
|---|
| 121 | if (static_cast<World *>(publisher) == World::getPointer()) {
|
|---|
| 122 | switch (notification->getChannelNo()) {
|
|---|
| 123 | case World::MoleculeInserted:
|
|---|
| 124 | {
|
|---|
| 125 | const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
|---|
| 126 | #ifdef LOG_OBSERVER
|
|---|
| 127 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been inserted.";
|
|---|
| 128 | #endif
|
|---|
| 129 | LOG(3, "DEBUG: InformationBoard got moleculeInserted signal for molecule " << _id);
|
|---|
| 130 | const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
|
|---|
| 131 | getMolecule(MoleculeById(_id));
|
|---|
| 132 | if (_molecule != NULL) {
|
|---|
| 133 | ObservedValues_t ObservedValues(GLMoleculeObject_molecule::MAX_ObservedTypes);
|
|---|
| 134 | LOG(3, "DEBUG: InformationBoard initializes ObservedValues for molecule " << _id);
|
|---|
| 135 | GLMoleculeObject_molecule::initObservedValues(
|
|---|
| 136 | ObservedValues,
|
|---|
| 137 | _id,
|
|---|
| 138 | _molecule,
|
|---|
| 139 | moleculeSubjectKilled);
|
|---|
| 140 | #ifndef NDEBUG
|
|---|
| 141 | std::pair<moleculeObservedValues_t::iterator, bool> inserter =
|
|---|
| 142 | #endif
|
|---|
| 143 | moleculeObservedValues.insert(
|
|---|
| 144 | std::make_pair( _id, ObservedValues));
|
|---|
| 145 | ASSERT( inserter.second,
|
|---|
| 146 | "QtInstanceInformationBoard::recieveNotification() - could not insert ObservedValues for"
|
|---|
| 147 | +toString(_id)+".");
|
|---|
| 148 | // we need to check for index changes
|
|---|
| 149 | LOG(3, "DEBUG: InformationBoard signOn()s to molecule " << _id);
|
|---|
| 150 | _molecule->signOn(this, molecule::IndexChanged);
|
|---|
| 151 | MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
|
|---|
| 152 | _molecule->signOn(this, molecule::AtomInserted);
|
|---|
| 153 | MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
|
|---|
| 154 | _molecule->signOn(this, molecule::AtomRemoved);
|
|---|
| 155 | MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) );
|
|---|
| 156 |
|
|---|
| 157 | emit moleculeInserted(_id);
|
|---|
| 158 | } else {
|
|---|
| 159 | ELOG(1, "QtInstanceInformationBoard got MoleculeInserted for unknown molecule id " << _id);
|
|---|
| 160 | }
|
|---|
| 161 | break;
|
|---|
| 162 | }
|
|---|
| 163 | case World::MoleculeRemoved:
|
|---|
| 164 | {
|
|---|
| 165 | const moleculeId_t _id = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
|---|
| 166 | LOG(3, "DEBUG: InformationBoard got MoleculeRemoved signal for molecule " << _id);
|
|---|
| 167 | // note down such that ObservedValues are simply dropped
|
|---|
| 168 | lastremovedmolecule = _id;
|
|---|
| 169 | break;
|
|---|
| 170 | }
|
|---|
| 171 | case World::AtomInserted:
|
|---|
| 172 | {
|
|---|
| 173 | const atomId_t _id = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
|---|
| 174 | #ifdef LOG_OBSERVER
|
|---|
| 175 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
|---|
| 176 | #endif
|
|---|
| 177 | LOG(3, "DEBUG: InformationBoard got atomInserted signal for atom " << _id);
|
|---|
| 178 | const atom * const _atom = const_cast<const World &>(World::getInstance()).
|
|---|
| 179 | getAtom(AtomById(_id));
|
|---|
| 180 | if (_atom!= NULL) {
|
|---|
| 181 | ObservedValues_t ObservedValues(GLMoleculeObject_atom::MAX_ObservedTypes);
|
|---|
| 182 | LOG(3, "DEBUG: InformationBoard initializes ObservedValues for atom " << _id);
|
|---|
| 183 | GLMoleculeObject_atom::initObservedValues(
|
|---|
| 184 | ObservedValues,
|
|---|
| 185 | _id,
|
|---|
| 186 | _atom,
|
|---|
| 187 | atomSubjectKilled);
|
|---|
| 188 | #ifndef NDEBUG
|
|---|
| 189 | std::pair<atomObservedValues_t::iterator, bool> inserter =
|
|---|
| 190 | #endif
|
|---|
| 191 | atomObservedValues.insert(
|
|---|
| 192 | std::make_pair( _id, ObservedValues));
|
|---|
| 193 | ASSERT( inserter.second,
|
|---|
| 194 | "QtInstanceInformationBoard::recieveNotification() - could not insert ObservedValues for"
|
|---|
| 195 | +toString(_id)+".");
|
|---|
| 196 | // we need to check for index changes
|
|---|
| 197 | LOG(3, "DEBUG: InformationBoard signOn()s to atom " << _id);
|
|---|
| 198 | _atom->signOn(this, atom::IndexChanged);
|
|---|
| 199 | AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
|
|---|
| 200 | } else {
|
|---|
| 201 | ELOG(1, "QtInstanceInformationBoard got AtomInserted for unknown atom id " << _id);
|
|---|
| 202 | }
|
|---|
| 203 | break;
|
|---|
| 204 | }
|
|---|
| 205 | case World::AtomRemoved:
|
|---|
| 206 | {
|
|---|
| 207 | const atomId_t _id = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
|---|
| 208 | LOG(3, "DEBUG: InformationBoard got AtomRemoved signal for atom " << _id);
|
|---|
| 209 | // note down such that ObservedValues are simply dropped
|
|---|
| 210 | lastremovedatom = _id;
|
|---|
| 211 | break;
|
|---|
| 212 | }
|
|---|
| 213 | default:
|
|---|
| 214 | ASSERT(0, "QtInstanceInformationBoard::recieveNotification() - we cannot get here for World.");
|
|---|
| 215 | break;
|
|---|
| 216 | }
|
|---|
| 217 | } else if (dynamic_cast<molecule *>(publisher) != NULL) {
|
|---|
| 218 | const moleculeId_t molid = const_cast<const World &>(World::getInstance()).lastChangedMolId();
|
|---|
| 219 | switch (notification->getChannelNo()) {
|
|---|
| 220 | case molecule::AtomInserted:
|
|---|
| 221 | {
|
|---|
| 222 | const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
|
|---|
| 223 | getMolecule(MoleculeById(molid));
|
|---|
| 224 | if (_molecule != NULL) {
|
|---|
| 225 | const atomId_t atomid = const_cast<const molecule *>(_molecule)->lastChangedAtomId();
|
|---|
| 226 | LOG(3, "DEBUG: InformationBoard got AtomInserted signal for atom "
|
|---|
| 227 | << atomid << " from molecule " << molid);
|
|---|
| 228 | // check whether atom's observedvalues are present
|
|---|
| 229 | ASSERT( atomObservedValues.find(atomid) != atomObservedValues.end(),
|
|---|
| 230 | "QtInstanceInformationBoard::recieveNotification() - ObservedValues for atom "
|
|---|
| 231 | +toString(atomid)+" are not present yet.");
|
|---|
| 232 | // and emit
|
|---|
| 233 | emit atomInserted(molid, atomid);
|
|---|
| 234 | } else {
|
|---|
| 235 | ELOG(2, "QtInstanceInformationBoard::recieveNotification() - molecule "
|
|---|
| 236 | << molid << " has disappeared.");
|
|---|
| 237 | }
|
|---|
| 238 | break;
|
|---|
| 239 | }
|
|---|
| 240 | case molecule::AtomRemoved:
|
|---|
| 241 | {
|
|---|
| 242 | const molecule * const _molecule = const_cast<const World &>(World::getInstance()).
|
|---|
| 243 | getMolecule(MoleculeById(molid));
|
|---|
| 244 | if (_molecule != NULL) {
|
|---|
| 245 | const atomId_t atomid = const_cast<const molecule *>(_molecule)->lastChangedAtomId();
|
|---|
| 246 | LOG(3, "DEBUG: InformationBoard got AtomRemoved signal for atom "
|
|---|
| 247 | << atomid << " from molecule " << molid);
|
|---|
| 248 | lastremovedatomsmolecule = std::make_pair(molid, atomid);
|
|---|
| 249 | }
|
|---|
| 250 | break;
|
|---|
| 251 | }
|
|---|
| 252 | case molecule::IndexChanged:
|
|---|
| 253 | {
|
|---|
| 254 | // molecule has changed its index
|
|---|
| 255 | const moleculeId_t newmoleculeId = dynamic_cast<molecule *>(publisher)->getId();
|
|---|
| 256 | LOG(3, "DEBUG: InformationBoard got IndexChanged from molecule " << molid << " to " << newmoleculeId);
|
|---|
| 257 | {
|
|---|
| 258 | moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(molid);
|
|---|
| 259 | // change id here only if still present
|
|---|
| 260 | if (iter != moleculeObservedValues.end()) {
|
|---|
| 261 | ObservedValues_t obsvalues = iter->second;
|
|---|
| 262 | moleculeObservedValues.erase(iter);
|
|---|
| 263 | ASSERT( moleculeObservedValues.find(newmoleculeId) == moleculeObservedValues.end(),
|
|---|
| 264 | "QtInstanceInformationBoard::recieveNotification() - ObservedValues for atom "
|
|---|
| 265 | +toString(newmoleculeId)+" already present.");
|
|---|
| 266 | moleculeObservedValues.insert( std::make_pair(newmoleculeId, obsvalues) );
|
|---|
| 267 | // if (!inserter.second)
|
|---|
| 268 | // ELOG(1, "QtInformationBoard could not insert molecule id change "
|
|---|
| 269 | // << molid << "->" << newmoleculeId);
|
|---|
| 270 | }
|
|---|
| 271 | }
|
|---|
| 272 | // no need update SignedOn, ref does not change
|
|---|
| 273 | emit moleculeIndexChanged(molid, newmoleculeId);
|
|---|
| 274 | break;
|
|---|
| 275 | }
|
|---|
| 276 | default:
|
|---|
| 277 | ASSERT(0, "QtInstanceInformationBoard::recieveNotification() - we cannot get here.");
|
|---|
| 278 | break;
|
|---|
| 279 | }
|
|---|
| 280 | } else if (dynamic_cast<atom *>(publisher) != NULL) {
|
|---|
| 281 | const atomId_t oldatomId = const_cast<const World &>(World::getInstance()).lastChangedAtomId();
|
|---|
| 282 | switch (notification->getChannelNo()) {
|
|---|
| 283 | case AtomObservable::IndexChanged:
|
|---|
| 284 | {
|
|---|
| 285 | const atomId_t newatomId = dynamic_cast<atom *>(publisher)->getId();
|
|---|
| 286 | LOG(3, "DEBUG: InformationBoard got IndexChanged from atom " << oldatomId << " to " << newatomId);
|
|---|
| 287 | // update atomObservedValues
|
|---|
| 288 | {
|
|---|
| 289 | atomObservedValues_t::iterator iter = atomObservedValues.find(oldatomId);
|
|---|
| 290 | // change id here only if still present
|
|---|
| 291 | if (iter != atomObservedValues.end()) {
|
|---|
| 292 | ObservedValues_t obsvalues = iter->second;
|
|---|
| 293 | atomObservedValues.erase(iter);
|
|---|
| 294 | ASSERT( atomObservedValues.find(newatomId) == atomObservedValues.end(),
|
|---|
| 295 | "QtInstanceInformationBoard::recieveNotification() - ObservedValues for atom "
|
|---|
| 296 | +toString(newatomId)+" already present.");
|
|---|
| 297 | atomObservedValues.insert( std::make_pair(newatomId, obsvalues) );
|
|---|
| 298 | // if (!inserter.second)
|
|---|
| 299 | // ELOG(1, "QtInformationBoard could not insert atom id change "
|
|---|
| 300 | // << oldatomId << "->" << newatomId);
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 | // no need update SignedOn, ref does not change
|
|---|
| 304 | emit atomIndexChanged(oldatomId, newatomId);
|
|---|
| 305 | break;
|
|---|
| 306 | }
|
|---|
| 307 | default:
|
|---|
| 308 | ASSERT(0, "QtInstanceInformationBoard::recieveNotification() - we cannot get here.");
|
|---|
| 309 | break;
|
|---|
| 310 | }
|
|---|
| 311 | } else {
|
|---|
| 312 | ASSERT(0, "QtInstanceInformationBoard::recieveNotification() - notification from unknown source.");
|
|---|
| 313 | }
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | void QtInstanceInformationBoard::atomcountsubjectKilled(const atomId_t _atomid)
|
|---|
| 317 | {
|
|---|
| 318 | LOG(3, "DEBUG: InformationBoard got subjectKilled() for a value of atom " << _atomid);
|
|---|
| 319 | atomsubjectKilledCount_t::iterator iter = atomsubjectKilledCount.find(_atomid);
|
|---|
| 320 | if (iter == atomsubjectKilledCount.end()) {
|
|---|
| 321 | std::pair<atomsubjectKilledCount_t::iterator, bool> inserter =
|
|---|
| 322 | atomsubjectKilledCount.insert( std::make_pair(_atomid, 0) );
|
|---|
| 323 | iter = inserter.first;
|
|---|
| 324 | }
|
|---|
| 325 | ++(iter->second);
|
|---|
| 326 |
|
|---|
| 327 | if (iter->second > GLMoleculeObject_atom::MAX_ObservedTypes) {
|
|---|
| 328 | if (_atomid == lastremovedatomsmolecule.second)
|
|---|
| 329 | emit atomRemoved(lastremovedatomsmolecule.first, lastremovedatomsmolecule.second);
|
|---|
| 330 | else
|
|---|
| 331 | ELOG(2, "QtInstanceInformationBoard::atomcountsubjectKilled() - id " << _atomid
|
|---|
| 332 | << " not fitting with " << lastremovedatomsmolecule);
|
|---|
| 333 | atomsubjectKilledCount.erase(iter);
|
|---|
| 334 | }
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | void QtInstanceInformationBoard::moleculecountsubjectKilled(const moleculeId_t _molid)
|
|---|
| 338 | {
|
|---|
| 339 | LOG(3, "DEBUG: InformationBoard got subjectKilled() for a value of molecule " << _molid);
|
|---|
| 340 | moleculesubjectKilledCount_t::iterator iter = moleculesubjectKilledCount.find(_molid);
|
|---|
| 341 | if (iter == moleculesubjectKilledCount.end()) {
|
|---|
| 342 | std::pair<moleculesubjectKilledCount_t::iterator, bool> inserter =
|
|---|
| 343 | moleculesubjectKilledCount.insert( std::make_pair(_molid, 0) );
|
|---|
| 344 | iter = inserter.first;
|
|---|
| 345 | }
|
|---|
| 346 | ++(iter->second);
|
|---|
| 347 |
|
|---|
| 348 | if (iter->second > GLMoleculeObject_molecule::MAX_ObservedTypes) {
|
|---|
| 349 | // then free the instance
|
|---|
| 350 | emit moleculeRemoved(_molid);
|
|---|
| 351 | moleculesubjectKilledCount.erase(iter);
|
|---|
| 352 | }
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | QtInstanceInformationBoard::ObservedValues_t
|
|---|
| 356 | QtInstanceInformationBoard::getAtomObservedValues(const atomId_t _id)
|
|---|
| 357 | {
|
|---|
| 358 | ObservedValues_t returnvalues;
|
|---|
| 359 | const atomObservedValues_t::iterator iter = atomObservedValues.find(_id);
|
|---|
| 360 | ASSERT(iter != atomObservedValues.end(),
|
|---|
| 361 | "QtInstanceInformationBoard::getAtomObservedValues() - atom values not present for id"
|
|---|
| 362 | +toString(_id));
|
|---|
| 363 | if (iter->first == _id) {
|
|---|
| 364 | returnvalues = iter->second;
|
|---|
| 365 | atomObservedValues.erase(iter);
|
|---|
| 366 | }
|
|---|
| 367 | return returnvalues;
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | QtInstanceInformationBoard::ObservedValues_t
|
|---|
| 371 | QtInstanceInformationBoard::getMoleculeObservedValues(const moleculeId_t _id)
|
|---|
| 372 | {
|
|---|
| 373 | ObservedValues_t returnvalues;
|
|---|
| 374 | const moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(_id);
|
|---|
| 375 | ASSERT(iter != moleculeObservedValues.end(),
|
|---|
| 376 | "getMoleculeObservedValues::getAtomObservedValues() - molecule values not present for id"
|
|---|
| 377 | +toString(_id));
|
|---|
| 378 | if (iter->first == _id) {
|
|---|
| 379 | returnvalues = iter->second;
|
|---|
| 380 | moleculeObservedValues.erase(iter);
|
|---|
| 381 | }
|
|---|
| 382 | return returnvalues;
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | void QtInstanceInformationBoard::returnAtomObservedValues(
|
|---|
| 386 | const atomId_t _id,
|
|---|
| 387 | ObservedValues_t &_observedvalues)
|
|---|
| 388 | {
|
|---|
| 389 | if (lastremovedatom != _id) {
|
|---|
| 390 | #ifndef NDEBUG
|
|---|
| 391 | std::pair<atomObservedValues_t::iterator, bool> inserter =
|
|---|
| 392 | #endif
|
|---|
| 393 | atomObservedValues.insert(
|
|---|
| 394 | std::make_pair( _id, _observedvalues) );
|
|---|
| 395 | ASSERT( inserter.second,
|
|---|
| 396 | "QtInstanceInformationBoard::returnAtomObservedValues() - could not insert ObservedValues for"
|
|---|
| 397 | +toString(_id)+".");
|
|---|
| 398 | } else
|
|---|
| 399 | lastremovedatom = (atomId_t)-1;
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | void QtInstanceInformationBoard::returnMoleculeObservedValues(
|
|---|
| 403 | const moleculeId_t _id,
|
|---|
| 404 | ObservedValues_t &_observedvalues)
|
|---|
| 405 | {
|
|---|
| 406 | if (lastremovedmolecule != _id) {
|
|---|
| 407 | #ifndef NDEBUG
|
|---|
| 408 | std::pair<moleculeObservedValues_t::iterator, bool> inserter =
|
|---|
| 409 | #endif
|
|---|
| 410 | moleculeObservedValues.insert(
|
|---|
| 411 | std::make_pair( _id, _observedvalues) );
|
|---|
| 412 | ASSERT( inserter.second,
|
|---|
| 413 | "QtInstanceInformationBoard::returnMoleculeObservedValues() - could not insert ObservedValues for"
|
|---|
| 414 | +toString(_id)+".");
|
|---|
| 415 | } else
|
|---|
| 416 | lastremovedmolecule = (moleculeId_t)-1;
|
|---|
| 417 | }
|
|---|