/// Removes the molecule from the file and deletes it. Returns /// \c true if \p molecule is found and deleted successfully. bool MoleculeFile::deleteMolecule(Molecule *molecule) { bool found = removeMolecule(molecule); if(found){ delete molecule; } return found; }
void MoleculeURLListProperty::addMolecule(Molecule* handle, bool owner /*= false*/, bool selected /*= false*/) { tgtAssert(handle, "null pointer passed"); std::string url = handle->getOrigin().getURL(); if (!containsURL(url)) addURL(url, selected); else removeMolecule(handle); handleMap_[url] = handle; ownerMap_[url] = owner; invalidate(); }
void MoleculeURLListProperty::removeURL(const std::string& url) { if (!containsURL(url)) { LWARNING("removeURL(): passed URL not contained by this property: " << url); return; } // free corresponding molecule, if owned by the property Molecule* handle = getMolecule(url); if (handle) removeMolecule(handle); // remove url from url list std::vector<std::string>::iterator it = std::find(value_.begin(), value_.end(), url); tgtAssert(it != value_.end(), "url not found"); value_.erase(it); // remove url from maps handleMap_.erase(url); selectionMap_.erase(url); ownerMap_.erase(url); invalidate(); }