From 53880abb2017208026577fb1fecddb032f0fdd08 Mon Sep 17 00:00:00 2001 From: Christopher Woods Date: Wed, 11 Jan 2023 18:34:50 +0000 Subject: [PATCH] I found time and have added the `.find()` function to the molecular containers. This lets you easily get the index of atoms in systems etc., e.g. >>> idxs = mols.atoms().find(mols["element C"]) returns the indexes in `mols` for all of the carbon atoms. --- corelib/src/libs/SireMM/selectorbond.h | 221 +- corelib/src/libs/SireMM/selectormbond.h | 585 ++-- corelib/src/libs/SireMol/selector.hpp | 2977 ++++++++-------- corelib/src/libs/SireMol/selectorm.hpp | 4023 +++++++++++----------- corelib/src/libs/SireMol/selectormol.cpp | 319 +- corelib/src/libs/SireMol/selectormol.h | 551 +-- doc/source/conf.py | 2 +- doc/source/images/favicon.ico | Bin 4286 -> 0 bytes doc/source/images/favicon.png | Bin 0 -> 1478 bytes doc/source/images/logo.svg | 67 +- src/sire/mol/__init__.py | 59 +- src/sire/system/_system.py | 4 + tests/mol/test_find.py | 31 + wrapper/Mol/Atom.pypp.cpp | 2 + wrapper/Mol/Bead.pypp.cpp | 2 + wrapper/Mol/Chain.pypp.cpp | 2 + wrapper/Mol/CutGroup.pypp.cpp | 2 + wrapper/Mol/Residue.pypp.cpp | 2 + wrapper/Mol/Segment.pypp.cpp | 2 + wrapper/Mol/SelectorM_Atom_.pypp.cpp | 42 + wrapper/Mol/SelectorM_Chain_.pypp.cpp | 42 + wrapper/Mol/SelectorM_CutGroup_.pypp.cpp | 42 + wrapper/Mol/SelectorM_Residue_.pypp.cpp | 42 + wrapper/Mol/SelectorM_Segment_.pypp.cpp | 42 + wrapper/Mol/SelectorMol.pypp.cpp | 26 + wrapper/Mol/Selector_Atom_.pypp.cpp | 44 + wrapper/Mol/Selector_Chain_.pypp.cpp | 44 + wrapper/Mol/Selector_CutGroup_.pypp.cpp | 44 + wrapper/Mol/Selector_Residue_.pypp.cpp | 44 + wrapper/Mol/Selector_Segment_.pypp.cpp | 44 + wrapper/Mol/special_code.py | 13 + 31 files changed, 5119 insertions(+), 4201 deletions(-) delete mode 100644 doc/source/images/favicon.ico create mode 100644 doc/source/images/favicon.png create mode 100644 tests/mol/test_find.py diff --git a/corelib/src/libs/SireMM/selectorbond.h b/corelib/src/libs/SireMM/selectorbond.h index a72a71ac5..00c20df63 100644 --- a/corelib/src/libs/SireMM/selectorbond.h +++ b/corelib/src/libs/SireMM/selectorbond.h @@ -36,172 +36,171 @@ SIRE_BEGIN_HEADER namespace SireMM { -class SelectorBond; + class SelectorBond; } -SIREMM_EXPORT QDataStream& operator<<(QDataStream&, const SireMM::SelectorBond&); -SIREMM_EXPORT QDataStream& operator>>(QDataStream&, SireMM::SelectorBond&); +SIREMM_EXPORT QDataStream &operator<<(QDataStream &, const SireMM::SelectorBond &); +SIREMM_EXPORT QDataStream &operator>>(QDataStream &, SireMM::SelectorBond &); namespace SireMM { -/** This provides a Selector-style interface for multiple bonds */ -class SIREMM_EXPORT SelectorBond : - public SireBase::ConcreteProperty -{ + /** This provides a Selector-style interface for multiple bonds */ + class SIREMM_EXPORT SelectorBond : public SireBase::ConcreteProperty + { -friend QDataStream& ::operator<<(QDataStream&, const SelectorBond&); -friend QDataStream& ::operator>>(QDataStream&, SelectorBond&); + friend QDataStream & ::operator<<(QDataStream &, const SelectorBond &); + friend QDataStream & ::operator>>(QDataStream &, SelectorBond &); -public: - SelectorBond(); + public: + SelectorBond(); - SelectorBond(const Bond &bond); + SelectorBond(const Bond &bond); - SelectorBond(const SireMol::MoleculeData &molecule, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeData &molecule, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const MoleculeView &molecule, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const MoleculeView &molecule, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::MoleculeData &molecule, - const SireMol::AtomID &atom, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeData &molecule, + const SireMol::AtomID &atom, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::MoleculeData &molecule, - const SireMol::AtomID &atom0, const SireMol::AtomID &atom1, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeData &molecule, + const SireMol::AtomID &atom0, const SireMol::AtomID &atom1, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::MoleculeView &molecule, - const SireMol::AtomID &atom, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeView &molecule, + const SireMol::AtomID &atom, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::MoleculeView &molecule, - const SireMol::BondID &bond, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeView &molecule, + const SireMol::BondID &bond, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::MoleculeView &molecule, - const QList &bonds, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeView &molecule, + const QList &bonds, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::MoleculeView &molecule, - const SireMol::AtomID &atom0, const SireMol::AtomID &atom1, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::MoleculeView &molecule, + const SireMol::AtomID &atom0, const SireMol::AtomID &atom1, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::Selector &atoms, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SireMol::Selector &atoms0, - const SireMol::Selector &atoms1, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::Selector &atoms, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorBond(const SireMol::Selector &atoms0, + const SireMol::Selector &atoms1, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorBond(const SelectorBond &other); + SelectorBond(const SelectorBond &other); - virtual ~SelectorBond(); + virtual ~SelectorBond(); - static const char* typeName(); + static const char *typeName(); - virtual const char* what() const - { - return SelectorBond::typeName(); - } + virtual const char *what() const + { + return SelectorBond::typeName(); + } - virtual SelectorBond* clone() const - { - return new SelectorBond(*this); - } + virtual SelectorBond *clone() const + { + return new SelectorBond(*this); + } - SelectorBond& operator=(const SelectorBond &bond); + SelectorBond &operator=(const SelectorBond &bond); - bool operator==(const SelectorBond &other) const; - bool operator!=(const SelectorBond &other) const; + bool operator==(const SelectorBond &other) const; + bool operator!=(const SelectorBond &other) const; - QString toString() const; + QString toString() const; - SireMol::MolViewPtr operator[](int i) const; - SireMol::MolViewPtr operator[](const SireBase::Slice &slice) const; - SireMol::MolViewPtr operator[](const QList &idxs) const; - SireMol::MolViewPtr operator[](const SireMol::BondID &bond) const; + SireMol::MolViewPtr operator[](int i) const; + SireMol::MolViewPtr operator[](const SireBase::Slice &slice) const; + SireMol::MolViewPtr operator[](const QList &idxs) const; + SireMol::MolViewPtr operator[](const SireMol::BondID &bond) const; - Bond operator()(int i) const; - SelectorBond operator()(int i, int j) const; - SelectorBond operator()(const SireBase::Slice &slice) const; - SelectorBond operator()(const QList &idxs) const; - SelectorBond operator()(const SireMol::BondID &bond) const; + Bond operator()(int i) const; + SelectorBond operator()(int i, int j) const; + SelectorBond operator()(const SireBase::Slice &slice) const; + SelectorBond operator()(const QList &idxs) const; + SelectorBond operator()(const SireMol::BondID &bond) const; - QList toList() const; + QList toList() const; - bool isSelector() const; + bool isSelector() const; - QList IDs() const; + QList IDs() const; - SelectorBond add(const Bond &bond) const; + SelectorBond add(const Bond &bond) const; - int count() const; - int size() const; - int nViews() const; + int count() const; + int size() const; + int nViews() const; - bool isEmpty() const; - bool selectedAll() const; + bool isEmpty() const; + bool selectedAll() const; - SireMol::MolViewPtr toSelector() const; + SireMol::MolViewPtr toSelector() const; - SireMol::AtomSelection selection() const; + SireMol::AtomSelection selection() const; - SelectorBond add(const SelectorBond &other) const; + SelectorBond add(const SelectorBond &other) const; - SelectorBond intersection(const SelectorBond &other) const; + SelectorBond intersection(const SelectorBond &other) const; - SelectorBond invert(const SireBase::PropertyMap &map) const; - SelectorBond invert() const; + SelectorBond invert(const SireBase::PropertyMap &map) const; + SelectorBond invert() const; - bool hasProperty(const SireBase::PropertyName &key) const; - bool hasMetadata(const SireBase::PropertyName &key) const; - bool hasMetadata(const SireBase::PropertyName &key, - const SireBase::PropertyName &metakey) const; + bool hasProperty(const SireBase::PropertyName &key) const; + bool hasMetadata(const SireBase::PropertyName &key) const; + bool hasMetadata(const SireBase::PropertyName &key, + const SireBase::PropertyName &metakey) const; - QStringList propertyKeys() const; - QStringList metadataKeys() const; - QStringList metadataKeys(const SireBase::PropertyName &key) const; + QStringList propertyKeys() const; + QStringList metadataKeys() const; + QStringList metadataKeys(const SireBase::PropertyName &key) const; - QList properties() const; + QList properties() const; - SireMol::Mover move() const; - SireMol::Evaluator evaluate() const; + SireMol::Mover move() const; + SireMol::Evaluator evaluate() const; - QList property(const SireBase::PropertyName &key) const; - QList property(const SireBase::PropertyName &key, - const Property &default_value) const; + QList property(const SireBase::PropertyName &key) const; + QList property(const SireBase::PropertyName &key, + const Property &default_value) const; - QList lengths() const; - QList lengths(const SireBase::PropertyMap &map) const; + QList lengths() const; + QList lengths(const SireBase::PropertyMap &map) const; - QList measures() const; - QList measures(const SireBase::PropertyMap &map) const; + QList measures() const; + QList measures(const SireBase::PropertyMap &map) const; - QList potentials() const; - QList potentials(const SireBase::PropertyMap &map) const; + QList potentials() const; + QList potentials(const SireBase::PropertyMap &map) const; - QList energies() const; - QList energies( - const SireBase::PropertyMap &map) const; + QList energies() const; + QList energies( + const SireBase::PropertyMap &map) const; - SireUnits::Dimension::GeneralUnit energy() const; - SireUnits::Dimension::GeneralUnit energy( - const SireBase::PropertyMap &map) const; + SireUnits::Dimension::GeneralUnit energy() const; + SireUnits::Dimension::GeneralUnit energy( + const SireBase::PropertyMap &map) const; -protected: - /** The IDs of the bond (holding AtomIdx IDs) */ - QList bnds; -}; + protected: + /** The IDs of the bond (holding AtomIdx IDs) */ + QList bnds; + }; } // end of namespace SireMM -Q_DECLARE_METATYPE( SireMM::SelectorBond ) -Q_DECLARE_METATYPE( SireMol::Mover ) +Q_DECLARE_METATYPE(SireMM::SelectorBond) +Q_DECLARE_METATYPE(SireMol::Mover) -SIRE_EXPOSE_CLASS( SireMM::SelectorBond ) +SIRE_EXPOSE_CLASS(SireMM::SelectorBond) -SIRE_EXPOSE_ALIAS( SireMol::Mover, SireMol::Mover_SelectorBond_ ) +SIRE_EXPOSE_ALIAS(SireMol::Mover, SireMol::Mover_SelectorBond_) #ifdef SIRE_INSTANTIATE_TEMPLATES diff --git a/corelib/src/libs/SireMM/selectormbond.h b/corelib/src/libs/SireMM/selectormbond.h index 316b26980..2e278bdb6 100644 --- a/corelib/src/libs/SireMM/selectormbond.h +++ b/corelib/src/libs/SireMM/selectormbond.h @@ -33,321 +33,320 @@ #include "selectorbond.h" - SIRE_BEGIN_HEADER namespace SireMol { -class Atom; -class Residue; -class Chain; -class Segment; -class CutGroup; -class Molecule; -class MoleculeGroup; -class Molecules; -class SelectResult; - -class SelectorMol; -class EvaluatorM; + class Atom; + class Residue; + class Chain; + class Segment; + class CutGroup; + class Molecule; + class MoleculeGroup; + class Molecules; + class SelectResult; + + class SelectorMol; + class EvaluatorM; } namespace SireMM { -class SelectorMBond; + class SelectorMBond; } -SIREMM_EXPORT QDataStream& operator<<(QDataStream&, const SireMM::SelectorMBond&); -SIREMM_EXPORT QDataStream& operator>>(QDataStream&, SireMM::SelectorMBond&); +SIREMM_EXPORT QDataStream &operator<<(QDataStream &, const SireMM::SelectorMBond &); +SIREMM_EXPORT QDataStream &operator>>(QDataStream &, SireMM::SelectorMBond &); namespace SireMM { -/** Multi-molecule selector for bonds */ -class SIREMM_EXPORT SelectorMBond - : public SireBase::ConcreteProperty -{ + /** Multi-molecule selector for bonds */ + class SIREMM_EXPORT SelectorMBond + : public SireBase::ConcreteProperty + { -friend QDataStream& ::operator<<(QDataStream&, const SelectorMBond&); -friend QDataStream& ::operator>>(QDataStream&, SelectorMBond&); + friend QDataStream & ::operator<<(QDataStream &, const SelectorMBond &); + friend QDataStream & ::operator>>(QDataStream &, SelectorMBond &); -public: - typedef QList::const_iterator const_iterator; - typedef QList::const_iterator iterator; + public: + typedef QList::const_iterator const_iterator; + typedef QList::const_iterator iterator; - SelectorMBond(); - SelectorMBond(const Bond &view); + SelectorMBond(); + SelectorMBond(const Bond &view); - SelectorMBond(const SireMol::Molecules &mols, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SireMol::MoleculeGroup &mols, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SireMol::MolGroupsBase &mols, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SireMol::SelectResult &mols, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::Molecules &mols, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::MoleculeGroup &mols, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::MolGroupsBase &mols, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::SelectResult &mols, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SelectorBond &bonds); + SelectorMBond(const SelectorBond &bonds); - SelectorMBond(const SireMol::SelectorMol &mols, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::SelectorMol &mols, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - template - SelectorMBond(const SireMol::SelectorM &other, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + template + SelectorMBond(const SireMol::SelectorM &other, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SelectorMBond &bonds, const SireBase::Slice &slice); - SelectorMBond(const SelectorMBond &bonds, const QList &idxs); + SelectorMBond(const SelectorMBond &bonds, const SireBase::Slice &slice); + SelectorMBond(const SelectorMBond &bonds, const QList &idxs); - SelectorMBond(const SireMol::SelectResult &mols, - const SireMol::BondID &bond, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::SelectResult &mols, + const SireMol::BondID &bond, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SireMol::SelectorM &atoms, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::SelectorM &atoms, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SireMol::SelectorM &atoms0, - const SireMol::SelectorM &atoms1, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorMBond(const SireMol::SelectorM &atoms0, + const SireMol::SelectorM &atoms1, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorMBond(const SelectorMBond &other); + SelectorMBond(const SelectorMBond &other); - virtual ~SelectorMBond(); + virtual ~SelectorMBond(); - static const char* typeName(); + static const char *typeName(); - virtual SelectorMBond* clone() const - { - return new SelectorMBond(*this); - } + virtual SelectorMBond *clone() const + { + return new SelectorMBond(*this); + } - SelectorMBond& operator=(const SelectorMBond &other); - - bool operator==(const SelectorMBond &other) const; - bool operator!=(const SelectorMBond &other) const; - - Bond operator[](int i) const; - SelectorMBond operator[](const SireBase::Slice &slice) const; - SelectorMBond operator[](const QList &idxs) const; - SelectorMBond operator[](const SireMol::BondID &id) const; - - Bond operator()(int i) const; - SelectorMBond operator()(const SireBase::Slice &slice) const; - SelectorMBond operator()(const QList &idxs) const; - SelectorMBond operator()(const SireMol::BondID &id) const; - - QList toList() const; - SireMol::Molecules toMolecules() const; - - int count() const; - int size() const; - - void update(const SireMol::Molecules &molecules); - - SireMol::EvaluatorM evaluate() const; - - bool isSelector() const; - - SireMol::MoleculeGroup toMoleculeGroup() const; - SireMol::SelectResult toSelectResult() const; - - SireMol::Molecule molecule(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Molecule molecule(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Molecule molecule(const SireMol::MolID &molid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()); - - SireMol::SelectorMol molecules() const; - SireMol::SelectorMol molecules(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorMol molecules(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorMol molecules(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorMol molecules(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorMol molecules(const SireMol::MolID &molid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::Atom atom(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Atom atom(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Atom atom(const SireMol::AtomID &atomid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::Residue residue(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Residue residue(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Residue residue(const SireMol::ResID &resid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::Chain chain(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Chain chain(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Chain chain(const SireMol::ChainID &chainid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::Segment segment(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Segment segment(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::Segment segment(const SireMol::SegID &segid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::CutGroup cutGroup(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::CutGroup cutGroup(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::CutGroup cutGroup(const SireMol::CGID &cgid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::SelectorM atoms() const; - SireMol::SelectorM atoms(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM atoms(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM atoms(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM atoms(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM atoms(const SireMol::AtomID &atomid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::SelectorM residues() const; - SireMol::SelectorM residues(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM residues(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM residues(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM residues(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM residues(const SireMol::ResID &resid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::SelectorM chains() const; - SireMol::SelectorM chains(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM chains(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM chains(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM chains(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM chains(const SireMol::ChainID &chainid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::SelectorM segments() const; - SireMol::SelectorM segments(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM segments(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM segments(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM segments(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM segments(const SireMol::SegID &segid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SireMol::SelectorM cutGroups() const; - SireMol::SelectorM cutGroups(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM cutGroups(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM cutGroups(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM cutGroups(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SireMol::SelectorM cutGroups(const SireMol::CGID &cgid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorMBond add(const SelectorMBond &other) const; - - SelectorMBond intersection(const SelectorMBond &other) const; - - SelectorMBond invert(const SireBase::PropertyMap &map) const; - SelectorMBond invert() const; - - bool hasProperty(const SireBase::PropertyName &key) const; - bool hasMetadata(const SireBase::PropertyName &key) const; - bool hasMetadata(const SireBase::PropertyName &key, - const SireBase::PropertyName &metakey) const; - - QStringList propertyKeys() const; - QStringList metadataKeys() const; - QStringList metadataKeys(const SireBase::PropertyName &key) const; - - QList properties() const; - - QList property(const SireBase::PropertyName &key) const; - QList property(const SireBase::PropertyName &key, - const Property &default_value) const; - - QList lengths() const; - QList lengths(const SireBase::PropertyMap &map) const; - - QList measures() const; - QList measures(const SireBase::PropertyMap &map) const; - - QList potentials() const; - QList potentials(const SireBase::PropertyMap &map) const; - - QList energies() const; - QList energies( - const SireBase::PropertyMap &map) const; - - SireUnits::Dimension::GeneralUnit energy() const; - SireUnits::Dimension::GeneralUnit energy( - const SireBase::PropertyMap &map) const; - - SireMol::SelectResult search(const QString &search_string) const; - SireMol::SelectResult search(const QString &search_string, - const SireBase::PropertyMap &map) const; - - QList IDs() const; - - int nAtoms() const; - int nResidues() const; - int nChains() const; - int nSegments() const; - int nCutGroups() const; - int nMolecules() const; - - bool isEmpty() const; - - int nFrames() const; - int nFrames(const SireBase::PropertyMap &map) const; - - void loadFrame(int frame); - void saveFrame(int frame); - void saveFrame(); - void deleteFrame(int frame); - - void loadFrame(int frame, const SireBase::PropertyMap &map); - void saveFrame(int frame, const SireBase::PropertyMap &map); - void saveFrame(const SireBase::PropertyMap &map); - void deleteFrame(int frame, const SireBase::PropertyMap &map); - - const_iterator begin() const; - const_iterator end() const; - - const_iterator constBegin() const; - const_iterator constEnd() const; + SelectorMBond &operator=(const SelectorMBond &other); + + bool operator==(const SelectorMBond &other) const; + bool operator!=(const SelectorMBond &other) const; + + Bond operator[](int i) const; + SelectorMBond operator[](const SireBase::Slice &slice) const; + SelectorMBond operator[](const QList &idxs) const; + SelectorMBond operator[](const SireMol::BondID &id) const; + + Bond operator()(int i) const; + SelectorMBond operator()(const SireBase::Slice &slice) const; + SelectorMBond operator()(const QList &idxs) const; + SelectorMBond operator()(const SireMol::BondID &id) const; + + QList toList() const; + SireMol::Molecules toMolecules() const; + + int count() const; + int size() const; + + void update(const SireMol::Molecules &molecules); + + SireMol::EvaluatorM evaluate() const; + + bool isSelector() const; + + SireMol::MoleculeGroup toMoleculeGroup() const; + SireMol::SelectResult toSelectResult() const; + + SireMol::Molecule molecule(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Molecule molecule(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Molecule molecule(const SireMol::MolID &molid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + + SireMol::SelectorMol molecules() const; + SireMol::SelectorMol molecules(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorMol molecules(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorMol molecules(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorMol molecules(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorMol molecules(const SireMol::MolID &molid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::Atom atom(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Atom atom(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Atom atom(const SireMol::AtomID &atomid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::Residue residue(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Residue residue(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Residue residue(const SireMol::ResID &resid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::Chain chain(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Chain chain(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Chain chain(const SireMol::ChainID &chainid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::Segment segment(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Segment segment(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::Segment segment(const SireMol::SegID &segid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::CutGroup cutGroup(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::CutGroup cutGroup(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::CutGroup cutGroup(const SireMol::CGID &cgid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::SelectorM atoms() const; + SireMol::SelectorM atoms(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM atoms(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM atoms(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM atoms(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM atoms(const SireMol::AtomID &atomid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::SelectorM residues() const; + SireMol::SelectorM residues(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM residues(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM residues(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM residues(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM residues(const SireMol::ResID &resid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::SelectorM chains() const; + SireMol::SelectorM chains(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM chains(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM chains(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM chains(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM chains(const SireMol::ChainID &chainid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::SelectorM segments() const; + SireMol::SelectorM segments(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM segments(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM segments(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM segments(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM segments(const SireMol::SegID &segid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SireMol::SelectorM cutGroups() const; + SireMol::SelectorM cutGroups(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM cutGroups(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM cutGroups(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM cutGroups(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SireMol::SelectorM cutGroups(const SireMol::CGID &cgid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorMBond add(const SelectorMBond &other) const; + + SelectorMBond intersection(const SelectorMBond &other) const; + + SelectorMBond invert(const SireBase::PropertyMap &map) const; + SelectorMBond invert() const; + + bool hasProperty(const SireBase::PropertyName &key) const; + bool hasMetadata(const SireBase::PropertyName &key) const; + bool hasMetadata(const SireBase::PropertyName &key, + const SireBase::PropertyName &metakey) const; + + QStringList propertyKeys() const; + QStringList metadataKeys() const; + QStringList metadataKeys(const SireBase::PropertyName &key) const; + + QList properties() const; + + QList property(const SireBase::PropertyName &key) const; + QList property(const SireBase::PropertyName &key, + const Property &default_value) const; + + QList lengths() const; + QList lengths(const SireBase::PropertyMap &map) const; + + QList measures() const; + QList measures(const SireBase::PropertyMap &map) const; + + QList potentials() const; + QList potentials(const SireBase::PropertyMap &map) const; + + QList energies() const; + QList energies( + const SireBase::PropertyMap &map) const; + + SireUnits::Dimension::GeneralUnit energy() const; + SireUnits::Dimension::GeneralUnit energy( + const SireBase::PropertyMap &map) const; + + SireMol::SelectResult search(const QString &search_string) const; + SireMol::SelectResult search(const QString &search_string, + const SireBase::PropertyMap &map) const; + + QList IDs() const; + + int nAtoms() const; + int nResidues() const; + int nChains() const; + int nSegments() const; + int nCutGroups() const; + int nMolecules() const; + + bool isEmpty() const; + + int nFrames() const; + int nFrames(const SireBase::PropertyMap &map) const; + + void loadFrame(int frame); + void saveFrame(int frame); + void saveFrame(); + void deleteFrame(int frame); + + void loadFrame(int frame, const SireBase::PropertyMap &map); + void saveFrame(int frame, const SireBase::PropertyMap &map); + void saveFrame(const SireBase::PropertyMap &map); + void deleteFrame(int frame, const SireBase::PropertyMap &map); + + const_iterator begin() const; + const_iterator end() const; + + const_iterator constBegin() const; + const_iterator constEnd() const; - virtual QString toString() const; + virtual QString toString() const; -protected: - void _append(const Bond &bond); - void _append(const SelectorBond &bonds); + protected: + void _append(const Bond &bond); + void _append(const SelectorBond &bonds); - /** The actual bonds */ - QList< SelectorBond > bnds; -}; + /** The actual bonds */ + QList bnds; + }; } // end of namespace SireMM @@ -363,22 +362,22 @@ friend QDataStream& ::operator>>(QDataStream&, SelectorMBond&); namespace SireMM { -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMBond::SelectorMBond(const SireMol::SelectorM &other, - const SireBase::PropertyMap &map) - : SireBase::ConcreteProperty() -{ - if (not other.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMBond::SelectorMBond(const SireMol::SelectorM &other, + const SireBase::PropertyMap &map) + : SireBase::ConcreteProperty() { - this->bnds.reserve(other.nMolecules()); - - for (int i=0; ibnds.append(SelectorBond(other.molecule(i), map)); + this->bnds.reserve(other.nMolecules()); + + for (int i = 0; i < other.nMolecules(); ++i) + { + this->bnds.append(SelectorBond(other.molecule(i), map)); + } } } -} } // end of namespace SireMol diff --git a/corelib/src/libs/SireMol/selector.hpp b/corelib/src/libs/SireMol/selector.hpp index df3c57ff3..9c5afb257 100644 --- a/corelib/src/libs/SireMol/selector.hpp +++ b/corelib/src/libs/SireMol/selector.hpp @@ -53,1806 +53,1948 @@ SIRE_BEGIN_HEADER namespace SireMol { -template -class Selector; + template + class Selector; + + template + class SelectorM; } -template -SIREMOL_EXPORT QDataStream& operator<<(QDataStream&, const SireMol::Selector&); +template +SIREMOL_EXPORT QDataStream &operator<<(QDataStream &, const SireMol::Selector &); -template -SIREMOL_EXPORT QDataStream& operator>>(QDataStream&, SireMol::Selector&); +template +SIREMOL_EXPORT QDataStream &operator>>(QDataStream &, SireMol::Selector &); namespace SireMol { -class MoleculeData; - -namespace detail -{ + class MoleculeData; -SIREMOL_EXPORT bool has_property(const Atom*, const MoleculeData &moldata, - const PropertyName &key); -SIREMOL_EXPORT bool has_property(const Chain*, const MoleculeData &moldata, - const PropertyName &key); -SIREMOL_EXPORT bool has_property(const CutGroup*, const MoleculeData &moldata, - const PropertyName &key); -SIREMOL_EXPORT bool has_property(const Residue*, const MoleculeData &moldata, - const PropertyName &key); -SIREMOL_EXPORT bool has_property(const Segment*, const MoleculeData &moldata, - const PropertyName &key); - -SIREMOL_EXPORT bool has_metadata(const Atom*, const MoleculeData &moldata, - const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const Chain*, const MoleculeData &moldata, - const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const CutGroup*, const MoleculeData &moldata, - const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const Residue*, const MoleculeData &moldata, - const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const Segment*, const MoleculeData &moldata, - const PropertyName &metakey); - -SIREMOL_EXPORT bool has_metadata(const Atom*, const MoleculeData &moldata, - const PropertyName &key, const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const Chain*, const MoleculeData &moldata, - const PropertyName &key, const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const CutGroup*, const MoleculeData &moldata, - const PropertyName &key, const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const Residue*, const MoleculeData &moldata, - const PropertyName &key, const PropertyName &metakey); -SIREMOL_EXPORT bool has_metadata(const Segment*, const MoleculeData &moldata, - const PropertyName &key, const PropertyName &metakey); - -} // end of namespace detail - -/** This template class provides a way to manipulate the selection - of parts of a a molecule, e.g. Selector provides a - MoleculeView that has a user-configurable view of an - arbitrary set of atoms. This class is used by the code - whenever multiple groups from within the same molecule - are returned, e.g. when returning all residues that - have a particular name - - @author Christopher Woods -*/ -template -class SIREMOL_EXPORT Selector : public SireBase::ConcreteProperty,MoleculeView> -{ + namespace detail + { -friend SIREMOL_EXPORT QDataStream& ::operator<<<>(QDataStream&, const Selector&); -friend SIREMOL_EXPORT QDataStream& ::operator>><>(QDataStream&, Selector&); + SIREMOL_EXPORT bool has_property(const Atom *, const MoleculeData &moldata, + const PropertyName &key); + SIREMOL_EXPORT bool has_property(const Chain *, const MoleculeData &moldata, + const PropertyName &key); + SIREMOL_EXPORT bool has_property(const CutGroup *, const MoleculeData &moldata, + const PropertyName &key); + SIREMOL_EXPORT bool has_property(const Residue *, const MoleculeData &moldata, + const PropertyName &key); + SIREMOL_EXPORT bool has_property(const Segment *, const MoleculeData &moldata, + const PropertyName &key); + + SIREMOL_EXPORT bool has_metadata(const Atom *, const MoleculeData &moldata, + const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const Chain *, const MoleculeData &moldata, + const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const CutGroup *, const MoleculeData &moldata, + const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const Residue *, const MoleculeData &moldata, + const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const Segment *, const MoleculeData &moldata, + const PropertyName &metakey); + + SIREMOL_EXPORT bool has_metadata(const Atom *, const MoleculeData &moldata, + const PropertyName &key, const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const Chain *, const MoleculeData &moldata, + const PropertyName &key, const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const CutGroup *, const MoleculeData &moldata, + const PropertyName &key, const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const Residue *, const MoleculeData &moldata, + const PropertyName &key, const PropertyName &metakey); + SIREMOL_EXPORT bool has_metadata(const Segment *, const MoleculeData &moldata, + const PropertyName &key, const PropertyName &metakey); + + } // end of namespace detail + + /** This template class provides a way to manipulate the selection + of parts of a a molecule, e.g. Selector provides a + MoleculeView that has a user-configurable view of an + arbitrary set of atoms. This class is used by the code + whenever multiple groups from within the same molecule + are returned, e.g. when returning all residues that + have a particular name + + @author Christopher Woods + */ + template + class SIREMOL_EXPORT Selector : public SireBase::ConcreteProperty, MoleculeView> + { -public: - Selector(); + friend SIREMOL_EXPORT QDataStream & ::operator<< <>(QDataStream &, const Selector &); + friend SIREMOL_EXPORT QDataStream & ::operator>><>(QDataStream &, Selector &); - Selector(const T &view); + public: + Selector(); - Selector(const MoleculeData &moldata); + Selector(const T &view); - Selector(const MoleculeData &moldata, - const AtomSelection &selected_atoms); + Selector(const MoleculeData &moldata); - Selector(const MoleculeData &moldata, const typename T::ID &viewid); + Selector(const MoleculeData &moldata, + const AtomSelection &selected_atoms); - Selector(const MoleculeData &moldata, const QList &idxs); + Selector(const MoleculeData &moldata, const typename T::ID &viewid); - Selector(const Selector &other); + Selector(const MoleculeData &moldata, const QList &idxs); - ~Selector(); + Selector(const Selector &other); - Selector& operator=(const Selector &other); - Selector& operator=(const T &view); + ~Selector(); - static const char* typeName(); + Selector &operator=(const Selector &other); + Selector &operator=(const T &view); - Selector* clone() const; + static const char *typeName(); - QList IDs() const; - QList indexes() const; - QList names() const; - QList numbers() const; + Selector *clone() const; - bool operator==(const Selector &other) const; - bool operator!=(const Selector &other) const; + QList IDs() const; + QList indexes() const; + QList names() const; + QList numbers() const; - Selector operator+(const Selector &other) const; - Selector operator-(const Selector &other) const; + bool operator==(const Selector &other) const; + bool operator!=(const Selector &other) const; - Selector operator+(const typename T::ID &id) const; - Selector operator-(const typename T::ID &id) const; + Selector operator+(const Selector &other) const; + Selector operator-(const Selector &other) const; - Selector operator+(const T &view) const; - Selector operator-(const T &view) const; + Selector operator+(const typename T::ID &id) const; + Selector operator-(const typename T::ID &id) const; - int nViews() const; + Selector operator+(const T &view) const; + Selector operator-(const T &view) const; - MolViewPtr operator[](int i) const; - MolViewPtr operator[](const QString &name) const; - MolViewPtr operator[](const SireBase::Slice &slice) const; - MolViewPtr operator[](const QList &idxs) const; - MolViewPtr operator[](const AtomID &atomid) const; - MolViewPtr operator[](const ResID &resid) const; - MolViewPtr operator[](const CGID &cgid) const; - MolViewPtr operator[](const ChainID &chainid) const; - MolViewPtr operator[](const SegID &segid) const; - MolViewPtr operator[](const SireID::Index &idx) const; + int nViews() const; - T operator()(int i) const; - T operator()(const SireID::Index &idx) const; - Selector operator()(int i, int j) const; - Selector operator()(const SireBase::Slice &slice) const; - Selector operator()(const QList &idxs) const; - Selector operator()(const AtomID &atomid) const; - Selector operator()(const ResID &resid) const; - Selector operator()(const CGID &cgid) const; - Selector operator()(const ChainID &chainid) const; - Selector operator()(const SegID &segid) const; + MolViewPtr operator[](int i) const; + MolViewPtr operator[](const QString &name) const; + MolViewPtr operator[](const SireBase::Slice &slice) const; + MolViewPtr operator[](const QList &idxs) const; + MolViewPtr operator[](const AtomID &atomid) const; + MolViewPtr operator[](const ResID &resid) const; + MolViewPtr operator[](const CGID &cgid) const; + MolViewPtr operator[](const ChainID &chainid) const; + MolViewPtr operator[](const SegID &segid) const; + MolViewPtr operator[](const SireID::Index &idx) const; - typename T::Index index(int i) const; + T operator()(int i) const; + T operator()(const SireID::Index &idx) const; + Selector operator()(int i, int j) const; + Selector operator()(const SireBase::Slice &slice) const; + Selector operator()(const QList &idxs) const; + Selector operator()(const AtomID &atomid) const; + Selector operator()(const ResID &resid) const; + Selector operator()(const CGID &cgid) const; + Selector operator()(const ChainID &chainid) const; + Selector operator()(const SegID &segid) const; - MolViewPtr toSelector() const; - QList toList() const; + typename T::Index index(int i) const; - Molecules toMolecules() const; + MolViewPtr toSelector() const; + QList toList() const; - QString toString() const; + Molecules toMolecules() const; - bool isEmpty() const; - bool selectedAll() const; + QString toString() const; - bool isSelector() const; + bool isEmpty() const; + bool selectedAll() const; - Selector add(const Selector &other) const; - Selector add(const T &view) const; - Selector add(const typename T::ID &id) const; + bool isSelector() const; - Selector subtract(const Selector &other) const; - Selector subtract(const T &view) const; - Selector subtract(const typename T::ID &id) const; + Selector add(const Selector &other) const; + Selector add(const T &view) const; + Selector add(const typename T::ID &id) const; - Selector intersection(const Selector &other) const; - Selector intersection(const T &view) const; - Selector intersection(const typename T::ID &id) const; + Selector subtract(const Selector &other) const; + Selector subtract(const T &view) const; + Selector subtract(const typename T::ID &id) const; - Selector invert() const; + Selector intersection(const Selector &other) const; + Selector intersection(const T &view) const; + Selector intersection(const typename T::ID &id) const; - bool intersects(const Selector &other) const; - bool intersects(const T &view) const; - bool intersects(const typename T::ID &id) const; + Selector invert() const; - bool contains(const Selector &other) const; - bool contains(const T &view) const; - bool contains(const typename T::ID &id) const; + QList find(const T &view) const; + QList find(const Selector &views) const; + QList find(const SelectorM &views) const; - AtomSelection selection() const; - AtomSelection selection(int i) const; - AtomSelection selection(int i, int j) const; + bool intersects(const Selector &other) const; + bool intersects(const T &view) const; + bool intersects(const typename T::ID &id) const; - Mover< Selector > move() const; - Mover< Selector > move(int i) const; - Mover< Selector > move(int i, int j) const; + bool contains(const Selector &other) const; + bool contains(const T &view) const; + bool contains(const typename T::ID &id) const; - Evaluator evaluate() const; - Evaluator evaluate(int i) const; - Evaluator evaluate(int i, int j) const; + AtomSelection selection() const; + AtomSelection selection(int i) const; + AtomSelection selection(int i, int j) const; - Selector selector() const; - Selector selector(int i) const; - Selector selector(int i, int j) const; + Mover> move() const; + Mover> move(int i) const; + Mover> move(int i, int j) const; - bool hasProperty(const PropertyName &key) const; - bool hasMetadata(const PropertyName &metakey) const; - bool hasMetadata(const PropertyName &key, - const PropertyName &metakey) const; + Evaluator evaluate() const; + Evaluator evaluate(int i) const; + Evaluator evaluate(int i, int j) const; - QStringList propertyKeys() const; - QStringList metadataKeys() const; - QStringList metadataKeys(const PropertyName &key) const; + Selector selector() const; + Selector selector(int i) const; + Selector selector(int i, int j) const; - template - QList property(const PropertyName &key) const; + bool hasProperty(const PropertyName &key) const; + bool hasMetadata(const PropertyName &metakey) const; + bool hasMetadata(const PropertyName &key, + const PropertyName &metakey) const; - template - QList metadata(const PropertyName &metakey) const; + QStringList propertyKeys() const; + QStringList metadataKeys() const; + QStringList metadataKeys(const PropertyName &key) const; - template - QList metadata(const PropertyName &key, - const PropertyName &metakey) const; + template + QList property(const PropertyName &key) const; -protected: - template - void setProperty(const QString &key, const QList &values); + template + QList metadata(const PropertyName &metakey) const; - template - void setMetadata(const QString &metakey, const QList &values); + template + QList metadata(const PropertyName &key, + const PropertyName &metakey) const; - template - void setMetadata(const QString &key, const QString &metakey, - const QList &values); + protected: + template + void setProperty(const QString &key, const QList &values); - template - void setProperty(const QString &key, const V &value); + template + void setMetadata(const QString &metakey, const QList &values); - template - void setMetadata(const QString &metakey, V &value); + template + void setMetadata(const QString &key, const QString &metakey, + const QList &values); - template - void setMetadata(const QString &key, const QString &metakey, - const V &value); + template + void setProperty(const QString &key, const V &value); -private: - /** The list of indicies of the selected parts - of the molecule. This is empty if the entire - molecule is selected - */ - QList idxs; -}; + template + void setMetadata(const QString &metakey, V &value); -#ifndef SIRE_SKIP_INLINE_FUNCTIONS + template + void setMetadata(const QString &key, const QString &metakey, + const V &value); -/** Null constructor */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector() : SireBase::ConcreteProperty,MoleculeView>() -{} + private: + /** The list of indicies of the selected parts + of the molecule. This is empty if the entire + molecule is selected + */ + QList idxs; + }; -/** Construct the set of all groups for the molecule whose - data is in 'moldata' */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector(const MoleculeData &moldata) - : SireBase::ConcreteProperty,MoleculeView>(moldata) -{} +#ifndef SIRE_SKIP_INLINE_FUNCTIONS -/** Construct the set of all groups for the molecule whose data is in 'moldata' - and with the specfied groups selected */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector(const MoleculeData &moldata, - const QList &indexes) - : SireBase::ConcreteProperty,MoleculeView>(moldata) -{ - int n = detail::getCount(moldata.info()); + /** Null constructor */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector() : SireBase::ConcreteProperty, MoleculeView>() + { + } - //ensure all of the indexes are valid! - foreach (typename T::Index idx, indexes) + /** Construct the set of all groups for the molecule whose + data is in 'moldata' */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector(const MoleculeData &moldata) + : SireBase::ConcreteProperty, MoleculeView>(moldata) { - idx.map(n); } - idxs = indexes; -} + /** Construct the set of all groups for the molecule whose data is in 'moldata' + and with the specfied groups selected */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector(const MoleculeData &moldata, + const QList &indexes) + : SireBase::ConcreteProperty, MoleculeView>(moldata) + { + int n = detail::getCount(moldata.info()); -/** Construct the set of all groups that contain at least - one of the atoms selected in 'selected_atoms' + // ensure all of the indexes are valid! + foreach (typename T::Index idx, indexes) + { + idx.map(n); + } - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector(const MoleculeData &moldata, - const AtomSelection &selected_atoms) - : SireBase::ConcreteProperty,MoleculeView>(moldata) -{ - if (selected_atoms.selectedNone()) - { - this->operator=(Selector()); + idxs = indexes; } - else if (not selected_atoms.selectedAll()) + + /** Construct the set of all groups that contain at least + one of the atoms selected in 'selected_atoms' + + \throw SireError::incompatible_error + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector(const MoleculeData &moldata, + const AtomSelection &selected_atoms) + : SireBase::ConcreteProperty, MoleculeView>(moldata) { - idxs = detail::getAll(moldata.info(), selected_atoms); + if (selected_atoms.selectedNone()) + { + this->operator=(Selector()); + } + else if (not selected_atoms.selectedAll()) + { + idxs = detail::getAll(moldata.info(), selected_atoms); + } } -} -/** Construct the set that contains only the view 'view' */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector(const T &view) - : SireBase::ConcreteProperty,MoleculeView>(view) -{ - idxs.append(view.index()); -} + /** Construct the set that contains only the view 'view' */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector(const T &view) + : SireBase::ConcreteProperty, MoleculeView>(view) + { + idxs.append(view.index()); + } -/** Construct the set of parts that match the ID 'id' from the - molecule whose data is in 'moldata' - - \throw SireMol::missing_atom - \throw SireMol::missing_residue - \throw SireMol::missing_chain - \throw SireMol::missing_segment - \throw SireMol::missing_cutgroup - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector(const MoleculeData &moldata, - const typename T::ID &viewid) - : SireBase::ConcreteProperty,MoleculeView>(moldata) -{ - idxs = viewid.map(moldata.info()); + /** Construct the set of parts that match the ID 'id' from the + molecule whose data is in 'moldata' - if (idxs.count() == detail::getCount(moldata.info())) + \throw SireMol::missing_atom + \throw SireMol::missing_residue + \throw SireMol::missing_chain + \throw SireMol::missing_segment + \throw SireMol::missing_cutgroup + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector(const MoleculeData &moldata, + const typename T::ID &viewid) + : SireBase::ConcreteProperty, MoleculeView>(moldata) { - idxs.clear(); + idxs = viewid.map(moldata.info()); + + if (idxs.count() == detail::getCount(moldata.info())) + { + idxs.clear(); + } + else if (idxs.isEmpty()) + { + this->operator=(Selector()); + } } - else if (idxs.isEmpty()) + + /** Copy constructor */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::Selector(const Selector &other) + : SireBase::ConcreteProperty, MoleculeView>(other), + idxs(other.idxs) { - this->operator=(Selector()); } -} -/** Copy constructor */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::Selector(const Selector &other) - : SireBase::ConcreteProperty,MoleculeView>(other), - idxs(other.idxs) -{} + /** Destructor */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector::~Selector() + { + } -/** Destructor */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector::~Selector() -{} + /** Copy assignment operator */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector & + Selector::operator=(const Selector &other) + { + MoleculeView::operator=(other); + idxs = other.idxs; -/** Copy assignment operator */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector& Selector::operator=(const Selector &other) -{ - MoleculeView::operator=(other); - idxs = other.idxs; + return *this; + } - return *this; -} + /** Copy so that this contains just 'view' */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector & + Selector::operator=(const T &view) + { + MoleculeView::operator=(view); -/** Copy so that this contains just 'view' */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector& Selector::operator=(const T &view) -{ - MoleculeView::operator=(view); + idxs.clear(); + idxs.append(view.index()); - idxs.clear(); - idxs.append(view.index()); + return *this; + } - return *this; -} + /** Comparison operator */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::operator==(const Selector &other) const + { + return idxs == other.idxs and MoleculeView::operator==(other); + } -/** Comparison operator */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::operator==(const Selector &other) const -{ - return idxs == other.idxs and MoleculeView::operator==(other); -} + /** Comparison operator */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::operator!=(const Selector &other) const + { + return idxs != other.idxs or MoleculeView::operator!=(other); + } -/** Comparison operator */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::operator!=(const Selector &other) const -{ - return idxs != other.idxs or MoleculeView::operator!=(other); -} + template + SIRE_OUTOFLINE_TEMPLATE const char *Selector::typeName() + { + return QMetaType::typeName(qMetaTypeId>()); + } -template -SIRE_OUTOFLINE_TEMPLATE -const char* Selector::typeName() -{ - return QMetaType::typeName( qMetaTypeId< Selector >() ); -} + template + SIRE_OUTOFLINE_TEMPLATE + Selector * + Selector::clone() const + { + return new Selector(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -Selector* Selector::clone() const -{ - return new Selector(*this); -} + /** Return the IDs of all of the items in this selector, in the + * order they appear in the selector + */ + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::IDs() const + { + if (this->isEmpty()) + return QList(); -/** Return the IDs of all of the items in this selector, in the - * order they appear in the selector - */ -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::IDs() const -{ - if (this->isEmpty()) - return QList(); + else if (this->selectedAll()) + { + const int n = detail::getCount(this->data().info()); - else if (this->selectedAll()) - { - const int n = detail::getCount(this->data().info()); + QList ret; + ret.reserve(n); - QList ret; - ret.reserve(n); + for (int i = 0; i < n; ++i) + { + ret.append(typename T::Index(i)); + } - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::indexes() const + { + return this->IDs(); } - else - return idxs; -} -/** Return the indexes of all of the items in this selector, in the - * order they appear in the selector - */ -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::indexes() const -{ - return this->IDs(); -} + /** Return the names of all of the items in this selector, in the + * order they appear in the selector + */ + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::names() const + { + auto indexes = this->IDs(); -/** Return the names of all of the items in this selector, in the - * order they appear in the selector - */ -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::names() const -{ - auto indexes = this->IDs(); + QList n; + n.reserve(indexes.count()); - QList n; - n.reserve(indexes.count()); + const auto &molinfo = this->data().info(); - const auto &molinfo = this->data().info(); + for (const auto &index : indexes) + { + n.append(molinfo.name(index)); + } - for (const auto &index : indexes) - { - n.append( molinfo.name(index) ); + return n; } - return n; -} + /** Return the numbers of all of the items in this selector, in the + * order they appear in the selector + */ + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::numbers() const + { + auto indexes = this->IDs(); -/** Return the numbers of all of the items in this selector, in the - * order they appear in the selector - */ -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::numbers() const -{ - auto indexes = this->IDs(); + QList n; + n.reserve(indexes.count()); - QList n; - n.reserve(indexes.count()); + const auto &molinfo = this->data().info(); - const auto &molinfo = this->data().info(); + for (const auto &index : indexes) + { + n.append(molinfo.number(index)); + } - for (const auto &index : indexes) - { - n.append( molinfo.number(index) ); + return n; } - return n; -} - -/** Return whether this set is empty */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::isEmpty() const -{ - return this->data().isEmpty(); -} + /** Return whether this set is empty */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::isEmpty() const + { + return this->data().isEmpty(); + } -/** Return whether or not the entire molecule is selected */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::selectedAll() const -{ - // have no indexes if we have selected all of the molecule - if (not this->isEmpty()) + /** Return whether or not the entire molecule is selected */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::selectedAll() const { - if (idxs.isEmpty()) - return true; + // have no indexes if we have selected all of the molecule + if (not this->isEmpty()) + { + if (idxs.isEmpty()) + return true; - const int n = detail::getCount(this->data().info()); + const int n = detail::getCount(this->data().info()); - if (idxs.count() >= n) - { - auto s = _list_to_set(idxs); - return s.count() == n; + if (idxs.count() >= n) + { + auto s = _list_to_set(idxs); + return s.count() == n; + } } - } - return false; -} - -/** Return whether or not this is a Selector object */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::isSelector() const -{ - return true; -} + return false; + } -/** Return a string representation of this selector */ -template -SIRE_OUTOFLINE_TEMPLATE -QString Selector::toString() const -{ - if (this->isEmpty()) + /** Return whether or not this is a Selector object */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::isSelector() const { - return QObject::tr("Selector<%1>::empty").arg(T::typeName()); + return true; } - else - { - QStringList parts; - if (this->size() <= 10) + /** Return a string representation of this selector */ + template + SIRE_OUTOFLINE_TEMPLATE + QString + Selector::toString() const + { + if (this->isEmpty()) { - for (int i=0; isize(); ++i) - { - parts.append(QString("%1: %2").arg(i).arg(this->operator()(i).toString())); - } + return QObject::tr("Selector<%1>::empty").arg(T::typeName()); } else { - for (int i=0; i<5; ++i) + QStringList parts; + + if (this->size() <= 10) { - parts.append(QString("%1: %2").arg(i).arg(this->operator()(i).toString())); + for (int i = 0; i < this->size(); ++i) + { + parts.append(QString("%1: %2").arg(i).arg(this->operator()(i).toString())); + } } + else + { + for (int i = 0; i < 5; ++i) + { + parts.append(QString("%1: %2").arg(i).arg(this->operator()(i).toString())); + } - parts.append("..."); + parts.append("..."); - for (int i=this->size()-5; isize(); ++i) - { - parts.append(QString("%1: %3").arg(i).arg(this->operator()(i).toString())); + for (int i = this->size() - 5; i < this->size(); ++i) + { + parts.append(QString("%1: %3").arg(i).arg(this->operator()(i).toString())); + } } - } - return QObject::tr( "Selector<%1>( size=%2\n%3\n)") - .arg(T::typeName()).arg(this->count()) - .arg(parts.join("\n")); + return QObject::tr("Selector<%1>( size=%2\n%3\n)") + .arg(T::typeName()) + .arg(this->count()) + .arg(parts.join("\n")); + } } -} -/** Return the sum of this selection with 'other' - items from - 'other' are appended to this set only if they are not already - in this set + /** Return the sum of this selection with 'other' - items from + 'other' are appended to this set only if they are not already + in this set - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::add(const Selector &other) const -{ - if (this->selectedAll()) + \throw SireError::incompatible_error + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::add(const Selector &other) const { - if (other.isEmpty()) + if (this->selectedAll()) + { + if (other.isEmpty()) + return *this; + + MoleculeView::assertSameMolecule(other); + return *this; + } + else if (other.selectedAll()) + { + if (this->isEmpty()) + return other; - MoleculeView::assertSameMolecule(other); + MoleculeView::assertSameMolecule(other); - return *this; - } - else if (other.selectedAll()) - { - if (this->isEmpty()) - return other; + // do this so that we always use the version from the left hand molecule + Selector ret(*this); + ret.idxs.clear(); + return ret; + } MoleculeView::assertSameMolecule(other); - // do this so that we always use the version from the left hand molecule Selector ret(*this); - ret.idxs.clear(); + + if (ret.idxs.isEmpty()) + { + // expand the indexes + const int n = detail::getCount(this->data().info()); + ret.idxs.reserve(n); + + for (int i = 0; i < n; ++i) + { + ret.idxs.append(typename T::Index(i)); + } + } + + if (other.idxs.isEmpty()) + { + const int n = detail::getCount(this->data().info()); + ret.idxs.reserve(ret.idxs.count() + n); + + for (int i = 0; i < n; ++i) + { + ret.idxs.append(typename T::Index(i)); + } + } + else + { + ret.idxs.reserve(ret.idxs.count() + other.idxs.count()); + + for (typename T::Index idx : other.idxs) + { + ret.idxs.append(idx); + } + } + return ret; } - MoleculeView::assertSameMolecule(other); + /** Return the view 'view' to this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::add(const T &view) const + { + return this->add(Selector(view)); + } - Selector ret(*this); + /** Return the set that has all views that match the ID 'id' + added - if (ret.idxs.isEmpty()) + \throw SireMol::missing_atom + \throw SireMol::missing_residue + \throw SireMol::missing_chain + \throw SireMol::missing_segment + \throw SireMol::missing_cutgroup + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::add(const typename T::ID &id) const { - //expand the indexes - const int n = detail::getCount(this->data().info()); - ret.idxs.reserve(n); + return this->operator+(Selector(this->data(), id)); + } + + /** Subtract all of the views in 'other' from this set - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::subtract(const Selector &other) const + { + if (this->isEmpty()) + return Selector(); + else if (other.selectedAll()) { - ret.idxs.append(typename T::Index(i)); + MoleculeView::assertSameMolecule(other); + return Selector(); } - } - if (other.idxs.isEmpty()) - { + Selector ret(*this); + const int n = detail::getCount(this->data().info()); - ret.idxs.reserve(ret.idxs.count() + n); - for (int i=0; i(); } - } - return ret; -} + return ret; + } -/** Return the view 'view' to this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::add(const T &view) const -{ - return this->add(Selector(view)); -} + /** Remove the view 'view' from this set -/** Return the set that has all views that match the ID 'id' - added - - \throw SireMol::missing_atom - \throw SireMol::missing_residue - \throw SireMol::missing_chain - \throw SireMol::missing_segment - \throw SireMol::missing_cutgroup - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::add(const typename T::ID &id) const -{ - return this->operator+(Selector(this->data(), id)); -} + \throw SireError::incompatible_error + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::subtract(const T &view) const + { + return this->subtract(Selector(view)); + } -/** Subtract all of the views in 'other' from this set + /** Subtract all of the views that match the ID 'id' from + this set - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::subtract(const Selector &other) const -{ - if (this->isEmpty()) - return Selector(); - else if (other.selectedAll()) + \throw SireMol::missing_atom + \throw SireMol::missing_residue + \throw SireMol::missing_chain + \throw SireMol::missing_segment + \throw SireMol::missing_cutgroup + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::subtract(const typename T::ID &id) const { - MoleculeView::assertSameMolecule(other); - return Selector(); + return this->subtract(Selector(this->data(), id)); } - Selector ret(*this); + /** Syntactic sugar for add() */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator+(const Selector &other) const + { + return this->add(other); + } - const int n = detail::getCount(this->data().info()); + /** Syntactic sugar for subtract() */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator-(const Selector &other) const + { + return this->subtract(other); + } - if (ret.idxs.isEmpty()) + /** Syntactic sugar for add() */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator+(const typename T::ID &id) const { + return this->add(id); + } - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator-(const typename T::ID &id) const + { + return this->subtract(id); } - foreach (typename T::Index idx, other.idxs) + /** Syntactic sugar for add() */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator+(const T &view) const { - ret.idxs.removeAll(idx); + return this->add(view); + } - if (ret.idxs.isEmpty()) - return Selector(); + /** Syntactic sugar for subtract() */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator-(const T &view) const + { + return this->subtract(view); } - return ret; -} + /** Return the ith view in this set (this supports negative indexing!) -/** Remove the view 'view' from this set + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](int i) const + { + return this->operator()(i); + } - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::subtract(const T &view) const -{ - return this->subtract(Selector(view)); -} - -/** Subtract all of the views that match the ID 'id' from - this set - - \throw SireMol::missing_atom - \throw SireMol::missing_residue - \throw SireMol::missing_chain - \throw SireMol::missing_segment - \throw SireMol::missing_cutgroup - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::subtract(const typename T::ID &id) const -{ - return this->subtract(Selector(this->data(), id)); -} - -/** Syntactic sugar for add() */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator+(const Selector &other) const -{ - return this->add(other); -} - -/** Syntactic sugar for subtract() */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator-(const Selector &other) const -{ - return this->subtract(other); -} - -/** Syntactic sugar for add() */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator+(const typename T::ID &id) const -{ - return this->add(id); -} - -/** Syntactic sugar for subtract() */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator-(const typename T::ID &id) const -{ - return this->subtract(id); -} - -/** Syntactic sugar for add() */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator+(const T &view) const -{ - return this->add(view); -} - -/** Syntactic sugar for subtract() */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator-(const T &view) const -{ - return this->subtract(view); -} - -/** Return the ith view in this set (this supports negative indexing!) - - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](int i) const -{ - return this->operator()(i); -} - -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const QString &name) const -{ - auto match = this->operator()(AtomName(name)); + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const QString &name) const + { + auto match = this->operator()(AtomName(name)); - if (match.nAtoms() == 1) - return match(0); - else - return match; -} + if (match.nAtoms() == 1) + return match(0); + else + return match; + } -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const SireBase::Slice &slice) const -{ - return this->operator()(slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const SireBase::Slice &slice) const + { + return this->operator()(slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const QList &idxs) const -{ - return this->operator()(idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const QList &idxs) const + { + return this->operator()(idxs); + } -/** Exposing MoleculeView::operator[] */ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const AtomID &atom) const -{ - auto match = this->operator()(atom); + /** Exposing MoleculeView::operator[] */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const AtomID &atom) const + { + auto match = this->operator()(atom); - if (match.nAtoms() == 1) - return match(0); - else - return match; -} + if (match.nAtoms() == 1) + return match(0); + else + return match; + } -/** Exposing MoleculeView::operator[] */ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const ResID &res) const -{ - auto match = this->operator()(res); + /** Exposing MoleculeView::operator[] */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const ResID &res) const + { + auto match = this->operator()(res); - if (match.nResidues() == 1) - return match(0); - else - return match; -} + if (match.nResidues() == 1) + return match(0); + else + return match; + } -/** Exposing MoleculeView::operator[] */ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const CGID &cg) const -{ - auto match = this->operator()(cg); + /** Exposing MoleculeView::operator[] */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const CGID &cg) const + { + auto match = this->operator()(cg); - if (match.nCutGroups() == 1) - return match(0); - else - return match; -} + if (match.nCutGroups() == 1) + return match(0); + else + return match; + } -/** Exposing MoleculeView::operator[] */ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const ChainID &chain) const -{ - auto match = this->operator()(chain); + /** Exposing MoleculeView::operator[] */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const ChainID &chain) const + { + auto match = this->operator()(chain); - if (match.nChains() == 1) - return match(0); - else - return match; -} + if (match.nChains() == 1) + return match(0); + else + return match; + } -/** Exposing MoleculeView::operator[] */ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const SegID &seg) const -{ - auto match = this->operator()(seg); + /** Exposing MoleculeView::operator[] */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const SegID &seg) const + { + auto match = this->operator()(seg); - if (match.nSegments() == 1) - return match(0); - else - return match; -} + if (match.nSegments() == 1) + return match(0); + else + return match; + } -/** Exposing MoleculeView::operator[] */ -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::operator[](const SireID::Index &idx) const -{ - return this->operator()(idx.value()); -} + /** Exposing MoleculeView::operator[] */ + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::operator[](const SireID::Index &idx) const + { + return this->operator()(idx.value()); + } -/** Return the index of the ith view in this set (this supports negative indexing) + /** Return the index of the ith view in this set (this supports negative indexing) - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -typename T::Index Selector::index(int i) const -{ - if (not this->isEmpty()) + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + typename T::Index + Selector::index(int i) const { - if (idxs.isEmpty()) - { - const int n = detail::getCount(this->data().info()); - return typename T::Index(SireID::Index(i).map(n)); - } - else + if (not this->isEmpty()) { - return idxs.at( SireID::Index(i).map(idxs.count())); + if (idxs.isEmpty()) + { + const int n = detail::getCount(this->data().info()); + return typename T::Index(SireID::Index(i).map(n)); + } + else + { + return idxs.at(SireID::Index(i).map(idxs.count())); + } } - } - - return typename T::Index(SireID::Index(i).map(0)); -} -/** Return the ith view in this set (this supports negative indexing!) + return typename T::Index(SireID::Index(i).map(0)); + } - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -T Selector::operator()(int i) const -{ - return T(this->data(), this->index(i)); -} + /** Return the ith view in this set (this supports negative indexing!) -/** Return the range of views from index i to j in this set. This - supports negative indexing, and also, if j is less then i, then - the order of views in the returned set is reversed + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + T + Selector::operator()(int i) const + { + return T(this->data(), this->index(i)); + } - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(int i, int j) const -{ - if (this->isEmpty()) - // raise an index exception - i = SireID::Index(i).map(0); + /** Return the range of views from index i to j in this set. This + supports negative indexing, and also, if j is less then i, then + the order of views in the returned set is reversed - if (this->idxs.isEmpty()) + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(int i, int j) const { - const int n = detail::getCount(this->data().info()); + if (this->isEmpty()) + // raise an index exception + i = SireID::Index(i).map(0); - i = SireID::Index(i).map(n); - j = SireID::Index(j).map(n); + if (this->idxs.isEmpty()) + { + const int n = detail::getCount(this->data().info()); - Selector ret(*this); - ret.idxs.clear(); + i = SireID::Index(i).map(n); + j = SireID::Index(j).map(n); - if (i <= j) - { - if (i == 0 and j == n-1) - // selected all - return ret; + Selector ret(*this); + ret.idxs.clear(); - for ( ; i<=j; ++i) + if (i <= j) { - ret.idxs.append(typename T::Index(i)); + if (i == 0 and j == n - 1) + // selected all + return ret; + + for (; i <= j; ++i) + { + ret.idxs.append(typename T::Index(i)); + } + } + else + { + if (i == n - 1 and j == 0) + // selected all + return ret; + + for (; i >= j; --i) + { + ret.idxs.append(typename T::Index(i)); + } } + + return ret; } else { - if (i == n-1 and j == 0) - // selected all - return ret; + i = SireID::Index(i).map(idxs.count()); + j = SireID::Index(j).map(idxs.count()); + + Selector ret(*this); + ret.idxs.clear(); - for ( ; i >= j; --i) + if (i <= j) { - ret.idxs.append(typename T::Index(i)); + for (; i <= j; ++i) + { + ret.idxs.append(this->idxs.at(i)); + } + } + else + { + for (; i >= j; --i) + { + ret.idxs.append(this->idxs.at(i)); + } } - } - return ret; + return ret; + } } - else - { - i = SireID::Index(i).map(idxs.count()); - j = SireID::Index(j).map(idxs.count()); - Selector ret(*this); - ret.idxs.clear(); + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const SireBase::Slice &slice) const + { + if (this->isEmpty()) + // raise an exception + slice.begin(0); - if (i <= j) + if (this->idxs.isEmpty()) { - for ( ; i<=j; ++i) + const int n = detail::getCount(this->data().info()); + + Selector ret(*this); + ret.idxs.clear(); + + for (auto it = slice.begin(n); not it.atEnd(); it.next()) { - ret.idxs.append(this->idxs.at(i)); + ret.idxs.append(typename T::Index(it.value())); } + + return ret; } else { - for ( ; i >= j; --i) + Selector ret(*this); + ret.idxs.clear(); + + for (auto it = slice.begin(this->idxs.count()); + not it.atEnd(); it.next()) { - ret.idxs.append(this->idxs.at(i)); + ret.idxs.append(this->idxs.at(it.value())); } - } - return ret; + return ret; + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const SireBase::Slice &slice) const -{ - if (this->isEmpty()) - //raise an exception - slice.begin(0); + /** Return the range of views from whose indicies are in idxs in this set. - if (this->idxs.isEmpty()) + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const QList &idxs) const { - const int n = detail::getCount(this->data().info()); - - Selector ret(*this); - ret.idxs.clear(); + if (idxs.isEmpty()) + return Selector(); - for (auto it = slice.begin(n); not it.atEnd(); it.next()) + else if (this->isEmpty()) { - ret.idxs.append(typename T::Index(it.value())); + // raise an exception + SireID::Index(idxs.at(0)).map(0); + return Selector(); } - - return ret; - } - else - { - Selector ret(*this); - ret.idxs.clear(); - - for (auto it = slice.begin(this->idxs.count()); - not it.atEnd(); it.next()) + else if (this->idxs.isEmpty()) { - ret.idxs.append(this->idxs.at(it.value())); - } - - return ret; - } -} + Selector ret(*this); + ret.idxs.clear(); -/** Return the range of views from whose indicies are in idxs in this set. + const int n = detail::getCount(this->data().info()); - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const QList &idxs) const -{ - if (idxs.isEmpty()) - return Selector(); + QSet seen; - else if (this->isEmpty()) - { - //raise an exception - SireID::Index(idxs.at(0)).map(0); - return Selector(); - } - else if (this->idxs.isEmpty()) - { - Selector ret(*this); - ret.idxs.clear(); + for (const auto &idx : idxs) + { + typename T::Index index(SireID::Index(idx).map(n)); - const int n = detail::getCount(this->data().info()); + if (not seen.contains(index)) + { + ret.idxs.append(index); + seen.insert(index); + } + } - QSet seen; + if (ret.idxs.count() >= n) + ret.idxs.clear(); - for (const auto &idx : idxs) + return ret; + } + else { - typename T::Index index(SireID::Index(idx).map(n)); + Selector ret(*this); + ret.idxs.clear(); - if (not seen.contains(index)) + for (const auto &idx : idxs) { + auto index = this->idxs.at(SireID::Index(idx).map(this->idxs.count())); ret.idxs.append(index); - seen.insert(index); } - } - - if (ret.idxs.count() >= n) - ret.idxs.clear(); - - return ret; - } - else - { - Selector ret(*this); - ret.idxs.clear(); - for (const auto &idx : idxs) - { - auto index = this->idxs.at(SireID::Index(idx).map(this->idxs.count())); - ret.idxs.append(index); + return ret; } - - return ret; } -} - -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const AtomID &atomid) const -{ - return this->atoms(atomid); -} -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const ResID &resid) const -{ - return this->residues(resid); -} + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const AtomID &atomid) const + { + return this->atoms(atomid); + } -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const CGID &cgid) const -{ - return this->cutGroups(cgid); -} + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const ResID &resid) const + { + return this->residues(resid); + } -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const ChainID &chainid) const -{ - return this->chains(chainid); -} + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const CGID &cgid) const + { + return this->cutGroups(cgid); + } -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::operator()(const SegID &segid) const -{ - return this->segments(segid); -} + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const ChainID &chainid) const + { + return this->chains(chainid); + } -template -SIRE_OUTOFLINE_TEMPLATE -MolViewPtr Selector::toSelector() const -{ - return MolViewPtr(*this); -} + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::operator()(const SegID &segid) const + { + return this->segments(segid); + } -template -SIRE_OUTOFLINE_TEMPLATE -Molecules Selector::toMolecules() const -{ - return Molecules( ViewsOfMol(*this) ); -} + template + SIRE_OUTOFLINE_TEMPLATE + MolViewPtr + Selector::toSelector() const + { + return MolViewPtr(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::toList() const -{ - QList l; + template + SIRE_OUTOFLINE_TEMPLATE + Molecules + Selector::toMolecules() const + { + return Molecules(ViewsOfMol(*this)); + } - if (not this->isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::toList() const { - if (idxs.isEmpty()) + QList l; + + if (not this->isEmpty()) { - //return the entire molecule - const auto& d = this->data(); + if (idxs.isEmpty()) + { + // return the entire molecule + const auto &d = this->data(); - const int n = detail::getCount(d.info()); - l.reserve(n); + const int n = detail::getCount(d.info()); + l.reserve(n); - for (int i=0; idata(); + const auto &d = this->data(); - for (const auto &idx : idxs) - { - l.append(MolViewPtr(new T(d, idx))); + for (const auto &idx : idxs) + { + l.append(MolViewPtr(new T(d, idx))); + } } } + + return l; } - return l; -} + template + SIRE_OUTOFLINE_TEMPLATE + T + Selector::operator()(const SireID::Index &idx) const + { + return this->operator()(idx.value()); + } -template -SIRE_OUTOFLINE_TEMPLATE -T Selector::operator()(const SireID::Index &idx) const -{ - return this->operator()(idx.value()); -} - -/** Return the number of views in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -int Selector::nViews() const -{ - if (this->isEmpty()) - return 0; - else if (this->selectedAll()) - return detail::getCount(this->data().info()); - else - return this->idxs.count(); -} + /** Return the number of views in this set */ + template + SIRE_OUTOFLINE_TEMPLATE int Selector::nViews() const + { + if (this->isEmpty()) + return 0; + else if (this->selectedAll()) + return detail::getCount(this->data().info()); + else + return this->idxs.count(); + } -template -SIRE_INLINE_TEMPLATE -QSet _list_to_set(const QList &vals) -{ - #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + template + SIRE_INLINE_TEMPLATE + QSet + _list_to_set(const QList &vals) + { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) return QSet(vals.constBegin(), vals.constEnd()); - #else +#else return vals.toSet(); - #endif -} +#endif + } -/** Return the intersection of this set with 'other' - the - views in both sets are returned, in the order that they - appear in this set + /** Return the intersection of this set with 'other' - the + views in both sets are returned, in the order that they + appear in this set - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::intersection(const Selector &other) const -{ - if (this->isEmpty() or other.isEmpty()) - return Selector(); - - else if (this->selectedAll()) + \throw SireError::incompatible_error + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::intersection(const Selector &other) const { - MoleculeView::assertSameMolecule(other); - Selector ret(*this); - ret.idxs = other.idxs; - return ret; + if (this->isEmpty() or other.isEmpty()) + return Selector(); + + else if (this->selectedAll()) + { + MoleculeView::assertSameMolecule(other); + Selector ret(*this); + ret.idxs = other.idxs; + return ret; + } + else if (other.selectedAll()) + { + MoleculeView::assertSameMolecule(other); + return *this; + } + else + { + MoleculeView::assertSameMolecule(other); + + Selector ret(*this); + ret.idxs.clear(); + + auto this_idxs = this->idxs; + auto other_idxs = other.idxs; + + const int n = detail::getCount(this->data().info()); + + if (this_idxs.isEmpty()) + { + this_idxs.reserve(n); + for (int i = 0; i < n; ++i) + { + this_idxs.append(typename T::Index(i)); + } + } + + if (other_idxs.isEmpty()) + { + other_idxs.reserve(n); + for (int i = 0; i < n; ++i) + { + other_idxs.append(typename T::Index(i)); + } + } + + auto seen = _list_to_set(other_idxs); + + for (const auto &idx : this_idxs) + { + if (seen.contains(idx)) + ret.idxs.append(idx); + } + + if (ret.idxs.isEmpty()) + { + return Selector(); + } + + return ret; + } } - else if (other.selectedAll()) + + /** Return the intersection of this set with 'view' + + \throw SireError::incompatible_error + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::intersection(const T &view) const { - MoleculeView::assertSameMolecule(other); - return *this; + return this->intersection(Selector(view)); } - else - { - MoleculeView::assertSameMolecule(other); - Selector ret(*this); - ret.idxs.clear(); + /** Return the intersection of this set with the views identified + by the ID 'id' - auto this_idxs = this->idxs; - auto other_idxs = other.idxs; + \throw SireMol::missing_atom + \throw SireMol::missing_residue + \throw SireMol::missing_chain + \throw SireMol::missing_segment + \throw SireMol::missing_cutgroup + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::intersection(const typename T::ID &id) const + { + return this->intersection(Selector(this->data(), id)); + } - const int n = detail::getCount(this->data().info()); + /** Return the index in this collection of the view that + * matches 'view'. This returns an empty list if the + * view is not in this collection + */ + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::find(const T &view) const + { + QList matches; - if (this_idxs.isEmpty()) + if (MoleculeView::isSameMolecule(view)) { - this_idxs.reserve(n); - for (int i=0; iselectedAll()) + { + matches.append(view.index().value()); + } + else if (not this->isEmpty()) { - this_idxs.append(typename T::Index(i)); + int match = this->idxs.indexOf(view.index()); + + if (match != -1) + matches.append(match); } } - if (other_idxs.isEmpty()) + return matches; + } + + /** Return the index in this collection of any views that + * matches 'views'. This returns an empty list if none of + * the views are in this collection + */ + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::find(const Selector &views) const + { + QList matches; + + if (MoleculeView::isSameMolecule(views)) { - other_idxs.reserve(n); - for (int i=0; iselectedAll()) + { + if (views.selectedAll()) + { + for (int i = 0; i < this->count(); ++i) + { + matches.append(i); + } + } + else if (not views.isEmpty()) + { + for (const auto &idx : views.idxs) + { + matches.append(idx.value()); + } + } + } + else if (not this->isEmpty()) { - other_idxs.append(typename T::Index(i)); + if (views.selectedAll()) + { + for (int i = 0; i < this->count(); ++i) + { + matches.append(i); + } + } + else if (not views.isEmpty()) + { + for (const auto &idx : views.idxs) + { + int match = this->idxs.indexOf(idx); + + if (match != -1) + matches.append(match); + } + } } } - auto seen = _list_to_set(other_idxs); + return matches; + } - for (const auto &idx : this_idxs) + /** Return the set that has a completely inverted selection */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::invert() const + { + if (this->isEmpty()) { - if (seen.contains(idx)) - ret.idxs.append(idx); + throw SireMol::missing_atom(QObject::tr( + "Cannot invert an empty selection!"), + CODELOC); } - - if (ret.idxs.isEmpty()) + else if (this->selectedAll()) { return Selector(); } + else + { + Selector ret(*this); + ret.idxs.clear(); - return ret; - } -} + const int n = detail::getCount(this->data().info()); -/** Return the intersection of this set with 'view' + if (this->idxs.count() == 1) + { + auto seen = this->idxs.at(0); - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::intersection(const T &view) const -{ - return this->intersection(Selector(view)); -} + for (int i = 0; i < n; ++i) + { + typename T::Index idx(i); -/** Return the intersection of this set with the views identified - by the ID 'id' - - \throw SireMol::missing_atom - \throw SireMol::missing_residue - \throw SireMol::missing_chain - \throw SireMol::missing_segment - \throw SireMol::missing_cutgroup - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::intersection(const typename T::ID &id) const -{ - return this->intersection(Selector(this->data(), id)); -} + if (idx != seen) + ret.idxs.append(idx); + } + } + else + { + auto seen = _list_to_set(this->idxs); -/** Return the set that has a completely inverted selection */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::invert() const -{ - if (this->isEmpty()) - { - throw SireMol::missing_atom(QObject::tr( - "Cannot invert an empty selection!"), CODELOC); - } - else if (this->selectedAll()) - { - return Selector(); + for (int i = 0; i < n; ++i) + { + typename T::Index idx(i); + + if (not seen.contains(idx)) + ret.idxs.append(idx); + } + } + + return ret; + } } - else - { - Selector ret(*this); - ret.idxs.clear(); - const int n = detail::getCount(this->data().info()); + /** Return whether this set contains all of the views + in 'other' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::contains(const Selector &other) const + { + if (this->isEmpty() or other.isEmpty()) + return false; - if (this->idxs.count() == 1) - { - auto seen = this->idxs.at(0); + MoleculeView::assertSameMolecule(other); - for (int i=0; iselectedAll()) + return true; + else if (other.selectedAll()) + return false; - if (idx != seen) - ret.idxs.append(idx); - } - } else { auto seen = _list_to_set(this->idxs); - for (int i=0; i -SIRE_OUTOFLINE_TEMPLATE -bool Selector::contains(const Selector &other) const -{ - if (this->isEmpty() or other.isEmpty()) - return false; + /** Return whether this set contains some of the view + in other - MoleculeView::assertSameMolecule(other); + \throw SireError::incompatible_error + */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::intersects(const Selector &other) const + { + if (this->isEmpty() or other.isEmpty()) + return false; - if (this->selectedAll()) - return true; - else if (other.selectedAll()) - return false; + MoleculeView::assertSameMolecule(other); + + if (this->selectedAll() or other.selectedAll()) + return true; - else - { auto seen = _list_to_set(this->idxs); for (const auto &idx : other.idxs) { - if (not seen.contains(idx)) - return false; + if (seen.contains(idx)) + return true; } - return true; - } -} - -/** Return whether this set contains some of the view - in other - - \throw SireError::incompatible_error -*/ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::intersects(const Selector &other) const -{ - if (this->isEmpty() or other.isEmpty()) return false; + } - MoleculeView::assertSameMolecule(other); - - if (this->selectedAll() or other.selectedAll()) - return true; + /** Return whether or not this set contains the view 'view' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::contains(const T &view) const + { + return this->contains(Selector(view)); + } - auto seen = _list_to_set(this->idxs); + /** Return whether or not this set contains all of the + view identified by the ID 'id' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::contains(const typename T::ID &id) const + { + return this->contains(Selector(this->data(), id)); + } - for (const auto &idx : other.idxs) + /** Return whether or not this set contains the view 'view' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::intersects(const T &view) const { - if (seen.contains(idx)) - return true; + return this->intersects(Selector(view)); } - return false; -} + /** Return whether this set contains some of the views + identified by the ID 'id' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::intersects(const typename T::ID &id) const + { + return this->intersects(Selector(this->data(), id)); + } -/** Return whether or not this set contains the view 'view' */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::contains(const T &view) const -{ - return this->contains(Selector(view)); -} + /** Return all of the atoms selected in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + AtomSelection + Selector::selection() const + { + if (this->isEmpty()) + return AtomSelection(); -/** Return whether or not this set contains all of the - view identified by the ID 'id' */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::contains(const typename T::ID &id) const -{ - return this->contains(Selector(this->data(), id)); -} + else if (this->selectedAll()) + { + return AtomSelection(this->data()); + } -/** Return whether or not this set contains the view 'view' */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::intersects(const T &view) const -{ - return this->intersects(Selector(view)); -} + AtomSelection selected_atoms(this->data()); -/** Return whether this set contains some of the views - identified by the ID 'id' */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::intersects(const typename T::ID &id) const -{ - return this->intersects(Selector(this->data(), id)); -} + selected_atoms.selectNone(); -/** Return all of the atoms selected in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -AtomSelection Selector::selection() const -{ - if (this->isEmpty()) - return AtomSelection(); + for (const auto &idx : this->idxs) + { + selected_atoms.select(idx); + } - else if (this->selectedAll()) - { - return AtomSelection(this->data()); + return selected_atoms; } - AtomSelection selected_atoms(this->data()); + /** Return the selection of the atoms in the ith view - selected_atoms.selectNone(); - - for (const auto &idx : this->idxs) + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + AtomSelection + Selector::selection(int i) const { - selected_atoms.select(idx); + return this->operator()(i).selection(); } - return selected_atoms; -} - -/** Return the selection of the atoms in the ith view - - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -AtomSelection Selector::selection(int i) const -{ - return this->operator()(i).selection(); -} + /** Return the selection of the atoms in the ith to jth views -/** Return the selection of the atoms in the ith to jth views - - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -AtomSelection Selector::selection(int i, int j) const -{ - return this->operator()(i, j).selection(); -} + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + AtomSelection + Selector::selection(int i, int j) const + { + return this->operator()(i, j).selection(); + } -/** Return an object that can move a copy of all of the views - in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Mover< Selector > Selector::move() const -{ - return Mover< Selector >(*this); -} + /** Return an object that can move a copy of all of the views + in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Mover> + Selector::move() const + { + return Mover>(*this); + } -/** Return an object that can move the ith view in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Mover< Selector > Selector::move(int i) const -{ - return Mover< Selector >(Selector(this->operator()(i))); -} + /** Return an object that can move the ith view in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Mover> + Selector::move(int i) const + { + return Mover>(Selector(this->operator()(i))); + } -/** Return an object that can move the ith to jth views in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Mover< Selector > Selector::move(int i, int j) const -{ - return Mover< Selector >(this->operator()(i,j)); -} + /** Return an object that can move the ith to jth views in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Mover> + Selector::move(int i, int j) const + { + return Mover>(this->operator()(i, j)); + } -/** Return an evaluator that can evaluate properties over all - of the views in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Evaluator Selector::evaluate() const -{ - return Evaluator(*this); -} + /** Return an evaluator that can evaluate properties over all + of the views in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Evaluator + Selector::evaluate() const + { + return Evaluator(*this); + } -/** Return an evaluator that can evaluate properties over the - ith view in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Evaluator Selector::evaluate(int i) const -{ - return Evaluator(this->operator()(i)); -} + /** Return an evaluator that can evaluate properties over the + ith view in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Evaluator + Selector::evaluate(int i) const + { + return Evaluator(this->operator()(i)); + } -/** Return an evaluator that can evaluate properties over - the ith to jth views in this set */ -template -SIRE_OUTOFLINE_TEMPLATE -Evaluator Selector::evaluate(int i, int j) const -{ - return Evaluator(this->operator()(i,j)); -} + /** Return an evaluator that can evaluate properties over + the ith to jth views in this set */ + template + SIRE_OUTOFLINE_TEMPLATE + Evaluator + Selector::evaluate(int i, int j) const + { + return Evaluator(this->operator()(i, j)); + } -/** Return a selector that can change the selection of this view */ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::selector() const -{ - return *this; -} + /** Return a selector that can change the selection of this view */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::selector() const + { + return *this; + } -/** Return a selector for the ith view that can change the - selection of that view + /** Return a selector for the ith view that can change the + selection of that view - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::selector(int i) const -{ - return Selector(this->operator()(i)); -} + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::selector(int i) const + { + return Selector(this->operator()(i)); + } -/** Return a selector for the ith to jth views + /** Return a selector for the ith to jth views - \throw SireError::invalid_index -*/ -template -SIRE_OUTOFLINE_TEMPLATE -Selector Selector::selector(int i, int j) const -{ - return this->operator()(i, j); -} + \throw SireError::invalid_index + */ + template + SIRE_OUTOFLINE_TEMPLATE + Selector + Selector::selector(int i, int j) const + { + return this->operator()(i, j); + } -/** Return a list of the values of the property called 'key' for each - of the views in this set, in the order that they appear in this set. + /** Return a list of the values of the property called 'key' for each + of the views in this set, in the order that they appear in this set. - \throw SireBase::missing_property - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::property(const PropertyName &key) const -{ - T *ptr = 0; - return detail::get_property(ptr, this->data(), this->IDs(), key); -} + \throw SireBase::missing_property + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::property(const PropertyName &key) const + { + T *ptr = 0; + return detail::get_property(ptr, this->data(), this->IDs(), key); + } -/** Return a list of all of the metadata called 'metakey' for each - of the views in this set, in the order they appear in this set. + /** Return a list of all of the metadata called 'metakey' for each + of the views in this set, in the order they appear in this set. - \throw SireBase::missing_property - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::metadata(const PropertyName &metakey) const -{ - T *ptr = 0; - return detail::get_metadata(ptr, this->data(), - this->IDs(), metakey); -} + \throw SireBase::missing_property + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::metadata(const PropertyName &metakey) const + { + T *ptr = 0; + return detail::get_metadata(ptr, this->data(), + this->IDs(), metakey); + } -/** Return a list of all of the metadata called 'key'/'metakey' for each - of the views in this set, in the order they appear in this set. + /** Return a list of all of the metadata called 'key'/'metakey' for each + of the views in this set, in the order they appear in this set. - \throw SireBase::missing_property - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -QList Selector::metadata(const PropertyName &key, - const PropertyName &metakey) const -{ - T *ptr = 0; - return detail::get_metadata(ptr, this->data(), this->IDs(), - key, metakey); -} + \throw SireBase::missing_property + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE + QList + Selector::metadata(const PropertyName &key, + const PropertyName &metakey) const + { + T *ptr = 0; + return detail::get_metadata(ptr, this->data(), this->IDs(), + key, metakey); + } -/** Set the property at key 'key' for all of the views in this set - to the values in 'values', with the values given in the same - order as the views in this set. + /** Set the property at key 'key' for all of the views in this set + to the values in 'values', with the values given in the same + order as the views in this set. - \throw SireError::incompatible_error - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -void Selector::setProperty(const QString &key, const QList &values) -{ - T *ptr = 0; - detail::set_property(ptr, this->data(), this->IDs(), key, values); -} - -/** Set the metadata at key 'metakey' for all of the views in this set - to the values in 'values', with the values given in the same - order as the views in this set. + \throw SireError::incompatible_error + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE void Selector::setProperty(const QString &key, const QList &values) + { + T *ptr = 0; + detail::set_property(ptr, this->data(), this->IDs(), key, values); + } - \throw SireError::incompatible_error - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -void Selector::setMetadata(const QString &metakey, const QList &values) -{ - T *ptr = 0; - detail::set_metadata(ptr, this->data(), this->IDs(), metakey, values); -} + /** Set the metadata at key 'metakey' for all of the views in this set + to the values in 'values', with the values given in the same + order as the views in this set. + \throw SireError::incompatible_error + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE void Selector::setMetadata(const QString &metakey, const QList &values) + { + T *ptr = 0; + detail::set_metadata(ptr, this->data(), this->IDs(), metakey, values); + } -/** Set the metadata at key 'key'/'metakey' for all of the views in this set - to the values in 'values', with the values given in the same - order as the views in this set. + /** Set the metadata at key 'key'/'metakey' for all of the views in this set + to the values in 'values', with the values given in the same + order as the views in this set. - \throw SireError::incompatible_error - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -void Selector::setMetadata(const QString &key, const QString &metakey, - const QList &values) -{ - T *ptr = 0; - detail::set_metadata(ptr, this->data(), this->IDs(), key, metakey, values); -} + \throw SireError::incompatible_error + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE void Selector::setMetadata(const QString &key, const QString &metakey, + const QList &values) + { + T *ptr = 0; + detail::set_metadata(ptr, this->data(), this->IDs(), key, metakey, values); + } -/** Set the property at key 'key' for all of the views in this set - to the value 'value' + /** Set the property at key 'key' for all of the views in this set + to the value 'value' - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -void Selector::setProperty(const QString &key, const V &value) -{ - T *ptr = 0; - detail::set_property(ptr, this->data(), this->IDs(), key, value); -} + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE void Selector::setProperty(const QString &key, const V &value) + { + T *ptr = 0; + detail::set_property(ptr, this->data(), this->IDs(), key, value); + } -/** Set the metadata at metakey 'metakey' for all of the views in this set - to the value 'value' + /** Set the metadata at metakey 'metakey' for all of the views in this set + to the value 'value' - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -void Selector::setMetadata(const QString &metakey, V &value) -{ - T *ptr = 0; - detail::set_metadata(ptr, this->data(), this->IDs(), metakey, value); -} + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE void Selector::setMetadata(const QString &metakey, V &value) + { + T *ptr = 0; + detail::set_metadata(ptr, this->data(), this->IDs(), metakey, value); + } -/** Set the metadata at key 'key'/'metakey' for all of the views in this set - to the value 'value' + /** Set the metadata at key 'key'/'metakey' for all of the views in this set + to the value 'value' - \throw SireError::invalid_cast -*/ -template -template -SIRE_OUTOFLINE_TEMPLATE -void Selector::setMetadata(const QString &key, const QString &metakey, - const V &value) -{ - T *ptr = 0; - detail::set_metadata(ptr, this->data(), this->IDs(), key, metakey, value); -} + \throw SireError::invalid_cast + */ + template + template + SIRE_OUTOFLINE_TEMPLATE void Selector::setMetadata(const QString &key, const QString &metakey, + const V &value) + { + T *ptr = 0; + detail::set_metadata(ptr, this->data(), this->IDs(), key, metakey, value); + } -/** Return whether or not the views of this selector has a property - at key 'key' */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::hasProperty(const PropertyName &key) const -{ - T *ptr = 0; - return detail::has_property(ptr, this->data(), key); -} + /** Return whether or not the views of this selector has a property + at key 'key' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::hasProperty(const PropertyName &key) const + { + T *ptr = 0; + return detail::has_property(ptr, this->data(), key); + } -/** Return whether or not the views of this selector have metadata - at metakey 'metakey' */ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::hasMetadata(const PropertyName &metakey) const -{ - T *ptr = 0; - return detail::has_metadata(ptr, this->data(), metakey); -} + /** Return whether or not the views of this selector have metadata + at metakey 'metakey' */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::hasMetadata(const PropertyName &metakey) const + { + T *ptr = 0; + return detail::has_metadata(ptr, this->data(), metakey); + } -/** Return whether or not the property at key 'key' for the views - of this selector has metadata at metakey 'metakey' + /** Return whether or not the property at key 'key' for the views + of this selector has metadata at metakey 'metakey' - \throw SireBase::missing_property -*/ -template -SIRE_OUTOFLINE_TEMPLATE -bool Selector::hasMetadata(const PropertyName &key, - const PropertyName &metakey) const -{ - T *ptr = 0; - return detail::has_metadata(ptr, this->data(), key, metakey); -} + \throw SireBase::missing_property + */ + template + SIRE_OUTOFLINE_TEMPLATE bool Selector::hasMetadata(const PropertyName &key, + const PropertyName &metakey) const + { + T *ptr = 0; + return detail::has_metadata(ptr, this->data(), key, metakey); + } -/** Return all of the keys for the properties attached to the - parts of this selection */ -template -SIRE_OUTOFLINE_TEMPLATE -QStringList Selector::propertyKeys() const -{ - if (this->isEmpty()) - return QStringList(); - else - return this->operator()(0).propertyKeys(); -} + /** Return all of the keys for the properties attached to the + parts of this selection */ + template + SIRE_OUTOFLINE_TEMPLATE + QStringList + Selector::propertyKeys() const + { + if (this->isEmpty()) + return QStringList(); + else + return this->operator()(0).propertyKeys(); + } -/** Return all of the metakeys for the metadata attached to the - parts of this selection */ -template -SIRE_OUTOFLINE_TEMPLATE -QStringList Selector::metadataKeys() const -{ - if (this->isEmpty()) - return QStringList(); - else - return this->operator()(0).metadataKeys(); -} + /** Return all of the metakeys for the metadata attached to the + parts of this selection */ + template + SIRE_OUTOFLINE_TEMPLATE + QStringList + Selector::metadataKeys() const + { + if (this->isEmpty()) + return QStringList(); + else + return this->operator()(0).metadataKeys(); + } -/** Return all of the metakeys for the metadata attached to the - parts of this selection for the property at key 'key' + /** Return all of the metakeys for the metadata attached to the + parts of this selection for the property at key 'key' - \throw SireBase::missing_property -*/ -template -SIRE_OUTOFLINE_TEMPLATE -QStringList Selector::metadataKeys(const PropertyName &key) const -{ - if (this->isEmpty()) - return QStringList(); - else - return this->operator()(0).metadataKeys(key); -} + \throw SireBase::missing_property + */ + template + SIRE_OUTOFLINE_TEMPLATE + QStringList + Selector::metadataKeys(const PropertyName &key) const + { + if (this->isEmpty()) + return QStringList(); + else + return this->operator()(0).metadataKeys(key); + } -#endif //SIRE_SKIP_INLINE_FUNCTIONS +#endif // SIRE_SKIP_INLINE_FUNCTIONS } // end of namespace SireMol #ifndef SIRE_SKIP_INLINE_FUNCTIONS /** Extract from a binary datastream */ -template +template SIRE_OUTOFLINE_TEMPLATE -SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SireMol::Selector &views) + SIREMOL_EXPORT QDataStream & + operator>>(QDataStream &ds, SireMol::Selector &views) { QString cls; SireStream::VersionID version; @@ -1862,8 +2004,10 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SireMol::Selector &vi if (cls != QString(SireMol::Selector::typeName())) { throw SireStream::corrupted_data(QObject::tr( - "Found the wrong class (%1) when trying to read a %2.") - .arg(cls).arg(SireMol::Selector::typeName()), CODELOC); + "Found the wrong class (%1) when trying to read a %2.") + .arg(cls) + .arg(SireMol::Selector::typeName()), + CODELOC); } ds >> version; @@ -1871,7 +2015,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SireMol::Selector &vi if (version == 2) { SireStream::SharedDataStream sds(ds); - sds >> views.idxs >> static_cast(views); + sds >> views.idxs >> static_cast(views); } else if (version == 1) { @@ -1894,15 +2038,16 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SireMol::Selector &vi } /** Serialise to a binary datastream */ -template +template SIRE_OUTOFLINE_TEMPLATE -SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SireMol::Selector &views) + SIREMOL_EXPORT QDataStream & + operator<<(QDataStream &ds, const SireMol::Selector &views) { ds << QString(SireMol::Selector::typeName()) << SireStream::VersionID(2); SireStream::SharedDataStream sds(ds); - sds << views.idxs << static_cast(views); + sds << views.idxs << static_cast(views); return ds; } diff --git a/corelib/src/libs/SireMol/selectorm.hpp b/corelib/src/libs/SireMol/selectorm.hpp index fc88ca39b..82c137c18 100644 --- a/corelib/src/libs/SireMol/selectorm.hpp +++ b/corelib/src/libs/SireMol/selectorm.hpp @@ -41,2450 +41,2630 @@ SIRE_BEGIN_HEADER namespace SireMol { -template -class SelectorM; + template + class SelectorM; -class SelectorMol; + class SelectorMol; } -template -SIREMOL_EXPORT QDataStream& operator<<(QDataStream&, const SireMol::SelectorM&); +template +SIREMOL_EXPORT QDataStream &operator<<(QDataStream &, const SireMol::SelectorM &); -template -SIREMOL_EXPORT QDataStream& operator>>(QDataStream&, SireMol::SelectorM&); +template +SIREMOL_EXPORT QDataStream &operator>>(QDataStream &, SireMol::SelectorM &); namespace SireMol { -/** This is an analogue of the Selector class that is designed - to hold views from multiple molecules -*/ -template -class SIREMOL_EXPORT SelectorM - : public SireBase::ConcreteProperty,SireBase::Property> -{ + /** This is an analogue of the Selector class that is designed + to hold views from multiple molecules + */ + template + class SIREMOL_EXPORT SelectorM + : public SireBase::ConcreteProperty, SireBase::Property> + { -friend SIREMOL_EXPORT QDataStream& ::operator<<<>(QDataStream&, const SelectorM&); -friend SIREMOL_EXPORT QDataStream& ::operator>><>(QDataStream&, SelectorM&); + friend SIREMOL_EXPORT QDataStream & ::operator<< <>(QDataStream &, const SelectorM &); + friend SIREMOL_EXPORT QDataStream & ::operator>><>(QDataStream &, SelectorM &); -public: - typedef typename QList< Selector >::const_iterator iterator; - typedef typename QList< Selector >::const_iterator const_iterator; + public: + typedef typename QList>::const_iterator iterator; + typedef typename QList>::const_iterator const_iterator; - SelectorM(); - SelectorM(const T &view); - SelectorM(const Selector &views); - SelectorM(const Molecules &mols); - SelectorM(const MoleculeGroup &mols); - SelectorM(const MolGroupsBase &mols); - SelectorM(const SelectResult &mols); + SelectorM(); + SelectorM(const T &view); + SelectorM(const Selector &views); + SelectorM(const Molecules &mols); + SelectorM(const MoleculeGroup &mols); + SelectorM(const MolGroupsBase &mols); + SelectorM(const SelectResult &mols); - SelectorM(const SelectorMol &mols); - SelectorM(const SelectorMol &mols, const SireBase::Slice &slice); - SelectorM(const SelectorMol &mols, const QList &idxs); - SelectorM(const SelectorMol &mols, const QString &name, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); - SelectorM(const SelectorMol &mols, const typename T::ID &id); + SelectorM(const SelectorMol &mols); + SelectorM(const SelectorMol &mols, const SireBase::Slice &slice); + SelectorM(const SelectorMol &mols, const QList &idxs); + SelectorM(const SelectorMol &mols, const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + SelectorM(const SelectorMol &mols, const typename T::ID &id); - template - SelectorM(const SelectorM &other); - template - SelectorM(const SelectorM &other, const SireBase::Slice &slice); - template - SelectorM(const SelectorM &other, const QList &idxs); - template - SelectorM(const SelectorM &other, const QString &name); - template - SelectorM(const SelectorM &other, const typename T::ID &id); + template + SelectorM(const SelectorM &other); + template + SelectorM(const SelectorM &other, const SireBase::Slice &slice); + template + SelectorM(const SelectorM &other, const QList &idxs); + template + SelectorM(const SelectorM &other, const QString &name); + template + SelectorM(const SelectorM &other, const typename T::ID &id); - SelectorM(const SelectorM &other); + SelectorM(const SelectorM &other); - virtual ~SelectorM(); + virtual ~SelectorM(); - static const char* typeName(); + static const char *typeName(); - virtual SelectorM* clone() const - { - return new SelectorM(*this); - } + virtual SelectorM *clone() const + { + return new SelectorM(*this); + } - SelectorM& operator=(const SelectorM &other); + SelectorM &operator=(const SelectorM &other); - bool operator==(const SelectorM &other) const; - bool operator!=(const SelectorM &other) const; + bool operator==(const SelectorM &other) const; + bool operator!=(const SelectorM &other) const; - T operator[](int i) const; - SelectorM operator[](const SireBase::Slice &slice) const; - SelectorM operator[](const QList &idxs) const; - T operator[](const QString &name) const; - T operator[](const typename T::ID &id) const; + T operator[](int i) const; + SelectorM operator[](const SireBase::Slice &slice) const; + SelectorM operator[](const QList &idxs) const; + T operator[](const QString &name) const; + T operator[](const typename T::ID &id) const; - T operator()(int i) const; - T operator()(const QString &name) const; - T operator()(const typename T::ID &id) const; + T operator()(int i) const; + T operator()(const QString &name) const; + T operator()(const typename T::ID &id) const; - QList toList() const; - Molecules toMolecules() const; + QList toList() const; + Molecules toMolecules() const; - int count() const; - int size() const; + int count() const; + int size() const; - void update(const Molecules &molecules); + void update(const Molecules &molecules); - EvaluatorM evaluate() const; + EvaluatorM evaluate() const; - MoleculeGroup toMoleculeGroup() const; - SelectResult toSelectResult() const; + MoleculeGroup toMoleculeGroup() const; + SelectResult toSelectResult() const; - bool isSelector() const; + bool isSelector() const; - SelectorM add(const SelectorM &other) const; - SelectorM add(const Selector &views) const; - SelectorM add(const T &view) const; + QList find(const T &view) const; + QList find(const Selector &views) const; + QList find(const SelectorM &views) const; - SelectorM subtract(const SelectorM &other) const; - SelectorM subtract(const Selector &views) const; - SelectorM subtract(const T &view) const; + SelectorM add(const SelectorM &other) const; + SelectorM add(const Selector &views) const; + SelectorM add(const T &view) const; - SelectorM intersection(const SelectorM &other) const; - SelectorM intersection(const Selector &views) const; - SelectorM intersection(const T &view) const; + SelectorM subtract(const SelectorM &other) const; + SelectorM subtract(const Selector &views) const; + SelectorM subtract(const T &view) const; - SelectorM invert() const; + SelectorM intersection(const SelectorM &other) const; + SelectorM intersection(const Selector &views) const; + SelectorM intersection(const T &view) const; - bool intersects(const SelectorM &other) const; - bool intersects(const Selector &view) const; - bool intersects(const T &view) const; + SelectorM invert() const; - bool contains(const SelectorM &other) const; - bool contains(const Selector &view) const; - bool contains(const T &view) const; + bool intersects(const SelectorM &other) const; + bool intersects(const Selector &view) const; + bool intersects(const T &view) const; - Molecule molecule(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const QString &name, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const MolID &molid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); + bool contains(const SelectorM &other) const; + bool contains(const Selector &view) const; + bool contains(const T &view) const; - SelectorMol molecules() const; - SelectorMol molecules(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const SireBase::Slice &slice, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const QList &idxs, + Molecule molecule(int i, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const QString &name, + Molecule molecule(const QString &name, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const MolID &molid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - - Atom atom(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Atom atom(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Atom atom(const AtomID &atomid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - - Residue residue(int i, + Molecule molecule(const MolID &molid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + + SelectorMol molecules() const; + SelectorMol molecules(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const MolID &molid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + Atom atom(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Atom atom(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Atom atom(const AtomID &atomid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + Residue residue(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Residue residue(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Residue residue(const ResID &resid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + Chain chain(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Chain chain(const QString &name, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Residue residue(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Residue residue(const ResID &resid, + Chain chain(const ChainID &chainid, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Chain chain(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Chain chain(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Chain chain(const ChainID &chainid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Segment segment(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Segment segment(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Segment segment(const SegID &segid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Segment segment(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Segment segment(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Segment segment(const SegID &segid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + CutGroup cutGroup(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + CutGroup cutGroup(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + CutGroup cutGroup(const CGID &cgid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - CutGroup cutGroup(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - CutGroup cutGroup(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - CutGroup cutGroup(const CGID &cgid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - - SelectorM atoms() const; - SelectorM atoms(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const AtomID &atomid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM residues() const; - SelectorM residues(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const ResID &resid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM chains() const; - SelectorM chains(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const ChainID &chainid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM segments() const; - SelectorM segments(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const SegID &segid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM cutGroups() const; - SelectorM cutGroups(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const CGID &cgid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectResult search(const QString &search_string) const; - SelectResult search(const QString &search_string, - const SireBase::PropertyMap &map) const; - - QList IDs() const; - QList indexes() const; - QList numbers() const; - QList names() const; - - int nAtoms() const; - int nResidues() const; - int nChains() const; - int nSegments() const; - int nCutGroups() const; - int nMolecules() const; - - bool isEmpty() const; - - int nFrames() const; - int nFrames(const SireBase::PropertyMap &map) const; - - void loadFrame(int frame); - void saveFrame(int frame); - void saveFrame(); - void deleteFrame(int frame); - - void loadFrame(int frame, const SireBase::PropertyMap &map); - void saveFrame(int frame, const SireBase::PropertyMap &map); - void saveFrame(const SireBase::PropertyMap &map); - void deleteFrame(int frame, const SireBase::PropertyMap &map); - - const_iterator begin() const; - const_iterator end() const; - - const_iterator constBegin() const; - const_iterator constEnd() const; - - virtual QString toString() const; - -protected: - void _append(const T &view); - - /** The actual views */ - QList< Selector > vws; -}; + SelectorM atoms() const; + SelectorM atoms(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const AtomID &atomid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM residues() const; + SelectorM residues(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const ResID &resid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM chains() const; + SelectorM chains(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const ChainID &chainid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM segments() const; + SelectorM segments(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const SegID &segid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM cutGroups() const; + SelectorM cutGroups(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const CGID &cgid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectResult search(const QString &search_string) const; + SelectResult search(const QString &search_string, + const SireBase::PropertyMap &map) const; + + QList IDs() const; + QList indexes() const; + QList numbers() const; + QList names() const; + + int nAtoms() const; + int nResidues() const; + int nChains() const; + int nSegments() const; + int nCutGroups() const; + int nMolecules() const; + + bool isEmpty() const; + + int nFrames() const; + int nFrames(const SireBase::PropertyMap &map) const; + + void loadFrame(int frame); + void saveFrame(int frame); + void saveFrame(); + void deleteFrame(int frame); + + void loadFrame(int frame, const SireBase::PropertyMap &map); + void saveFrame(int frame, const SireBase::PropertyMap &map); + void saveFrame(const SireBase::PropertyMap &map); + void deleteFrame(int frame, const SireBase::PropertyMap &map); + + const_iterator begin() const; + const_iterator end() const; + + const_iterator constBegin() const; + const_iterator constEnd() const; + + virtual QString toString() const; + + protected: + void _append(const T &view); + + /** The actual views */ + QList> vws; + }; #ifndef SIRE_SKIP_INLINE_FUNCTIONS #ifndef GCCXML_PARSE -namespace detail -{ - -template -SIRE_OUTOFLINE_TEMPLATE -bool _usesParallel(const QList vws, const SireBase::PropertyMap &map) -{ - if (vws.count() < 16) - return false; - - else if (map["parallel"].hasValue()) + namespace detail { - return map["parallel"].value().asA().value(); - } - - return true; -} - -template -SIRE_OUTOFLINE_TEMPLATE -int _nFrames(const QList &vws, const SireBase::PropertyMap &map) -{ - int nframes = std::numeric_limits::max(); - if (_usesParallel(vws, map)) - { - nframes = tbb::parallel_reduce( tbb::blocked_range(0, vws.count()), - std::numeric_limits::max(), - [&](tbb::blocked_range r, int my_nframes) + template + SIRE_OUTOFLINE_TEMPLATE bool _usesParallel(const QList vws, const SireBase::PropertyMap &map) { - for (int i=r.begin(); i().value(); } - return my_nframes; + return true; + } - }, [](int a, int b){ return std::min(a, b);}); - } - else - { - for (const auto &view : vws) + template + SIRE_OUTOFLINE_TEMPLATE int _nFrames(const QList &vws, const SireBase::PropertyMap &map) { - nframes = std::min(nframes, view.nFrames(map)); + int nframes = std::numeric_limits::max(); - if (nframes == 0) - break; - } - } + if (_usesParallel(vws, map)) + { + nframes = tbb::parallel_reduce( + tbb::blocked_range(0, vws.count()), + std::numeric_limits::max(), + [&](tbb::blocked_range r, int my_nframes) + { + for (int i = r.begin(); i < r.end(); ++i) + { + my_nframes = std::min(my_nframes, vws.at(i).nFrames(map)); + } + + return my_nframes; + }, + [](int a, int b) + { return std::min(a, b); }); + } + else + { + for (const auto &view : vws) + { + nframes = std::min(nframes, view.nFrames(map)); - return nframes; -} + if (nframes == 0) + break; + } + } -template -SIRE_OUTOFLINE_TEMPLATE -void _loadFrame(QList &vws, int frame, const SireBase::PropertyMap &map) -{ - const int nframes = _nFrames(vws, map); + return nframes; + } - if (not (nframes == 0 and frame == 0)) - frame = SireID::Index(frame).map(nframes); + template + SIRE_OUTOFLINE_TEMPLATE void _loadFrame(QList &vws, int frame, const SireBase::PropertyMap &map) + { + const int nframes = _nFrames(vws, map); - vws.detach(); - const int n = vws.count(); + if (not(nframes == 0 and frame == 0)) + frame = SireID::Index(frame).map(nframes); - if (_usesParallel(vws, map)) - { - tbb::parallel_for(tbb::blocked_range(0, n), - [&](tbb::blocked_range r) - { - for (int i=r.begin(); i(0, n), + [&](tbb::blocked_range r) + { + for (int i = r.begin(); i < r.end(); ++i) + { + vws[i].loadFrame(frame, map); + } + }); + } + else + { + for (int i = 0; i < n; ++i) + { + vws[i].loadFrame(frame, map); + } } - }); - } - else - { - for (int i=0; i -SIRE_OUTOFLINE_TEMPLATE -void _saveFrame(QList &vws, int frame, const SireBase::PropertyMap &map) -{ - frame = SireID::Index(frame).map(_nFrames(vws, map)); + template + SIRE_OUTOFLINE_TEMPLATE void _saveFrame(QList &vws, int frame, const SireBase::PropertyMap &map) + { + frame = SireID::Index(frame).map(_nFrames(vws, map)); - vws.detach(); - const int n = vws.count(); + vws.detach(); + const int n = vws.count(); - if (_usesParallel(vws, map)) - { - tbb::parallel_for(tbb::blocked_range(0, n), - [&](tbb::blocked_range r) - { - for (int i=r.begin(); i(0, n), + [&](tbb::blocked_range r) + { + for (int i = r.begin(); i < r.end(); ++i) + { + vws[i].saveFrame(frame, map); + } + }); + } + else + { + for (int i = 0; i < n; ++i) + { + vws[i].saveFrame(frame, map); + } } - }); - } - else - { - for (int i=0; i -SIRE_OUTOFLINE_TEMPLATE -void _saveFrame(QList &vws, const SireBase::PropertyMap &map) -{ - vws.detach(); - const int n = vws.count(); - if (_usesParallel(vws, map)) - { - tbb::parallel_for(tbb::blocked_range(0, n), - [&](tbb::blocked_range r) + template + SIRE_OUTOFLINE_TEMPLATE void _saveFrame(QList &vws, const SireBase::PropertyMap &map) { - for (int i=r.begin(); i(0, n), + [&](tbb::blocked_range r) + { + for (int i = r.begin(); i < r.end(); ++i) + { + vws[i].saveFrame(map); + } + }); + } + else + { + for (int i = 0; i < n; ++i) + { + vws[i].saveFrame(map); + } } - }); - } - else - { - for (int i=0; i -SIRE_OUTOFLINE_TEMPLATE -void _deleteFrame(QList &vws, int frame, const SireBase::PropertyMap &map) -{ - frame = SireID::Index(frame).map(_nFrames(vws, map)); + template + SIRE_OUTOFLINE_TEMPLATE void _deleteFrame(QList &vws, int frame, const SireBase::PropertyMap &map) + { + frame = SireID::Index(frame).map(_nFrames(vws, map)); - vws.detach(); - const int n = vws.count(); + vws.detach(); + const int n = vws.count(); - if (_usesParallel(vws, map)) - { - tbb::parallel_for(tbb::blocked_range(0, n), - [&](tbb::blocked_range r) - { - for (int i=r.begin(); i(0, n), + [&](tbb::blocked_range r) + { + for (int i = r.begin(); i < r.end(); ++i) + { + vws[i].deleteFrame(frame, map); + } + }); + } + else + { + for (int i = 0; i < n; ++i) + { + vws[i].deleteFrame(frame, map); + } } - }); - } - else - { - for (int i=0; i -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM() - : SireBase::ConcreteProperty,SireBase::Property>() -{} - -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const T &view) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - this->vws.append(Selector(view)); -} - -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const Selector &views) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - if (not views.isEmpty()) - this->vws.append(views); -} - -template -struct _get_view -{ - template - static int count(const C &mols) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM() + : SireBase::ConcreteProperty, SireBase::Property>() { - return mols.nAtoms(); } - template - static T at(const C &mols, int idx) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const T &view) + : SireBase::ConcreteProperty, SireBase::Property>() { - return mols.atom(idx); + this->vws.append(Selector(view)); } - template - static Selector get(const C &view) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const Selector &views) + : SireBase::ConcreteProperty, SireBase::Property>() { - if (view.template isA< Selector >()) - return view.template asA< Selector >(); - else - return view.atoms(); + if (not views.isEmpty()) + this->vws.append(views); } - static SelectorM getName(const SelectorM &view, const QString &name) + template + struct _get_view { - return view.atoms(name); - } + template + static int count(const C &mols) + { + return mols.nAtoms(); + } - static SelectorM getID(const SelectorM &view, - const typename T::ID &id) - { - return view.atoms(id); - } + template + static T at(const C &mols, int idx) + { + return mols.atom(idx); + } - template - static Selector get(const C &view, const ID &id) - { - return view.atoms(id); - } + template + static Selector get(const C &view) + { + if (view.template isA>()) + return view.template asA>(); + else + return view.atoms(); + } - static void raise_duplicate(const QString &id, int n) - { - throw SireMol::duplicate_atom(QObject::tr( - "Multiple atoms matched %1. Number of matches is %2.") - .arg(id).arg(n), CODELOC); - } + static SelectorM getName(const SelectorM &view, const QString &name) + { + return view.atoms(name); + } - static void raise_missing(const QString &id) - { - throw SireMol::missing_atom(QObject::tr( - "No atom matches %1.").arg(id), CODELOC); - } -}; + static SelectorM getID(const SelectorM &view, + const typename T::ID &id) + { + return view.atoms(id); + } -template<> -struct _get_view -{ - template - static int count(const C &mols) - { - return mols.nResidues(); - } + template + static Selector get(const C &view, const ID &id) + { + return view.atoms(id); + } - template - static Residue at(const C &mols, int idx) - { - return mols.residue(idx); - } + static void raise_duplicate(const QString &id, int n) + { + throw SireMol::duplicate_atom(QObject::tr( + "Multiple atoms matched %1. Number of matches is %2.") + .arg(id) + .arg(n), + CODELOC); + } - static SelectorM getName(const SelectorM &view, - const QString &name) - { - return view.residues(name); - } + static void raise_missing(const QString &id) + { + throw SireMol::missing_atom(QObject::tr( + "No atom matches %1.") + .arg(id), + CODELOC); + } + }; - static SelectorM getID(const SelectorM &view, - const Residue::ID &id) + template <> + struct _get_view { - return view.residues(id); - } + template + static int count(const C &mols) + { + return mols.nResidues(); + } - template - static Selector get(const C &view) - { - if (view.template isA< Selector >()) - return view.template asA< Selector >(); - else - return view.residues(); - } + template + static Residue at(const C &mols, int idx) + { + return mols.residue(idx); + } - template - static Selector get(const C &view, const ID &id) - { - return view.residues(id); - } + static SelectorM getName(const SelectorM &view, + const QString &name) + { + return view.residues(name); + } - static void raise_duplicate(const QString &id, int n) - { - throw SireMol::duplicate_residue(QObject::tr( - "Multiple residues matched %1. Number of matches is %2.") - .arg(id).arg(n), CODELOC); - } + static SelectorM getID(const SelectorM &view, + const Residue::ID &id) + { + return view.residues(id); + } - static void raise_missing(const QString &id) - { - throw SireMol::missing_residue(QObject::tr( - "No residue matches %1.").arg(id), CODELOC); - } -}; + template + static Selector get(const C &view) + { + if (view.template isA>()) + return view.template asA>(); + else + return view.residues(); + } -template<> -struct _get_view -{ - template - static int count(const C &mols) - { - return mols.nChains(); - } + template + static Selector get(const C &view, const ID &id) + { + return view.residues(id); + } - template - static Chain at(const C &mols, int idx) - { - return mols.chain(idx); - } + static void raise_duplicate(const QString &id, int n) + { + throw SireMol::duplicate_residue(QObject::tr( + "Multiple residues matched %1. Number of matches is %2.") + .arg(id) + .arg(n), + CODELOC); + } - static SelectorM getName(const SelectorM &view, - const QString &name) - { - return view.chains(name); - } + static void raise_missing(const QString &id) + { + throw SireMol::missing_residue(QObject::tr( + "No residue matches %1.") + .arg(id), + CODELOC); + } + }; - static SelectorM getID(const SelectorM &view, - const Chain::ID &id) + template <> + struct _get_view { - return view.chains(id); - } + template + static int count(const C &mols) + { + return mols.nChains(); + } - template - static Selector get(const C &view) - { - if (view.template isA< Selector >()) - return view.template asA< Selector >(); - else - return view.chains(); - } + template + static Chain at(const C &mols, int idx) + { + return mols.chain(idx); + } - template - static Selector get(const C &view, const ID &id) - { - return view.chains(id); - } + static SelectorM getName(const SelectorM &view, + const QString &name) + { + return view.chains(name); + } - static void raise_duplicate(const QString &id, int n) - { - throw SireMol::duplicate_chain(QObject::tr( - "Multiple chains matched %1. Number of matches is %2.") - .arg(id).arg(n), CODELOC); - } + static SelectorM getID(const SelectorM &view, + const Chain::ID &id) + { + return view.chains(id); + } - static void raise_missing(const QString &id) - { - throw SireMol::missing_chain(QObject::tr( - "No chain matches %1.").arg(id), CODELOC); - } -}; + template + static Selector get(const C &view) + { + if (view.template isA>()) + return view.template asA>(); + else + return view.chains(); + } -template<> -struct _get_view -{ - template - static int count(const C &mols) - { - return mols.nCutGroups(); - } + template + static Selector get(const C &view, const ID &id) + { + return view.chains(id); + } - template - static CutGroup at(const C &mols, int idx) - { - return mols.cutGroup(idx); - } + static void raise_duplicate(const QString &id, int n) + { + throw SireMol::duplicate_chain(QObject::tr( + "Multiple chains matched %1. Number of matches is %2.") + .arg(id) + .arg(n), + CODELOC); + } - static SelectorM getName(const SelectorM &view, - const QString &name) - { - return view.cutGroup(name); - } + static void raise_missing(const QString &id) + { + throw SireMol::missing_chain(QObject::tr( + "No chain matches %1.") + .arg(id), + CODELOC); + } + }; - static SelectorM getID(const SelectorM &view, - const CutGroup::ID &id) + template <> + struct _get_view { - return view.cutGroups(id); - } + template + static int count(const C &mols) + { + return mols.nCutGroups(); + } - template - static Selector get(const C &view) - { - if (view.template isA< Selector >()) - return view.template asA< Selector >(); - else - return view.cutGroups(); - } + template + static CutGroup at(const C &mols, int idx) + { + return mols.cutGroup(idx); + } - template - static Selector get(const C &view, const ID &id) - { - return view.cutGroups(id); - } + static SelectorM getName(const SelectorM &view, + const QString &name) + { + return view.cutGroup(name); + } - static void raise_duplicate(const QString &id, int n) - { - throw SireMol::duplicate_cutgroup(QObject::tr( - "Multiple CutGroups matched %1. Number of matches is %2.") - .arg(id).arg(n), CODELOC); - } + static SelectorM getID(const SelectorM &view, + const CutGroup::ID &id) + { + return view.cutGroups(id); + } - static void raise_missing(const QString &id) - { - throw SireMol::missing_cutgroup(QObject::tr( - "No CutGroup matches %1.").arg(id), CODELOC); - } -}; + template + static Selector get(const C &view) + { + if (view.template isA>()) + return view.template asA>(); + else + return view.cutGroups(); + } -template<> -struct _get_view -{ - template - static int count(const C &mols) - { - return mols.nSegments(); - } + template + static Selector get(const C &view, const ID &id) + { + return view.cutGroups(id); + } - template - static Segment at(const C &mols, int idx) - { - return mols.segment(idx); - } + static void raise_duplicate(const QString &id, int n) + { + throw SireMol::duplicate_cutgroup(QObject::tr( + "Multiple CutGroups matched %1. Number of matches is %2.") + .arg(id) + .arg(n), + CODELOC); + } - static SelectorM getName(const SelectorM &view, - const QString &name) - { - return view.segments(name); - } + static void raise_missing(const QString &id) + { + throw SireMol::missing_cutgroup(QObject::tr( + "No CutGroup matches %1.") + .arg(id), + CODELOC); + } + }; - static SelectorM getID(const SelectorM &view, - const Segment::ID &id) + template <> + struct _get_view { - return view.segments(id); - } + template + static int count(const C &mols) + { + return mols.nSegments(); + } - template - static Selector get(const C &view) - { - if (view.template isA< Selector >()) - return view.template asA< Selector >(); - else - return view.segments(); - } + template + static Segment at(const C &mols, int idx) + { + return mols.segment(idx); + } - template - static Selector get(const C &view, const ID &id) - { - return view.segments(id); - } + static SelectorM getName(const SelectorM &view, + const QString &name) + { + return view.segments(name); + } - static void raise_duplicate(const QString &id, int n) - { - throw SireMol::duplicate_segment(QObject::tr( - "Multiple segments matched %1. Number of matches is %2.") - .arg(id).arg(n), CODELOC); - } + static SelectorM getID(const SelectorM &view, + const Segment::ID &id) + { + return view.segments(id); + } - static void raise_missing(const QString &id) - { - throw SireMol::missing_segment(QObject::tr( - "No segment matches %1.").arg(id), CODELOC); - } -}; + template + static Selector get(const C &view) + { + if (view.template isA>()) + return view.template asA>(); + else + return view.segments(); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorMol &mols) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &mol : mols) - { - this->vws += _get_view::get(mol); - } -} + template + static Selector get(const C &view, const ID &id) + { + return view.segments(id); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::_append(const T &view) -{ - if (this->vws.isEmpty()) - { - this->vws.append(Selector(view)); - } - else if (this->vws.last().data().number() != view.data().number()) + static void raise_duplicate(const QString &id, int n) + { + throw SireMol::duplicate_segment(QObject::tr( + "Multiple segments matched %1. Number of matches is %2.") + .arg(id) + .arg(n), + CODELOC); + } + + static void raise_missing(const QString &id) + { + throw SireMol::missing_segment(QObject::tr( + "No segment matches %1.") + .arg(id), + CODELOC); + } + }; + + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorMol &mols) + : SireBase::ConcreteProperty, SireBase::Property>() { - // new molecule - this->vws.append(Selector(view)); + for (const auto &mol : mols) + { + this->vws += _get_view::get(mol); + } } - else + + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::_append(const T &view) { - // a new view in the current molecule - this->vws.last() = this->vws.last().add(view); + if (this->vws.isEmpty()) + { + this->vws.append(Selector(view)); + } + else if (this->vws.last().data().number() != view.data().number()) + { + // new molecule + this->vws.append(Selector(view)); + } + else + { + // a new view in the current molecule + this->vws.last() = this->vws.last().add(view); + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const Molecules &molecules) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - if (not molecules.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const Molecules &molecules) + : SireBase::ConcreteProperty, SireBase::Property>() { - auto toList = [](const QSet &molnums) + if (not molecules.isEmpty()) { - //return QList(molnums.constBegin(), molnums.constEnd()); - return molnums.values(); - }; + auto toList = [](const QSet &molnums) + { + // return QList(molnums.constBegin(), molnums.constEnd()); + return molnums.values(); + }; - auto molnums = toList(molecules.molNums()); + auto molnums = toList(molecules.molNums()); - //sort them, as this is also likely the order the molecules - //were read in from a file, and so more likely to be the - //order the user would expect - std::sort(molnums.begin(), molnums.end()); + // sort them, as this is also likely the order the molecules + // were read in from a file, and so more likely to be the + // order the user would expect + std::sort(molnums.begin(), molnums.end()); - this->vws.reserve(molnums.count()); + this->vws.reserve(molnums.count()); - for (const auto &molnum : molnums) - { - this->vws.append(_get_view::get(molecules.at(molnum))); + for (const auto &molnum : molnums) + { + this->vws.append(_get_view::get(molecules.at(molnum))); + } } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const MoleculeGroup &molecules) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - if (not molecules.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const MoleculeGroup &molecules) + : SireBase::ConcreteProperty, SireBase::Property>() { - const auto molnums = molecules.molNums(); - this->vws.reserve(molnums.count()); - - for (const auto &molnum : molnums) + if (not molecules.isEmpty()) { - this->vws.append(_get_view::get(molecules.at(molnum))); + const auto molnums = molecules.molNums(); + this->vws.reserve(molnums.count()); + + for (const auto &molnum : molnums) + { + this->vws.append(_get_view::get(molecules.at(molnum))); + } } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const MolGroupsBase &molecules) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - if (not molecules.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const MolGroupsBase &molecules) + : SireBase::ConcreteProperty, SireBase::Property>() { - const auto molnums = molecules.molNums(); - this->vws.reserve(molnums.count()); - - for (const auto &molnum : molnums) + if (not molecules.isEmpty()) { - this->vws.append(_get_view::get(molecules.at(molnum))); + const auto molnums = molecules.molNums(); + this->vws.reserve(molnums.count()); + + for (const auto &molnum : molnums) + { + this->vws.append(_get_view::get(molecules.at(molnum))); + } } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectResult &molecules) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - if (not molecules.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectResult &molecules) + : SireBase::ConcreteProperty, SireBase::Property>() { - this->vws.reserve(molecules.count()); - - for (const auto &mol : molecules) + if (not molecules.isEmpty()) { - this->vws.append(_get_view::get(*mol)); - } - } -} + this->vws.reserve(molecules.count()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorMol &mols, const SireBase::Slice &slice) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (auto it = slice.begin(_get_view::count(mols)); - not it.atEnd(); it.next()) - { - this->_append(_get_view::at(mols, it.value())); + for (const auto &mol : molecules) + { + this->vws.append(_get_view::get(*mol)); + } + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorMol &mols, const QList &idxs) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &idx : idxs) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorMol &mols, const SireBase::Slice &slice) + : SireBase::ConcreteProperty, SireBase::Property>() { - this->_append(_get_view::at(mols, idx)); + for (auto it = slice.begin(_get_view::count(mols)); + not it.atEnd(); it.next()) + { + this->_append(_get_view::at(mols, it.value())); + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorMol &mols, const QString &name, - const SireBase::PropertyMap &map) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &mol : mols) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorMol &mols, const QList &idxs) + : SireBase::ConcreteProperty, SireBase::Property>() { - auto flag = SireError::exception::enableFastExceptions(); - - try + for (const auto &idx : idxs) { - this->vws.append(_get_view::get(mol, typename T::Name(name))); + this->_append(_get_view::at(mols, idx)); } - catch(...) - {} } - if (this->vws.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorMol &mols, const QString &name, + const SireBase::PropertyMap &map) + : SireBase::ConcreteProperty, SireBase::Property>() { - // try a search - try + for (const auto &mol : mols) { - this->operator=(SelectorM(mols.search(name, map))); + auto flag = SireError::exception::enableFastExceptions(); + + try + { + this->vws.append(_get_view::get(mol, typename T::Name(name))); + } + catch (...) + { + } } - catch(...) + + if (this->vws.isEmpty()) { - if (name.length() < 5) - //likely a name error - _get_view::raise_missing(name); - else - //likely a syntax error - throw; + // try a search + try + { + this->operator=(SelectorM(mols.search(name, map))); + } + catch (...) + { + if (name.length() < 5) + // likely a name error + _get_view::raise_missing(name); + else + // likely a syntax error + throw; + } } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorMol &mols, const typename T::ID &id) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &mol : mols) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorMol &mols, const typename T::ID &id) + : SireBase::ConcreteProperty, SireBase::Property>() { - auto flag = SireError::exception::enableFastExceptions(); - - try + for (const auto &mol : mols) { - this->vws.append(_get_view::get(mol, id)); - } - catch(...) - {} - } + auto flag = SireError::exception::enableFastExceptions(); - if (this->vws.isEmpty()) - _get_view::raise_missing(id.toString()); -} + try + { + this->vws.append(_get_view::get(mol, id)); + } + catch (...) + { + } + } -template -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorM &other) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &o : other) - { - this->vws.append(_get_view::get(o)); + if (this->vws.isEmpty()) + _get_view::raise_missing(id.toString()); } -} -template -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorM &other, const SireBase::Slice &slice) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (auto it = slice.begin(_get_view::count(other)); - not it.atEnd(); it.next()) + template + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorM &other) + : SireBase::ConcreteProperty, SireBase::Property>() { - this->_append(_get_view::at(other, it.value())); + for (const auto &o : other) + { + this->vws.append(_get_view::get(o)); + } } -} -template -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorM &other, const QList &idxs) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &idx : idxs) + template + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorM &other, const SireBase::Slice &slice) + : SireBase::ConcreteProperty, SireBase::Property>() { - this->_append(_get_view::at(other, idx)); + for (auto it = slice.begin(_get_view::count(other)); + not it.atEnd(); it.next()) + { + this->_append(_get_view::at(other, it.value())); + } } -} -template -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorM &other, const QString &name) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &view : other) + template + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorM &other, const QList &idxs) + : SireBase::ConcreteProperty, SireBase::Property>() { - auto flag = SireError::exception::enableFastExceptions(); - - try + for (const auto &idx : idxs) { - this->vws.append(_get_view::get(view, name)); + this->_append(_get_view::at(other, idx)); } - catch(...) - {} } - if (this->vws.isEmpty()) + template + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorM &other, const QString &name) + : SireBase::ConcreteProperty, SireBase::Property>() { - // try a search - try + for (const auto &view : other) { - this->operator=(SelectorM(other.search(name))); + auto flag = SireError::exception::enableFastExceptions(); + + try + { + this->vws.append(_get_view::get(view, name)); + } + catch (...) + { + } } - catch(...) + + if (this->vws.isEmpty()) { - if (name.length() < 5) - //likely a name error - _get_view::raise_missing(name); - else - //likely a syntax error - throw; + // try a search + try + { + this->operator=(SelectorM(other.search(name))); + } + catch (...) + { + if (name.length() < 5) + // likely a name error + _get_view::raise_missing(name); + else + // likely a syntax error + throw; + } } } -} -template -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorM &other, const typename T::ID &id) - : SireBase::ConcreteProperty,SireBase::Property>() -{ - for (const auto &view : other) + template + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorM &other, const typename T::ID &id) + : SireBase::ConcreteProperty, SireBase::Property>() { - auto flag = SireError::exception::enableFastExceptions(); - - try + for (const auto &view : other) { - this->vws.append(_get_view::get(view, id)); - } - catch(...) - {} - } + auto flag = SireError::exception::enableFastExceptions(); - if (this->vws.isEmpty()) - _get_view::raise_missing(id.toString()); -} + try + { + this->vws.append(_get_view::get(view, id)); + } + catch (...) + { + } + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::SelectorM(const SelectorM &other) - : SireBase::ConcreteProperty,SireBase::Property>(), - vws(other.vws) -{} - -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM::~SelectorM() -{} - -template -SIRE_OUTOFLINE_TEMPLATE -const char* SelectorM::typeName() -{ - return QMetaType::typeName( qMetaTypeId< SelectorM >() ); -} + if (this->vws.isEmpty()) + _get_view::raise_missing(id.toString()); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM& SelectorM::operator=(const SelectorM &other) -{ - if (this != &other) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::SelectorM(const SelectorM &other) + : SireBase::ConcreteProperty, SireBase::Property>(), + vws(other.vws) { - this->vws = other.vws; - Property::operator=(other); } - return *this; -} - -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::operator==(const SelectorM &other) const -{ - return vws == other.vws; -} - -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::operator!=(const SelectorM &other) const -{ - return not this->operator==(other); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM::~SelectorM() + { + } -template -SIRE_OUTOFLINE_TEMPLATE -T SelectorM::operator[](int i) const -{ - i = SireID::Index(i).map(this->count()); + template + SIRE_OUTOFLINE_TEMPLATE const char *SelectorM::typeName() + { + return QMetaType::typeName(qMetaTypeId>()); + } - for (const auto &v : vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM & + SelectorM::operator=(const SelectorM &other) { - if (i < v.count()) - { - return v(i); - } - else + if (this != &other) { - i -= v.count(); + this->vws = other.vws; + Property::operator=(other); } + + return *this; } - throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::operator==(const SelectorM &other) const + { + return vws == other.vws; + } - return T(); -} + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::operator!=(const SelectorM &other) const + { + return not this->operator==(other); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::operator[](const SireBase::Slice &slice) const -{ - return SelectorM(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + T + SelectorM::operator[](int i) const + { + i = SireID::Index(i).map(this->count()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::operator[](const QList &idxs) const -{ - return SelectorM(*this,idxs); -} + for (const auto &v : vws) + { + if (i < v.count()) + { + return v(i); + } + else + { + i -= v.count(); + } + } + throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); -template -SIRE_OUTOFLINE_TEMPLATE -T SelectorM::operator[](const QString &name) const -{ - auto all = _get_view::getName(*this, name); + return T(); + } - if (all.count() > 1) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::operator[](const SireBase::Slice &slice) const { - _get_view::raise_duplicate(name, all.count()); + return SelectorM(*this, slice); } - BOOST_ASSERT( not all.isEmpty() ); - - return all(0); -} - -template -SIRE_OUTOFLINE_TEMPLATE -T SelectorM::operator[](const typename T::ID &id) const -{ - auto all = _get_view::getID(*this, id); - - if (all.count() > 1) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::operator[](const QList &idxs) const { - _get_view::raise_duplicate(id.toString(), all.count()); + return SelectorM(*this, idxs); } - BOOST_ASSERT( not all.isEmpty() ); - - return all(0); -} - -template -SIRE_OUTOFLINE_TEMPLATE -T SelectorM::operator()(int i) const -{ - return this->operator[](i); -} + template + SIRE_OUTOFLINE_TEMPLATE + T + SelectorM::operator[](const QString &name) const + { + auto all = _get_view::getName(*this, name); -template -SIRE_OUTOFLINE_TEMPLATE -T SelectorM::operator()(const QString &name) const -{ - return this->operator[](name); -} + if (all.count() > 1) + { + _get_view::raise_duplicate(name, all.count()); + } -template -SIRE_OUTOFLINE_TEMPLATE -T SelectorM::operator()(const typename T::ID &id) const -{ - return this->operator[](id); -} + BOOST_ASSERT(not all.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -QList SelectorM::toList() const -{ - QList l; - l.reserve(vws.count()); + return all(0); + } - for (const auto &v : vws) + template + SIRE_OUTOFLINE_TEMPLATE + T + SelectorM::operator[](const typename T::ID &id) const { - l.append(MolViewPtr(v.clone())); - } + auto all = _get_view::getID(*this, id); - return l; -} + if (all.count() > 1) + { + _get_view::raise_duplicate(id.toString(), all.count()); + } -template -SIRE_OUTOFLINE_TEMPLATE -Molecules SelectorM::toMolecules() const -{ - return Molecules(this->vws); -} + BOOST_ASSERT(not all.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectResult SelectorM::toSelectResult() const -{ - return SelectResult(this->vws); -} + return all(0); + } -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::isSelector() const -{ - return true; -} + template + SIRE_OUTOFLINE_TEMPLATE + T + SelectorM::operator()(int i) const + { + return this->operator[](i); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::add(const SelectorM &other) const -{ - SelectorM ret(*this); + template + SIRE_OUTOFLINE_TEMPLATE + T + SelectorM::operator()(const QString &name) const + { + return this->operator[](name); + } - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE + T + SelectorM::operator()(const typename T::ID &id) const { - ret._append(other(i)); + return this->operator[](id); } - return ret; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::toList() const + { + QList l; + l.reserve(vws.count()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::add(const Selector &other) const -{ - SelectorM ret(*this); + for (const auto &v : vws) + { + l.append(MolViewPtr(v.clone())); + } - for (int i=0; i -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::add(const T &other) const -{ - SelectorM ret(*this); - ret._append(other); - return ret; -} + template + SIRE_OUTOFLINE_TEMPLATE + Molecules + SelectorM::toMolecules() const + { + return Molecules(this->vws); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::subtract(const SelectorM &other) const -{ - SelectorM ret; + template + SIRE_OUTOFLINE_TEMPLATE + SelectResult + SelectorM::toSelectResult() const + { + return SelectResult(this->vws); + } - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::find(const T &view) const { - auto result = view; + QList matches; + + qint64 start = 0; - for (const auto &other_view : other.vws) + for (const auto &vw : vws) { - if (result.data().number() == other_view.data().number()) + const auto m = vw.find(view); + + if (m.isEmpty()) + { + start += vw.count(); + } + else { - result = result.subtract(other_view); + matches.append(start + m[0]); + break; } } - if (not result.isEmpty()) - ret.vws.append(result); + return matches; } - return ret; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::find(const Selector &views) const + { + QList matches; -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::subtract(const Selector &other) const -{ - SelectorM ret; + qint64 start = 0; - for (const auto &view : this->vws) - { - if (view.data().number() == other.data().number()) + for (const auto &vw : vws) { - auto result = view.subtract(other); + const auto m = vw.find(views); - if (not result.isEmpty()) - ret.vws.append(result); + if (m.isEmpty()) + { + start += vw.count(); + } + else + { + for (auto match : m) + { + matches.append(start + match); + } + + if (matches.count() == views.count()) + break; + else + start += vw.count(); + } } - else - ret.vws.append(view); + + return matches; } - return ret; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::find(const SelectorM &views) const + { + QList matches; -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::subtract(const T &other) const -{ - SelectorM ret; + qint64 start = 0; - for (const auto &view : this->vws) - { - if (view.data().number() == other.data().number()) + for (const auto &view : views) { - auto result = view.subtract(other); + const auto m = this->find(view); - if (not result.isEmpty()) - ret.vws.append(result); + if (not m.isEmpty()) + { + matches += m; + } } - else - ret.vws.append(view); + + return matches; } - return ret; -} + template + QList + Selector::find(const SelectorM &views) const + { + return SelectorM(*this).find(views); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::intersection(const SelectorM &other) const -{ - SelectorM ret; + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::isSelector() const + { + return true; + } - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::add(const SelectorM &other) const { - for (const auto &other_view : other.vws) - { - if (view.data().number() == other_view.data().number()) - { - auto intersect = view.intersection(other_view); + SelectorM ret(*this); - if (not intersect.isEmpty()) - { - ret.vws.append(intersect); - } - } + for (int i = 0; i < other.count(); ++i) + { + ret._append(other(i)); } + + return ret; } - return ret; -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::add(const Selector &other) const + { + SelectorM ret(*this); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::intersection(const Selector &views) const -{ - SelectorM ret; + for (int i = 0; i < other.count(); ++i) + { + ret._append(other(i)); + } + + return ret; + } + + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::add(const T &other) const + { + SelectorM ret(*this); + ret._append(other); + return ret; + } - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::subtract(const SelectorM &other) const { - if (view.data().number() == view.data().number()) + SelectorM ret; + + for (const auto &view : this->vws) { - auto intersect = view.intersection(views); + auto result = view; - if (not intersect.isEmpty()) + for (const auto &other_view : other.vws) { - ret.vws.append(intersect); + if (result.data().number() == other_view.data().number()) + { + result = result.subtract(other_view); + } } + + if (not result.isEmpty()) + ret.vws.append(result); } - } - return ret; -} + return ret; + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::intersection(const T &view) const -{ - if (this->contains(view)) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::subtract(const Selector &other) const { - return SelectorM(view); - } - else - return SelectorM(); -} + SelectorM ret; -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::invert() const -{ - SelectorM ret; + for (const auto &view : this->vws) + { + if (view.data().number() == other.data().number()) + { + auto result = view.subtract(other); + + if (not result.isEmpty()) + ret.vws.append(result); + } + else + ret.vws.append(view); + } + + return ret; + } - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::subtract(const T &other) const { - auto inverted = view.invert(); + SelectorM ret; - if (not inverted.isEmpty()) + for (const auto &view : this->vws) { - ret.vws.append(inverted); + if (view.data().number() == other.data().number()) + { + auto result = view.subtract(other); + + if (not result.isEmpty()) + ret.vws.append(result); + } + else + ret.vws.append(view); } - } - return ret; -} + return ret; + } -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::intersects(const SelectorM &other) const -{ - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::intersection(const SelectorM &other) const { - if (this->contains(other(i))) + SelectorM ret; + + for (const auto &view : this->vws) { - return true; + for (const auto &other_view : other.vws) + { + if (view.data().number() == other_view.data().number()) + { + auto intersect = view.intersection(other_view); + + if (not intersect.isEmpty()) + { + ret.vws.append(intersect); + } + } + } } + + return ret; } - return false; -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::intersection(const Selector &views) const + { + SelectorM ret; -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::intersects(const Selector &other) const -{ - for (int i=0; ivws) + { + if (view.data().number() == view.data().number()) + { + auto intersect = view.intersection(views); + + if (not intersect.isEmpty()) + { + ret.vws.append(intersect); + } + } + } + + return ret; + } + + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::intersection(const T &view) const { - if (this->contains(other(i))) + if (this->contains(view)) { - return true; + return SelectorM(view); } + else + return SelectorM(); } - return false; -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::invert() const + { + SelectorM ret; -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::intersects(const T &view) const -{ - return this->contains(view); -} + for (const auto &view : this->vws) + { + auto inverted = view.invert(); -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::contains(const SelectorM &other) const -{ - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::intersects(const SelectorM &other) const { - if (not this->contains(other(i))) + for (int i = 0; i < other.count(); ++i) { - return false; + if (this->contains(other(i))) + { + return true; + } } - } - return true; -} + return false; + } -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::contains(const Selector &other) const -{ - for (int i=0; i + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::intersects(const Selector &other) const { - if (not this->contains(other(i))) + for (int i = 0; i < other.count(); ++i) { - return false; + if (this->contains(other(i))) + { + return true; + } } - } - return true; -} + return false; + } -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::contains(const T &other) const -{ - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::intersects(const T &view) const { - if (view == other) - return true; + return this->contains(view); } - return false; -} + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::contains(const SelectorM &other) const + { + for (int i = 0; i < other.count(); ++i) + { + if (not this->contains(other(i))) + { + return false; + } + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::update(const Molecules &molecules) -{ - // better to create a map from MolNum to index here - QMultiHash molnum_to_idx; - molnum_to_idx.reserve(this->vws.count()); + return true; + } + + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::contains(const Selector &other) const + { + for (int i = 0; i < other.count(); ++i) + { + if (not this->contains(other(i))) + { + return false; + } + } - int i = 0; + return true; + } - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::contains(const T &other) const { - molnum_to_idx.insert(view.data().number(), i); - i += 1; + for (const auto &view : this->vws) + { + if (view == other) + return true; + } + + return false; } - for (const auto &mol : molecules) + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::update(const Molecules &molecules) { - const auto molnum = mol.data().number(); + // better to create a map from MolNum to index here + QMultiHash molnum_to_idx; + molnum_to_idx.reserve(this->vws.count()); - auto it = molnum_to_idx.constFind(molnum); + int i = 0; - while (it != molnum_to_idx.constEnd() && it.key() == molnum) + for (const auto &view : this->vws) { - this->vws[it.value()].update(mol.data()); + molnum_to_idx.insert(view.data().number(), i); + i += 1; } - } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectResult SelectorM::search(const QString &search_term) const -{ - Select search(search_term); - return search(this->toSelectResult()); -} + for (const auto &mol : molecules) + { + const auto molnum = mol.data().number(); -template -SIRE_OUTOFLINE_TEMPLATE -SelectResult SelectorM::search(const QString &search_term, - const SireBase::PropertyMap &map) const -{ - Select search(search_term); - return search(this->toSelectResult(), map); -} + auto it = molnum_to_idx.constFind(molnum); -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::count() const -{ - int n = 0; + while (it != molnum_to_idx.constEnd() && it.key() == molnum) + { + this->vws[it.value()].update(mol.data()); + } + } + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectResult + SelectorM::search(const QString &search_term) const { - n += v.count(); + Select search(search_term); + return search(this->toSelectResult()); } - return n; -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectResult + SelectorM::search(const QString &search_term, + const SireBase::PropertyMap &map) const + { + Select search(search_term); + return search(this->toSelectResult(), map); + } -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::size() const -{ - return this->count(); -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::count() const + { + int n = 0; -template -SIRE_OUTOFLINE_TEMPLATE -MoleculeGroup SelectorM::toMoleculeGroup() const -{ - MoleculeGroup grp; + for (const auto &v : this->vws) + { + n += v.count(); + } + + return n; + } - for (const auto &view : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::size() const { - grp.add(view); + return this->count(); } - return grp; -} + template + SIRE_OUTOFLINE_TEMPLATE + MoleculeGroup + SelectorM::toMoleculeGroup() const + { + MoleculeGroup grp; -template -SIRE_OUTOFLINE_TEMPLATE -Molecule SelectorM::molecule(int i, - const SireBase::PropertyMap&) const -{ - i = SireID::Index(i).map(this->vws.count()); + for (const auto &view : this->vws) + { + grp.add(view); + } - return this->vws.at(i).molecule(); -} + return grp; + } -template -SIRE_OUTOFLINE_TEMPLATE -Molecule SelectorM::molecule(const QString &name, - const SireBase::PropertyMap &map) const -{ - auto mols = this->molecules(name, map); + template + SIRE_OUTOFLINE_TEMPLATE + Molecule + SelectorM::molecule(int i, + const SireBase::PropertyMap &) const + { + i = SireID::Index(i).map(this->vws.count()); - if (mols.count() > 1) - throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches '%1'. Number of matches is %2.") - .arg(name).arg(mols.count()), CODELOC); + return this->vws.at(i).molecule(); + } - BOOST_ASSERT(not mols.isEmpty()); + template + SIRE_OUTOFLINE_TEMPLATE + Molecule + SelectorM::molecule(const QString &name, + const SireBase::PropertyMap &map) const + { + auto mols = this->molecules(name, map); - return mols[0]; -} + if (mols.count() > 1) + throw SireMol::duplicate_molecule(QObject::tr( + "More than one molecule matches '%1'. Number of matches is %2.") + .arg(name) + .arg(mols.count()), + CODELOC); -template -SIRE_OUTOFLINE_TEMPLATE -Molecule SelectorM::molecule(const MolID &molid, - const SireBase::PropertyMap &map) -{ - auto mols = this->molecules(molid, map); + BOOST_ASSERT(not mols.isEmpty()); - if (mols.count() > 1) - throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches '%1'. Number of matches is %2.") - .arg(molid.toString()).arg(mols.count()), CODELOC); + return mols[0]; + } - BOOST_ASSERT(not mols.isEmpty()); + template + SIRE_OUTOFLINE_TEMPLATE + Molecule + SelectorM::molecule(const MolID &molid, + const SireBase::PropertyMap &map) + { + auto mols = this->molecules(molid, map); - return mols[0]; -} + if (mols.count() > 1) + throw SireMol::duplicate_molecule(QObject::tr( + "More than one molecule matches '%1'. Number of matches is %2.") + .arg(molid.toString()) + .arg(mols.count()), + CODELOC); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol SelectorM::molecules() const -{ - return SelectorMol(*this); -} + BOOST_ASSERT(not mols.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol SelectorM::molecules(int i, - const SireBase::PropertyMap &map) const -{ - return SelectorMol(this->molecule(i, map)); -} + return mols[0]; + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol SelectorM::molecules(const SireBase::Slice &slice, - const SireBase::PropertyMap&) const -{ - return SelectorMol(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol + SelectorM::molecules() const + { + return SelectorMol(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol SelectorM::molecules(const QList &idxs, - const SireBase::PropertyMap&) const -{ - return SelectorMol(*this, idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol + SelectorM::molecules(int i, + const SireBase::PropertyMap &map) const + { + return SelectorMol(this->molecule(i, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol SelectorM::molecules(const QString &name, - const SireBase::PropertyMap &map) const -{ - return SelectorMol(*this, name, map); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol + SelectorM::molecules(const SireBase::Slice &slice, + const SireBase::PropertyMap &) const + { + return SelectorMol(*this, slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol SelectorM::molecules(const MolID &molid, - const SireBase::PropertyMap&) const -{ - return SelectorMol(*this, molid); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol + SelectorM::molecules(const QList &idxs, + const SireBase::PropertyMap &) const + { + return SelectorMol(*this, idxs); + } -template -SIRE_OUTOFLINE_TEMPLATE -Atom SelectorM::atom(int i, const SireBase::PropertyMap&) const -{ - i = SireID::Index(i).map(this->nAtoms()); + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol + SelectorM::molecules(const QString &name, + const SireBase::PropertyMap &map) const + { + return SelectorMol(*this, name, map); + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol + SelectorM::molecules(const MolID &molid, + const SireBase::PropertyMap &) const { - if (i < v.nAtoms()) - { - return v.atom(i); - } - else - { - i -= v.nAtoms(); - } + return SelectorMol(*this, molid); } - throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); + template + SIRE_OUTOFLINE_TEMPLATE + Atom + SelectorM::atom(int i, const SireBase::PropertyMap &) const + { + i = SireID::Index(i).map(this->nAtoms()); - return Atom(); -} + for (const auto &v : this->vws) + { + if (i < v.nAtoms()) + { + return v.atom(i); + } + else + { + i -= v.nAtoms(); + } + } -template -SIRE_OUTOFLINE_TEMPLATE -Atom SelectorM::atom(const QString &name, - const SireBase::PropertyMap &map) const -{ - auto all = this->atoms(name, map); + throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); + + return Atom(); + } - if (all.count() > 1) - _get_view::raise_duplicate(name, all.count()); + template + SIRE_OUTOFLINE_TEMPLATE + Atom + SelectorM::atom(const QString &name, + const SireBase::PropertyMap &map) const + { + auto all = this->atoms(name, map); - BOOST_ASSERT( not all.isEmpty() ); + if (all.count() > 1) + _get_view::raise_duplicate(name, all.count()); - return all[0]; -} + BOOST_ASSERT(not all.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -Atom SelectorM::atom(const AtomID &atomid, - const SireBase::PropertyMap &map) const -{ - auto all = this->atoms(atomid, map); + return all[0]; + } - if (all.count() > 1) - _get_view::raise_duplicate(atomid.toString(), all.count()); + template + SIRE_OUTOFLINE_TEMPLATE + Atom + SelectorM::atom(const AtomID &atomid, + const SireBase::PropertyMap &map) const + { + auto all = this->atoms(atomid, map); - BOOST_ASSERT( not all.isEmpty() ); + if (all.count() > 1) + _get_view::raise_duplicate(atomid.toString(), all.count()); - return all[0]; -} + BOOST_ASSERT(not all.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -Residue SelectorM::residue(int i, const SireBase::PropertyMap&) const -{ - i = SireID::Index(i).map(this->nResidues()); + return all[0]; + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + Residue + SelectorM::residue(int i, const SireBase::PropertyMap &) const { - if (i < v.nResidues()) - { - return v.residue(i); - } - else + i = SireID::Index(i).map(this->nResidues()); + + for (const auto &v : this->vws) { - i -= v.nResidues(); + if (i < v.nResidues()) + { + return v.residue(i); + } + else + { + i -= v.nResidues(); + } } - } - throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); + throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); - return Residue(); -} + return Residue(); + } -template -SIRE_OUTOFLINE_TEMPLATE -Residue SelectorM::residue(const QString &name, + template + SIRE_OUTOFLINE_TEMPLATE + Residue + SelectorM::residue(const QString &name, const SireBase::PropertyMap &map) const -{ - auto all = this->residues(name, map); + { + auto all = this->residues(name, map); - if (all.count() > 1) - _get_view::raise_duplicate(name, all.count()); + if (all.count() > 1) + _get_view::raise_duplicate(name, all.count()); - BOOST_ASSERT( not all.isEmpty() ); + BOOST_ASSERT(not all.isEmpty()); - return all[0]; -} + return all[0]; + } -template -SIRE_OUTOFLINE_TEMPLATE -Residue SelectorM::residue(const ResID &resid, + template + SIRE_OUTOFLINE_TEMPLATE + Residue + SelectorM::residue(const ResID &resid, const SireBase::PropertyMap &map) const -{ - auto all = this->residues(resid, map); - - if (all.count() > 1) - _get_view::raise_duplicate(resid.toString(), all.count()); + { + auto all = this->residues(resid, map); - BOOST_ASSERT( not all.isEmpty() ); + if (all.count() > 1) + _get_view::raise_duplicate(resid.toString(), all.count()); - return all[0]; -} + BOOST_ASSERT(not all.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -Chain SelectorM::chain(int i, const SireBase::PropertyMap&) const -{ - i = SireID::Index(i).map(this->nChains()); + return all[0]; + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + Chain + SelectorM::chain(int i, const SireBase::PropertyMap &) const { - if (i < v.nChains()) - { - return v.chain(i); - } - else + i = SireID::Index(i).map(this->nChains()); + + for (const auto &v : this->vws) { - i -= v.nChains(); + if (i < v.nChains()) + { + return v.chain(i); + } + else + { + i -= v.nChains(); + } } - } - throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); + throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); - return Chain(); -} + return Chain(); + } -template -SIRE_OUTOFLINE_TEMPLATE -Chain SelectorM::chain(const QString &name, - const SireBase::PropertyMap &map) const -{ - auto all = this->chains(name, map); + template + SIRE_OUTOFLINE_TEMPLATE + Chain + SelectorM::chain(const QString &name, + const SireBase::PropertyMap &map) const + { + auto all = this->chains(name, map); - if (all.count() > 1) - _get_view::raise_duplicate(name, all.count()); + if (all.count() > 1) + _get_view::raise_duplicate(name, all.count()); - BOOST_ASSERT( not all.isEmpty() ); + BOOST_ASSERT(not all.isEmpty()); - return all[0]; -} + return all[0]; + } -template -SIRE_OUTOFLINE_TEMPLATE -Chain SelectorM::chain(const ChainID &chainid, - const SireBase::PropertyMap &map) const -{ - auto all = this->chains(chainid); + template + SIRE_OUTOFLINE_TEMPLATE + Chain + SelectorM::chain(const ChainID &chainid, + const SireBase::PropertyMap &map) const + { + auto all = this->chains(chainid); - if (all.count() > 1) - _get_view::raise_duplicate(chainid.toString(), all.count()); + if (all.count() > 1) + _get_view::raise_duplicate(chainid.toString(), all.count()); - BOOST_ASSERT( not all.isEmpty() ); + BOOST_ASSERT(not all.isEmpty()); - return all[0]; -} - -template -SIRE_OUTOFLINE_TEMPLATE -Segment SelectorM::segment(int i, const SireBase::PropertyMap&) const -{ - i = SireID::Index(i).map(this->nSegments()); + return all[0]; + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + Segment + SelectorM::segment(int i, const SireBase::PropertyMap &) const { - if (i < v.nSegments()) - { - return v.segment(i); - } - else + i = SireID::Index(i).map(this->nSegments()); + + for (const auto &v : this->vws) { - i -= v.nSegments(); + if (i < v.nSegments()) + { + return v.segment(i); + } + else + { + i -= v.nSegments(); + } } - } - throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); + throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); - return Segment(); -} + return Segment(); + } -template -SIRE_OUTOFLINE_TEMPLATE -Segment SelectorM::segment(const QString &name, + template + SIRE_OUTOFLINE_TEMPLATE + Segment + SelectorM::segment(const QString &name, const SireBase::PropertyMap &map) const -{ - auto all = this->segments(name, map); + { + auto all = this->segments(name, map); - if (all.count() > 1) - _get_view::raise_duplicate(name, all.count()); + if (all.count() > 1) + _get_view::raise_duplicate(name, all.count()); - BOOST_ASSERT( not all.isEmpty() ); + BOOST_ASSERT(not all.isEmpty()); - return all[0]; -} + return all[0]; + } -template -SIRE_OUTOFLINE_TEMPLATE -Segment SelectorM::segment(const SegID &segid, + template + SIRE_OUTOFLINE_TEMPLATE + Segment + SelectorM::segment(const SegID &segid, const SireBase::PropertyMap &map) const -{ - auto all = this->segments(segid, map); + { + auto all = this->segments(segid, map); - if (all.count() > 1) - _get_view::raise_duplicate(segid.toString(), all.count()); + if (all.count() > 1) + _get_view::raise_duplicate(segid.toString(), all.count()); - BOOST_ASSERT( not all.isEmpty() ); + BOOST_ASSERT(not all.isEmpty()); - return all[0]; -} - -template -SIRE_OUTOFLINE_TEMPLATE -CutGroup SelectorM::cutGroup(int i, const SireBase::PropertyMap&) const -{ - i = SireID::Index(i).map(this->nCutGroups()); + return all[0]; + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + CutGroup + SelectorM::cutGroup(int i, const SireBase::PropertyMap &) const { - if (i < v.nCutGroups()) - { - return v.cutGroup(i); - } - else + i = SireID::Index(i).map(this->nCutGroups()); + + for (const auto &v : this->vws) { - i -= v.nCutGroups(); + if (i < v.nCutGroups()) + { + return v.cutGroup(i); + } + else + { + i -= v.nCutGroups(); + } } - } - - throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); - return CutGroup(); -} - -template -SIRE_OUTOFLINE_TEMPLATE -CutGroup SelectorM::cutGroup(const QString &name, - const SireBase::PropertyMap &map) const -{ - auto all = this->cutGroups(name, map); + throw SireError::program_bug(QObject::tr("Should not get here!"), CODELOC); - if (all.count() > 1) - _get_view::raise_duplicate(name, all.count()); + return CutGroup(); + } - BOOST_ASSERT( not all.isEmpty() ); + template + SIRE_OUTOFLINE_TEMPLATE + CutGroup + SelectorM::cutGroup(const QString &name, + const SireBase::PropertyMap &map) const + { + auto all = this->cutGroups(name, map); - return all[0]; -} + if (all.count() > 1) + _get_view::raise_duplicate(name, all.count()); -template -SIRE_OUTOFLINE_TEMPLATE -CutGroup SelectorM::cutGroup(const CGID &cgid, - const SireBase::PropertyMap &map) const -{ - auto all = this->cutGroups(cgid, map); + BOOST_ASSERT(not all.isEmpty()); - if (all.count() > 1) - _get_view::raise_duplicate(cgid.toString(), all.count()); + return all[0]; + } - BOOST_ASSERT( not all.isEmpty() ); + template + SIRE_OUTOFLINE_TEMPLATE + CutGroup + SelectorM::cutGroup(const CGID &cgid, + const SireBase::PropertyMap &map) const + { + auto all = this->cutGroups(cgid, map); - return all[0]; -} + if (all.count() > 1) + _get_view::raise_duplicate(cgid.toString(), all.count()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::atoms() const -{ - return SelectorM(*this); -} + BOOST_ASSERT(not all.isEmpty()); -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::atoms(int i, const SireBase::PropertyMap &map) const -{ - return SelectorM(this->atom(i,map)); -} + return all[0]; + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::atoms(const SireBase::Slice &slice, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::atoms() const + { + return SelectorM(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::atoms(const QList &idxs, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::atoms(int i, const SireBase::PropertyMap &map) const + { + return SelectorM(this->atom(i, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::atoms(const QString &name, - const SireBase::PropertyMap &map) const -{ - return SelectorM(*this, name, map); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::atoms(const SireBase::Slice &slice, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::atoms(const AtomID &atomid, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, atomid); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::atoms(const QList &idxs, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, idxs); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::residues() const -{ - return SelectorM(*this); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::atoms(const QString &name, + const SireBase::PropertyMap &map) const + { + return SelectorM(*this, name, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::residues(int i, - const SireBase::PropertyMap &map) const -{ - return SelectorM(this->residue(i, map)); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::atoms(const AtomID &atomid, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, atomid); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::residues(const SireBase::Slice &slice, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::residues() const + { + return SelectorM(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::residues(const QList &idxs, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::residues(int i, + const SireBase::PropertyMap &map) const + { + return SelectorM(this->residue(i, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::residues(const QString &name, - const SireBase::PropertyMap &map) const -{ - return SelectorM(*this, name, map); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::residues(const SireBase::Slice &slice, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::residues(const ResID &resid, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, resid); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::residues(const QList &idxs, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, idxs); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::chains() const -{ - return SelectorM(*this); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::residues(const QString &name, + const SireBase::PropertyMap &map) const + { + return SelectorM(*this, name, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::chains(int i, - const SireBase::PropertyMap &map) const -{ - return SelectorM(this->chain(i, map)); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::residues(const ResID &resid, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, resid); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::chains(const SireBase::Slice &slice, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::chains() const + { + return SelectorM(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::chains(const QList &idxs, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::chains(int i, + const SireBase::PropertyMap &map) const + { + return SelectorM(this->chain(i, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::chains(const QString &name, - const SireBase::PropertyMap &map) const -{ - return SelectorM(*this, name, map); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::chains(const SireBase::Slice &slice, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::chains(const ChainID &chainid, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, chainid); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::chains(const QList &idxs, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, idxs); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::segments() const -{ - return SelectorM(*this); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::chains(const QString &name, + const SireBase::PropertyMap &map) const + { + return SelectorM(*this, name, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::segments(int i, - const SireBase::PropertyMap &map) const -{ - return SelectorM(this->segment(i, map)); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::chains(const ChainID &chainid, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, chainid); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::segments(const SireBase::Slice &slice, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::segments() const + { + return SelectorM(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::segments(const QList &idxs, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::segments(int i, + const SireBase::PropertyMap &map) const + { + return SelectorM(this->segment(i, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::segments(const QString &name, - const SireBase::PropertyMap &map) const -{ - return SelectorM(*this, name, map); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::segments(const SireBase::Slice &slice, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::segments(const SegID &segid, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, segid); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::segments(const QList &idxs, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, idxs); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::cutGroups() const -{ - return SelectorM(*this); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::segments(const QString &name, + const SireBase::PropertyMap &map) const + { + return SelectorM(*this, name, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::cutGroups(int i, - const SireBase::PropertyMap &map) const -{ - return SelectorM(this->cutGroup(i, map)); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::segments(const SegID &segid, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, segid); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::cutGroups(const SireBase::Slice &slice, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, slice); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::cutGroups() const + { + return SelectorM(*this); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::cutGroups(const QList &idxs, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, idxs); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::cutGroups(int i, + const SireBase::PropertyMap &map) const + { + return SelectorM(this->cutGroup(i, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::cutGroups(const QString &name, - const SireBase::PropertyMap &map) const -{ - return SelectorM(*this, name, map); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::cutGroups(const SireBase::Slice &slice, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, slice); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorM SelectorM::cutGroups(const CGID &cgid, - const SireBase::PropertyMap&) const -{ - return SelectorM(*this, cgid); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::cutGroups(const QList &idxs, + const SireBase::PropertyMap &) const + { + return SelectorM(*this, idxs); + } -template -SIRE_OUTOFLINE_TEMPLATE -QList SelectorM::IDs() const -{ - QList ids; + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::cutGroups(const QString &name, + const SireBase::PropertyMap &map) const + { + return SelectorM(*this, name, map); + } - for (const auto &v : this->vws) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorM + SelectorM::cutGroups(const CGID &cgid, + const SireBase::PropertyMap &) const { - ids += v.IDs(); + return SelectorM(*this, cgid); } - return ids; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::IDs() const + { + QList ids; -template -SIRE_OUTOFLINE_TEMPLATE -QList SelectorM::indexes() const -{ - QList idxs; + for (const auto &v : this->vws) + { + ids += v.IDs(); + } - for (const auto &v : this->vws) - { - idxs += v.indexes(); + return ids; } - return idxs; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::indexes() const + { + QList idxs; -template -SIRE_OUTOFLINE_TEMPLATE -QList SelectorM::numbers() const -{ - QList nums; + for (const auto &v : this->vws) + { + idxs += v.indexes(); + } - for (const auto &v : this->vws) - { - nums += v.numbers(); + return idxs; } - return nums; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::numbers() const + { + QList nums; -template -SIRE_OUTOFLINE_TEMPLATE -QList SelectorM::names() const -{ - QList nmes; + for (const auto &v : this->vws) + { + nums += v.numbers(); + } - for (const auto &v : this->vws) - { - nmes += v.names(); + return nums; } - return nmes; -} + template + SIRE_OUTOFLINE_TEMPLATE + QList + SelectorM::names() const + { + QList nmes; -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nAtoms() const -{ - int n = 0; + for (const auto &v : this->vws) + { + nmes += v.names(); + } - for (const auto &v : this->vws) - { - n += v.nAtoms(); + return nmes; } - return n; -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nAtoms() const + { + int n = 0; -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nResidues() const -{ - int n = 0; + for (const auto &v : this->vws) + { + n += v.nAtoms(); + } - for (const auto &v : this->vws) - { - n += v.nResidues(); + return n; } - return n; -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nResidues() const + { + int n = 0; -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nChains() const -{ - int n = 0; + for (const auto &v : this->vws) + { + n += v.nResidues(); + } - for (const auto &v : this->vws) - { - n += v.nChains(); + return n; } - return n; -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nChains() const + { + int n = 0; -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nSegments() const -{ - int n = 0; + for (const auto &v : this->vws) + { + n += v.nChains(); + } - for (const auto &v : this->vws) - { - n += v.nSegments(); + return n; } - return n; -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nSegments() const + { + int n = 0; -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nCutGroups() const -{ - int n = 0; + for (const auto &v : this->vws) + { + n += v.nSegments(); + } - for (const auto &v : this->vws) - { - n += v.nCutGroups(); + return n; } - return n; -} - -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nMolecules() const -{ - return this->vws.count(); -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nCutGroups() const + { + int n = 0; -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nFrames() const -{ - return this->nFrames(PropertyMap()); -} + for (const auto &v : this->vws) + { + n += v.nCutGroups(); + } -template -SIRE_OUTOFLINE_TEMPLATE -int SelectorM::nFrames(const SireBase::PropertyMap &map) const -{ - return SireMol::detail::_nFrames(this->vws, map); -} + return n; + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::loadFrame(int frame) -{ - this->loadFrame(frame, PropertyMap()); -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nMolecules() const + { + return this->vws.count(); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::saveFrame(int frame) -{ - this->saveFrame(frame, PropertyMap()); -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nFrames() const + { + return this->nFrames(PropertyMap()); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::saveFrame() -{ - this->saveFrame(PropertyMap()); -} + template + SIRE_OUTOFLINE_TEMPLATE int SelectorM::nFrames(const SireBase::PropertyMap &map) const + { + return SireMol::detail::_nFrames(this->vws, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::deleteFrame(int frame) -{ - this->deleteFrame(frame, PropertyMap()); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::loadFrame(int frame) + { + this->loadFrame(frame, PropertyMap()); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::loadFrame(int frame, const SireBase::PropertyMap &map) -{ - SireMol::detail::_loadFrame(this->vws, frame, map); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::saveFrame(int frame) + { + this->saveFrame(frame, PropertyMap()); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::saveFrame(int frame, const SireBase::PropertyMap &map) -{ - SireMol::detail::_saveFrame(this->vws, frame, map); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::saveFrame() + { + this->saveFrame(PropertyMap()); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::saveFrame(const SireBase::PropertyMap &map) -{ - SireMol::detail::_saveFrame(this->vws, map); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::deleteFrame(int frame) + { + this->deleteFrame(frame, PropertyMap()); + } -template -SIRE_OUTOFLINE_TEMPLATE -void SelectorM::deleteFrame(int frame, const SireBase::PropertyMap &map) -{ - SireMol::detail::_deleteFrame(this->vws, frame, map); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::loadFrame(int frame, const SireBase::PropertyMap &map) + { + SireMol::detail::_loadFrame(this->vws, frame, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -bool SelectorM::isEmpty() const -{ - return this->vws.isEmpty(); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::saveFrame(int frame, const SireBase::PropertyMap &map) + { + SireMol::detail::_saveFrame(this->vws, frame, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -typename SelectorM::const_iterator SelectorM::begin() const -{ - return this->vws.constBegin(); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::saveFrame(const SireBase::PropertyMap &map) + { + SireMol::detail::_saveFrame(this->vws, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -typename SelectorM::const_iterator SelectorM::end() const -{ - return this->vws.constEnd(); -} + template + SIRE_OUTOFLINE_TEMPLATE void SelectorM::deleteFrame(int frame, const SireBase::PropertyMap &map) + { + SireMol::detail::_deleteFrame(this->vws, frame, map); + } -template -SIRE_OUTOFLINE_TEMPLATE -typename SelectorM::const_iterator SelectorM::constBegin() const -{ - return this->vws.constBegin(); -} + template + SIRE_OUTOFLINE_TEMPLATE bool SelectorM::isEmpty() const + { + return this->vws.isEmpty(); + } -template -SIRE_OUTOFLINE_TEMPLATE -typename SelectorM::const_iterator SelectorM::constEnd() const -{ - return this->vws.constEnd(); -} + template + SIRE_OUTOFLINE_TEMPLATE + typename SelectorM::const_iterator + SelectorM::begin() const + { + return this->vws.constBegin(); + } -template -SIRE_OUTOFLINE_TEMPLATE -QString SelectorM::toString() const -{ - if (this->isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + typename SelectorM::const_iterator + SelectorM::end() const { - return QObject::tr("%1::empty").arg(this->what()); + return this->vws.constEnd(); } - else + + template + SIRE_OUTOFLINE_TEMPLATE + typename SelectorM::const_iterator + SelectorM::constBegin() const { - QStringList parts; + return this->vws.constBegin(); + } - const auto n = this->count(); + template + SIRE_OUTOFLINE_TEMPLATE + typename SelectorM::const_iterator + SelectorM::constEnd() const + { + return this->vws.constEnd(); + } - if (n <= 10) + template + SIRE_OUTOFLINE_TEMPLATE + QString + SelectorM::toString() const + { + if (this->isEmpty()) { - for (int i=0; ioperator[](i); - - parts.append(QString("%1: %2 %3") - .arg(i).arg(view.data().number().toString()) - .arg(view.toString())); - } + return QObject::tr("%1::empty").arg(this->what()); } else { - for (int i=0; i<5; ++i) + QStringList parts; + + const auto n = this->count(); + + if (n <= 10) { - const auto view = this->operator[](i); + for (int i = 0; i < n; ++i) + { + const auto view = this->operator[](i); - parts.append(QString("%1: %2 %3") - .arg(i).arg(view.data().number().toString()) - .arg(view.toString())); + parts.append(QString("%1: %2 %3") + .arg(i) + .arg(view.data().number().toString()) + .arg(view.toString())); + } } + else + { + for (int i = 0; i < 5; ++i) + { + const auto view = this->operator[](i); - parts.append("..."); + parts.append(QString("%1: %2 %3") + .arg(i) + .arg(view.data().number().toString()) + .arg(view.toString())); + } - for (int i=n-5; ioperator[](i); + parts.append("..."); + + for (int i = n - 5; i < n; ++i) + { + const auto view = this->operator[](i); - parts.append(QString("%1: %2 %3") - .arg(i).arg(view.data().number().toString()) - .arg(view.toString())); + parts.append(QString("%1: %2 %3") + .arg(i) + .arg(view.data().number().toString()) + .arg(view.toString())); + } } - } - return QObject::tr("%1( size=%2\n%3\n)") - .arg(this->what()).arg(n) - .arg(parts.join("\n")); + return QObject::tr("%1( size=%2\n%3\n)") + .arg(this->what()) + .arg(n) + .arg(parts.join("\n")); + } } -} #endif // SIRE_SKIP_INLINE_FUNCTIONS @@ -2497,25 +2677,26 @@ QString SelectorM::toString() const namespace SireMol { -template -SIRE_OUTOFLINE_TEMPLATE -EvaluatorM::EvaluatorM(const SelectorM &views) - : SireBase::ConcreteProperty() -{ - this->vws.reserve(views.count()); - - for (const auto &view : views) + template + SIRE_OUTOFLINE_TEMPLATE + EvaluatorM::EvaluatorM(const SelectorM &views) + : SireBase::ConcreteProperty() { - this->vws.append(PartialMolecule(view)); + this->vws.reserve(views.count()); + + for (const auto &view : views) + { + this->vws.append(PartialMolecule(view)); + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -EvaluatorM SelectorM::evaluate() const -{ - return EvaluatorM(*this); -} + template + SIRE_OUTOFLINE_TEMPLATE + EvaluatorM + SelectorM::evaluate() const + { + return EvaluatorM(*this); + } } // end of namespace SireMol diff --git a/corelib/src/libs/SireMol/selectormol.cpp b/corelib/src/libs/SireMol/selectormol.cpp index 95b4cc5ca..5aea86ee8 100644 --- a/corelib/src/libs/SireMol/selectormol.cpp +++ b/corelib/src/libs/SireMol/selectormol.cpp @@ -56,11 +56,11 @@ using namespace SireMol; using namespace SireID; RegisterMetaType r_smol; -RegisterMetaType< SelectorM > r_satm; -RegisterMetaType< SelectorM > r_sres; -RegisterMetaType< SelectorM > r_schn; -RegisterMetaType< SelectorM > r_sseg; -RegisterMetaType< SelectorM > r_scg; +RegisterMetaType> r_satm; +RegisterMetaType> r_sres; +RegisterMetaType> r_schn; +RegisterMetaType> r_sseg; +RegisterMetaType> r_scg; /** Serialise to a binary datastream */ SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorMol &mols) @@ -69,7 +69,7 @@ SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorMol &mols) SharedDataStream sds(ds); - sds << mols.mols << static_cast(mols); + sds << mols.mols << static_cast(mols); return ds; } @@ -82,7 +82,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorMol &mols) if (v == 1) { SharedDataStream sds(ds); - sds >> mols.mols >> static_cast(mols); + sds >> mols.mols >> static_cast(mols); } else throw version_error(v, "1", r_smol, CODELOC); @@ -91,20 +91,20 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorMol &mols) } /** Serialise to a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorM &mols) { writeHeader(ds, r_satm, 1); SharedDataStream sds(ds); - sds << mols.vws << static_cast(mols); + sds << mols.vws << static_cast(mols); return ds; } /** Extract from a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) { VersionID v = readHeader(ds, r_satm); @@ -112,7 +112,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) if (v == 1) { SharedDataStream sds(ds); - sds >> mols.vws >> static_cast(mols); + sds >> mols.vws >> static_cast(mols); } else throw version_error(v, "1", r_satm, CODELOC); @@ -120,20 +120,20 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) return ds; } /** Serialise to a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorM &mols) { writeHeader(ds, r_sres, 1); SharedDataStream sds(ds); - sds << mols.vws << static_cast(mols); + sds << mols.vws << static_cast(mols); return ds; } /** Extract from a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) { VersionID v = readHeader(ds, r_sres); @@ -141,7 +141,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols if (v == 1) { SharedDataStream sds(ds); - sds >> mols.vws >> static_cast(mols); + sds >> mols.vws >> static_cast(mols); } else throw version_error(v, "1", r_sres, CODELOC); @@ -149,20 +149,20 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols return ds; } /** Serialise to a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorM &mols) { writeHeader(ds, r_schn, 1); SharedDataStream sds(ds); - sds << mols.vws << static_cast(mols); + sds << mols.vws << static_cast(mols); return ds; } /** Extract from a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) { VersionID v = readHeader(ds, r_schn); @@ -170,7 +170,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) if (v == 1) { SharedDataStream sds(ds); - sds >> mols.vws >> static_cast(mols); + sds >> mols.vws >> static_cast(mols); } else throw version_error(v, "1", r_schn, CODELOC); @@ -178,20 +178,20 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) return ds; } /** Serialise to a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorM &mols) { writeHeader(ds, r_sseg, 1); SharedDataStream sds(ds); - sds << mols.vws << static_cast(mols); + sds << mols.vws << static_cast(mols); return ds; } /** Extract from a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) { VersionID v = readHeader(ds, r_sseg); @@ -199,7 +199,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols if (v == 1) { SharedDataStream sds(ds); - sds >> mols.vws >> static_cast(mols); + sds >> mols.vws >> static_cast(mols); } else throw version_error(v, "1", r_sseg, CODELOC); @@ -207,20 +207,20 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols return ds; } /** Serialise to a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator<<(QDataStream &ds, const SelectorM &mols) { writeHeader(ds, r_scg, 1); SharedDataStream sds(ds); - sds << mols.vws << static_cast(mols); + sds << mols.vws << static_cast(mols); return ds; } /** Extract from a binary datastream */ -template<> +template <> SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mols) { VersionID v = readHeader(ds, r_scg); @@ -228,7 +228,7 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mol if (v == 1) { SharedDataStream sds(ds); - sds >> mols.vws >> static_cast(mols); + sds >> mols.vws >> static_cast(mols); } else throw version_error(v, "1", r_scg, CODELOC); @@ -236,17 +236,18 @@ SIREMOL_EXPORT QDataStream &operator>>(QDataStream &ds, SelectorM &mol return ds; } -SelectorMol::SelectorMol() : ConcreteProperty() -{} +SelectorMol::SelectorMol() : ConcreteProperty() +{ +} SelectorMol::SelectorMol(const MoleculeView &mol) - : ConcreteProperty() + : ConcreteProperty() { this->mols.append(mol.molecule()); } SelectorMol::SelectorMol(const Molecules &molecules) - : ConcreteProperty() + : ConcreteProperty() { if (not molecules.isEmpty()) { @@ -257,9 +258,9 @@ SelectorMol::SelectorMol(const Molecules &molecules) auto molnums = toList(molecules.molNums()); - //sort them, as this is also likely the order the molecules - //were read in from a file, and so more likely to be the - //order the user would expect + // sort them, as this is also likely the order the molecules + // were read in from a file, and so more likely to be the + // order the user would expect std::sort(molnums.begin(), molnums.end()); this->mols.reserve(molnums.count()); @@ -272,7 +273,7 @@ SelectorMol::SelectorMol(const Molecules &molecules) } SelectorMol::SelectorMol(const MoleculeGroup &molecules) - : ConcreteProperty() + : ConcreteProperty() { if (not molecules.isEmpty()) { @@ -287,7 +288,7 @@ SelectorMol::SelectorMol(const MoleculeGroup &molecules) } SelectorMol::SelectorMol(const MolGroupsBase &molecules) - : ConcreteProperty() + : ConcreteProperty() { if (not molecules.isEmpty()) { @@ -302,7 +303,7 @@ SelectorMol::SelectorMol(const MolGroupsBase &molecules) } SelectorMol::SelectorMol(const SelectResult &molecules) - : ConcreteProperty() + : ConcreteProperty() { if (not molecules.isEmpty()) { @@ -316,19 +317,21 @@ SelectorMol::SelectorMol(const SelectResult &molecules) } SelectorMol::SelectorMol(const SelectorMol &other) - : ConcreteProperty(), - mols(other.mols) -{} + : ConcreteProperty(), + mols(other.mols) +{ +} SelectorMol::~SelectorMol() -{} +{ +} -const char* SelectorMol::typeName() +const char *SelectorMol::typeName() { return QMetaType::typeName(qMetaTypeId()); } -SelectorMol& SelectorMol::operator=(const SelectorMol &other) +SelectorMol &SelectorMol::operator=(const SelectorMol &other) { if (this != &other) { @@ -417,6 +420,49 @@ bool SelectorMol::isSelector() const return true; } +/** Return the index of 'view' in this list of molecules. + * Returns an empty list if the view is not in this collection + */ +QList SelectorMol::find(const Molecule &view) const +{ + QList matches; + + for (int i = 0; i < mols.count(); ++i) + { + if (mols.at(i).isSameMolecule(view)) + { + matches.append(i); + break; + } + } + + return matches; +} + +/** Return the index of 'views' in this list of molecules. + * Returns an empty list if none of the views are in this collection + */ +QList SelectorMol::find(const SelectorMol &views) const +{ + QList matches; + + for (int i = 0; i < views.count(); ++i) + { + const auto &view = views[i]; + + for (int j = 0; j < mols.count(); ++j) + { + if (mols.at(j).isSameMolecule(view)) + { + matches.append(j); + break; + } + } + } + + return matches; +} + void SelectorMol::update(const Molecules &molecules) { // better to create a map from MolNum to index here @@ -483,7 +529,7 @@ bool SelectorMol::contains(const MolNum &molnum) const return false; } -Molecule SelectorMol::molecule(int i, const PropertyMap&) const +Molecule SelectorMol::molecule(int i, const PropertyMap &) const { return this->mols.at(Index(i).map(this->mols.count())); } @@ -494,8 +540,10 @@ Molecule SelectorMol::molecule(const QString &name, const PropertyMap &map) cons if (m.count() > 1) throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches %1. Number of matches is %2.") - .arg(name).arg(m.count()), CODELOC); + "More than one molecule matches %1. Number of matches is %2.") + .arg(name) + .arg(m.count()), + CODELOC); BOOST_ASSERT(m.count() != 0); @@ -508,8 +556,10 @@ Molecule SelectorMol::molecule(const MolIdx &molid, const PropertyMap &map) cons if (m.count() > 1) throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches %1. Number of matches is %2.") - .arg(molid.toString()).arg(m.count()), CODELOC); + "More than one molecule matches %1. Number of matches is %2.") + .arg(molid.toString()) + .arg(m.count()), + CODELOC); BOOST_ASSERT(m.count() != 0); @@ -522,8 +572,10 @@ Molecule SelectorMol::molecule(const MolName &molid, const PropertyMap &map) con if (m.count() > 1) throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches %1. Number of matches is %2.") - .arg(molid.toString()).arg(m.count()), CODELOC); + "More than one molecule matches %1. Number of matches is %2.") + .arg(molid.toString()) + .arg(m.count()), + CODELOC); BOOST_ASSERT(m.count() != 0); @@ -536,8 +588,10 @@ Molecule SelectorMol::molecule(const MolNum &molid, const PropertyMap &map) cons if (m.count() > 1) throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches %1. Number of matches is %2.") - .arg(molid.toString()).arg(m.count()), CODELOC); + "More than one molecule matches %1. Number of matches is %2.") + .arg(molid.toString()) + .arg(m.count()), + CODELOC); BOOST_ASSERT(m.count() != 0); @@ -550,8 +604,10 @@ Molecule SelectorMol::molecule(const MolID &molid, const PropertyMap &map) const if (m.count() > 1) throw SireMol::duplicate_molecule(QObject::tr( - "More than one molecule matches %1. Number of matches is %2.") - .arg(molid.toString()).arg(m.count()), CODELOC); + "More than one molecule matches %1. Number of matches is %2.") + .arg(molid.toString()) + .arg(m.count()), + CODELOC); BOOST_ASSERT(m.count() != 0); @@ -569,7 +625,7 @@ SelectorMol SelectorMol::molecules(int i, const PropertyMap &map) const } SelectorMol SelectorMol::molecules(const SireBase::Slice &slice, - const PropertyMap&) const + const PropertyMap &) const { SelectorMol m; @@ -582,7 +638,7 @@ SelectorMol SelectorMol::molecules(const SireBase::Slice &slice, } SelectorMol SelectorMol::molecules(const QList &idxs, - const PropertyMap&) const + const PropertyMap &) const { SelectorMol m; @@ -601,7 +657,7 @@ SelectorMol SelectorMol::molecules(const QString &name, { return this->molecules(MolName(name)); } - catch(const SireError::exception &e) + catch (const SireError::exception &e) { try { @@ -609,17 +665,19 @@ SelectorMol SelectorMol::molecules(const QString &name, if (ret.count() == 0) throw SireMol::missing_molecule(QObject::tr( - "No molecule matches '%1'").arg(name), CODELOC); + "No molecule matches '%1'") + .arg(name), + CODELOC); return ret; } - catch(...) + catch (...) { if (name.length() < 5) - //likely a name error + // likely a name error e.throwSelf(); else - //likely a syntax error + // likely a syntax error throw; } } @@ -634,7 +692,7 @@ SelectorMol SelectorMol::molecules(const MolIdx &molid, } SelectorMol SelectorMol::molecules(const MolName &molname, - const PropertyMap&) const + const PropertyMap &) const { SelectorMol m; @@ -648,14 +706,15 @@ SelectorMol SelectorMol::molecules(const MolName &molname, if (m.isEmpty()) throw SireMol::missing_molecule(QObject::tr( - "There is no molecule called %1 in this container.") - .arg(molname), CODELOC); + "There is no molecule called %1 in this container.") + .arg(molname), + CODELOC); return m; } SelectorMol SelectorMol::molecules(const MolNum &molnum, - const PropertyMap&) const + const PropertyMap &) const { SelectorMol m; @@ -671,8 +730,9 @@ SelectorMol SelectorMol::molecules(const MolNum &molnum, if (m.isEmpty()) throw SireMol::missing_molecule(QObject::tr( - "There is no molecule with number %1 in this container.") - .arg(molnum), CODELOC); + "There is no molecule with number %1 in this container.") + .arg(molnum), + CODELOC); return m; } @@ -690,13 +750,13 @@ MoleculeGroup SelectorMol::toMoleculeGroup() const } SelectorMol SelectorMol::molecules(const MolID &molid, - const PropertyMap&) const + const PropertyMap &) const { auto molnums = molid.map(this->toMoleculeGroup()); QHash m; - //QSet molnums_set(molnums.constBegin(), molnums.constEnd()); + // QSet molnums_set(molnums.constBegin(), molnums.constEnd()); QSet molnums_set = _list_to_set(molnums); for (const auto &mol : this->mols) @@ -723,7 +783,7 @@ SelectorMol SelectorMol::molecules(const MolID &molid, return ret; } -Atom SelectorMol::atom(int i, const PropertyMap&) const +Atom SelectorMol::atom(int i, const PropertyMap &) const { i = Index(i).map(this->nAtoms()); @@ -747,8 +807,10 @@ Atom SelectorMol::atom(const QString &name, if (atms.count() > 1) throw SireMol::duplicate_atom(QObject::tr( - "More than one atom matches the name '%1'. Number of matches is %2.") - .arg(name).arg(atms.count()), CODELOC); + "More than one atom matches the name '%1'. Number of matches is %2.") + .arg(name) + .arg(atms.count()), + CODELOC); BOOST_ASSERT(not atms.isEmpty()); @@ -761,15 +823,17 @@ Atom SelectorMol::atom(const AtomID &atomid, const PropertyMap &map) const if (atms.count() > 1) throw SireMol::duplicate_atom(QObject::tr( - "More than one atom matches '%1'. Number of matches is %2.") - .arg(atomid.toString()).arg(atms.count()), CODELOC); + "More than one atom matches '%1'. Number of matches is %2.") + .arg(atomid.toString()) + .arg(atms.count()), + CODELOC); BOOST_ASSERT(not atms.isEmpty()); return atms[0]; } -Residue SelectorMol::residue(int i, const PropertyMap&) const +Residue SelectorMol::residue(int i, const PropertyMap &) const { i = Index(i).map(this->nResidues()); @@ -793,8 +857,10 @@ Residue SelectorMol::residue(const QString &name, if (res.count() > 1) throw SireMol::duplicate_residue(QObject::tr( - "More than one residue matches the name '%1'. Number of matches is %2.") - .arg(name).arg(res.count()), CODELOC); + "More than one residue matches the name '%1'. Number of matches is %2.") + .arg(name) + .arg(res.count()), + CODELOC); BOOST_ASSERT(not res.isEmpty()); @@ -808,15 +874,17 @@ Residue SelectorMol::residue(const ResID &resid, if (res.count() > 1) throw SireMol::duplicate_residue(QObject::tr( - "More than one residue matches '%1'. Number of matches is %2.") - .arg(resid.toString()).arg(res.count()), CODELOC); + "More than one residue matches '%1'. Number of matches is %2.") + .arg(resid.toString()) + .arg(res.count()), + CODELOC); BOOST_ASSERT(not res.isEmpty()); return res[0]; } -Chain SelectorMol::chain(int i, const PropertyMap&) const +Chain SelectorMol::chain(int i, const PropertyMap &) const { i = Index(i).map(this->nChains()); @@ -840,8 +908,10 @@ Chain SelectorMol::chain(const QString &name, if (cs.count() > 1) throw SireMol::duplicate_chain(QObject::tr( - "More than one chain matches the name '%1'. Number of matches is %2.") - .arg(name).arg(cs.count()), CODELOC); + "More than one chain matches the name '%1'. Number of matches is %2.") + .arg(name) + .arg(cs.count()), + CODELOC); BOOST_ASSERT(not cs.isEmpty()); @@ -855,15 +925,17 @@ Chain SelectorMol::chain(const ChainID &chainid, if (cs.count() > 1) throw SireMol::duplicate_chain(QObject::tr( - "More than one chain matches '%1'. Number of matches is %2.") - .arg(chainid.toString()).arg(cs.count()), CODELOC); + "More than one chain matches '%1'. Number of matches is %2.") + .arg(chainid.toString()) + .arg(cs.count()), + CODELOC); BOOST_ASSERT(not cs.isEmpty()); return cs[0]; } -Segment SelectorMol::segment(int i, const PropertyMap&) const +Segment SelectorMol::segment(int i, const PropertyMap &) const { i = Index(i).map(this->nSegments()); @@ -887,8 +959,10 @@ Segment SelectorMol::segment(const QString &name, if (segs.count() > 1) throw SireMol::duplicate_segment(QObject::tr( - "More than one segment matches the name '%1'. Number of matches is %2.") - .arg(name).arg(segs.count()), CODELOC); + "More than one segment matches the name '%1'. Number of matches is %2.") + .arg(name) + .arg(segs.count()), + CODELOC); BOOST_ASSERT(not segs.isEmpty()); @@ -902,15 +976,17 @@ Segment SelectorMol::segment(const SegID &segid, if (segs.count() > 1) throw SireMol::duplicate_segment(QObject::tr( - "More than one segment matches '%1'. Number of matches is %2.") - .arg(segid.toString()).arg(segs.count()), CODELOC); + "More than one segment matches '%1'. Number of matches is %2.") + .arg(segid.toString()) + .arg(segs.count()), + CODELOC); BOOST_ASSERT(not segs.isEmpty()); return segs[0]; } -CutGroup SelectorMol::cutGroup(int i, const PropertyMap&) const +CutGroup SelectorMol::cutGroup(int i, const PropertyMap &) const { i = Index(i).map(this->nCutGroups()); @@ -934,8 +1010,10 @@ CutGroup SelectorMol::cutGroup(const QString &name, if (cgs.count() > 1) throw SireMol::duplicate_cutgroup(QObject::tr( - "More than one CutGroup matches the name '%1'. Number of matches is %2.") - .arg(name).arg(cgs.count()), CODELOC); + "More than one CutGroup matches the name '%1'. Number of matches is %2.") + .arg(name) + .arg(cgs.count()), + CODELOC); BOOST_ASSERT(not cgs.isEmpty()); @@ -949,8 +1027,10 @@ CutGroup SelectorMol::cutGroup(const CGID &cgid, if (cgs.count() > 1) throw SireMol::duplicate_cutgroup(QObject::tr( - "More than one CutGroup matches '%1'. Number of matches is %2.") - .arg(cgid.toString()).arg(cgs.count()), CODELOC); + "More than one CutGroup matches '%1'. Number of matches is %2.") + .arg(cgid.toString()) + .arg(cgs.count()), + CODELOC); BOOST_ASSERT(not cgs.isEmpty()); @@ -968,13 +1048,13 @@ SelectorM SelectorMol::atoms(int i, const PropertyMap &map) const } SelectorM SelectorMol::atoms(const SireBase::Slice &slice, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, slice); } SelectorM SelectorMol::atoms(const QList &idxs, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, idxs); } @@ -986,7 +1066,7 @@ SelectorM SelectorMol::atoms(const QString &name, } SelectorM SelectorMol::atoms(const AtomID &atomid, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, atomid); } @@ -1002,13 +1082,13 @@ SelectorM SelectorMol::residues(int i, const PropertyMap &map) const } SelectorM SelectorMol::residues(const SireBase::Slice &slice, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, slice); } SelectorM SelectorMol::residues(const QList &idxs, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, idxs); } @@ -1020,7 +1100,7 @@ SelectorM SelectorMol::residues(const QString &name, } SelectorM SelectorMol::residues(const ResID &resid, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, resid); } @@ -1037,13 +1117,13 @@ SelectorM SelectorMol::chains(int i, } SelectorM SelectorMol::chains(const SireBase::Slice &slice, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, slice); } SelectorM SelectorMol::chains(const QList &idxs, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, idxs); } @@ -1055,7 +1135,7 @@ SelectorM SelectorMol::chains(const QString &name, } SelectorM SelectorMol::chains(const ChainID &chainid, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, chainid); } @@ -1072,13 +1152,13 @@ SelectorM SelectorMol::segments(int i, } SelectorM SelectorMol::segments(const SireBase::Slice &slice, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, slice); } SelectorM SelectorMol::segments(const QList &idxs, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, idxs); } @@ -1090,7 +1170,7 @@ SelectorM SelectorMol::segments(const QString &name, } SelectorM SelectorMol::segments(const SegID &segid, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, segid); } @@ -1107,13 +1187,13 @@ SelectorM SelectorMol::cutGroups(int i, } SelectorM SelectorMol::cutGroups(const SireBase::Slice &slice, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, slice); } SelectorM SelectorMol::cutGroups(const QList &idxs, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, idxs); } @@ -1125,7 +1205,7 @@ SelectorM SelectorMol::cutGroups(const QString &name, } SelectorM SelectorMol::cutGroups(const CGID &cgid, - const PropertyMap&) const + const PropertyMap &) const { return SelectorM(*this, cgid); } @@ -1159,7 +1239,7 @@ QList SelectorMol::indexes() const QList idxs; idxs.reserve(this->mols.count()); - for (int i=0; imols.count(); ++i) + for (int i = 0; i < this->mols.count(); ++i) { idxs.append(MolIdx(i)); } @@ -1353,35 +1433,32 @@ QString SelectorMol::toString() const if (n <= 10) { - for (int i=0; imols[i].toString())); + parts.append(QObject::tr("%1: %2").arg(i).arg(this->mols[i].toString())); } } else { - for (int i=0; i<5; ++i) + for (int i = 0; i < 5; ++i) { - parts.append(QObject::tr("%1: %2").arg(i) - .arg(this->mols[i].toString())); + parts.append(QObject::tr("%1: %2").arg(i).arg(this->mols[i].toString())); } parts.append("..."); - for (int i=n-5; imols[i].toString())); + parts.append(QObject::tr("%1: %2").arg(i).arg(this->mols[i].toString())); } } return QObject::tr("SelectorMol( size=%1\n%2\n)") - .arg(n).arg(parts.join("\n")); + .arg(n) + .arg(parts.join("\n")); } } - namespace SireMol { template class SelectorM; diff --git a/corelib/src/libs/SireMol/selectormol.h b/corelib/src/libs/SireMol/selectormol.h index 757d66dfb..30fff4985 100644 --- a/corelib/src/libs/SireMol/selectormol.h +++ b/corelib/src/libs/SireMol/selectormol.h @@ -47,7 +47,7 @@ namespace SireMol class SelectorMol; class EvaluatorM; - template + template class SelectorM; class Molecules; @@ -66,263 +66,266 @@ namespace SireMol class MolIdx; } -SIREMOL_EXPORT QDataStream& operator<<(QDataStream&, const SireMol::SelectorMol&); -SIREMOL_EXPORT QDataStream& operator>>(QDataStream&, SireMol::SelectorMol&); +SIREMOL_EXPORT QDataStream &operator<<(QDataStream &, const SireMol::SelectorMol &); +SIREMOL_EXPORT QDataStream &operator>>(QDataStream &, SireMol::SelectorMol &); namespace SireMol { -/** This class provides a Selector-type interface to a - collection of molecules. -*/ -class SIREMOL_EXPORT SelectorMol - : public SireBase::ConcreteProperty -{ + /** This class provides a Selector-type interface to a + collection of molecules. + */ + class SIREMOL_EXPORT SelectorMol + : public SireBase::ConcreteProperty + { -friend SIREMOL_EXPORT QDataStream& ::operator<<(QDataStream&, const SelectorMol&); -friend SIREMOL_EXPORT QDataStream& ::operator>>(QDataStream&, SelectorMol&); + friend SIREMOL_EXPORT QDataStream & ::operator<<(QDataStream &, const SelectorMol &); + friend SIREMOL_EXPORT QDataStream & ::operator>>(QDataStream &, SelectorMol &); -public: - typedef QList::const_iterator const_iterator; - typedef QList::const_iterator iterator; + public: + typedef QList::const_iterator const_iterator; + typedef QList::const_iterator iterator; - SelectorMol(); - SelectorMol(const MoleculeView &mol); - SelectorMol(const Molecules &mols); - SelectorMol(const MoleculeGroup &mols); - SelectorMol(const MolGroupsBase &mols); - SelectorMol(const SelectResult &mols); + SelectorMol(); + SelectorMol(const MoleculeView &mol); + SelectorMol(const Molecules &mols); + SelectorMol(const MoleculeGroup &mols); + SelectorMol(const MolGroupsBase &mols); + SelectorMol(const SelectResult &mols); - template - SelectorMol(const SelectorM &other); - template - SelectorMol(const SelectorM &other, const QString &name, - const SireBase::PropertyMap &map = SireBase::PropertyMap()); - template - SelectorMol(const SelectorM &other, const SireBase::Slice &slice); - template - SelectorMol(const SelectorM &other, const QList &idxs); - template - SelectorMol(const SelectorM &other, const MolID &molid); + template + SelectorMol(const SelectorM &other); + template + SelectorMol(const SelectorM &other, const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()); + template + SelectorMol(const SelectorM &other, const SireBase::Slice &slice); + template + SelectorMol(const SelectorM &other, const QList &idxs); + template + SelectorMol(const SelectorM &other, const MolID &molid); - SelectorMol(const SelectorMol &other); + SelectorMol(const SelectorMol &other); - virtual ~SelectorMol(); + virtual ~SelectorMol(); - static const char* typeName(); + static const char *typeName(); - virtual const char* what() const - { - return SelectorMol::typeName(); - } + virtual const char *what() const + { + return SelectorMol::typeName(); + } - virtual SelectorMol* clone() const - { - return new SelectorMol(*this); - } + virtual SelectorMol *clone() const + { + return new SelectorMol(*this); + } - SelectorMol& operator=(const SelectorMol &other); + SelectorMol &operator=(const SelectorMol &other); - bool operator==(const SelectorMol &other) const; - bool operator!=(const SelectorMol &other) const; + bool operator==(const SelectorMol &other) const; + bool operator!=(const SelectorMol &other) const; - Molecule operator[](int i) const; - SelectorMol operator[](const SireBase::Slice &slice) const; - SelectorMol operator[](const QList &idxs) const; - Molecule operator[](const QString &name) const; - Molecule operator[](const MolIdx &molidx) const; - Molecule operator[](const MolName &molname) const; - Molecule operator[](const MolNum &molnum) const; - Molecule operator[](const MolID &molid) const; + Molecule operator[](int i) const; + SelectorMol operator[](const SireBase::Slice &slice) const; + SelectorMol operator[](const QList &idxs) const; + Molecule operator[](const QString &name) const; + Molecule operator[](const MolIdx &molidx) const; + Molecule operator[](const MolName &molname) const; + Molecule operator[](const MolNum &molnum) const; + Molecule operator[](const MolID &molid) const; - QList toList() const; - Molecules toMolecules() const; + QList toList() const; + Molecules toMolecules() const; - int count() const; - int size() const; + int count() const; + int size() const; - void update(const Molecules &molecules); + void update(const Molecules &molecules); - EvaluatorM evaluate() const; + EvaluatorM evaluate() const; - MoleculeGroup toMoleculeGroup() const; - SelectResult toSelectResult() const; + MoleculeGroup toMoleculeGroup() const; + SelectResult toSelectResult() const; - bool isSelector() const; + bool isSelector() const; - Molecule molecule(int i, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const QString &name, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const MolIdx &molidx, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const MolName &molname, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const MolNum &molnum, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - Molecule molecule(const MolID &molid, - const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + QList find(const Molecule &view) const; + QList find(const SelectorMol &views) const; - SelectorMol molecules() const; - SelectorMol molecules(int i, + Molecule molecule(int i, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const SireBase::Slice &slice, + Molecule molecule(const QString &name, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const QList &idxs, + Molecule molecule(const MolIdx &molidx, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const QString &name, + Molecule molecule(const MolName &molname, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const MolIdx &molidx, + Molecule molecule(const MolNum &molnum, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const MolName &molname, + Molecule molecule(const MolID &molid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorMol molecules() const; + SelectorMol molecules(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const MolIdx &molidx, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const MolName &molname, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const MolNum &molnum, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorMol molecules(const MolID &molid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + bool contains(const MolNum &molnum) const; + + Atom atom(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Atom atom(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Atom atom(const AtomID &atomid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + Residue residue(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Residue residue(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Residue residue(const ResID &resid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + Chain chain(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Chain chain(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Chain chain(const ChainID &chainid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + Segment segment(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Segment segment(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + Segment segment(const SegID &segid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + CutGroup cutGroup(int i, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const MolNum &molnum, + CutGroup cutGroup(const QString &name, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - SelectorMol molecules(const MolID &molid, + CutGroup cutGroup(const CGID &cgid, const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; - bool contains(const MolNum &molnum) const; - - Atom atom(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Atom atom(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Atom atom(const AtomID &atomid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - Residue residue(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Residue residue(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Residue residue(const ResID &resid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - Chain chain(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Chain chain(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Chain chain(const ChainID &chainid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - Segment segment(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Segment segment(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - Segment segment(const SegID &segid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - CutGroup cutGroup(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - CutGroup cutGroup(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - CutGroup cutGroup(const CGID &cgid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM atoms() const; - SelectorM atoms(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM atoms(const AtomID &atomid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM residues() const; - SelectorM residues(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM residues(const ResID &resid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM chains() const; - SelectorM chains(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM chains(const ChainID &chainid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM segments() const; - SelectorM segments(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM segments(const SegID &segid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectorM cutGroups() const; - SelectorM cutGroups(int i, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const SireBase::Slice &slice, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const QList &idxs, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const QString &name, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - SelectorM cutGroups(const CGID &cgid, - const SireBase::PropertyMap &map=SireBase::PropertyMap()) const; - - SelectResult search(const QString &search_string) const; - SelectResult search(const QString &search_string, - const SireBase::PropertyMap &map) const; - - QVector molNums() const; - - QList IDs() const; - QList indexes() const; - QList numbers() const; - QList names() const; - - int nAtoms() const; - int nResidues() const; - int nChains() const; - int nSegments() const; - int nCutGroups() const; - int nMolecules() const; - - bool isEmpty() const; - - int nFrames() const; - int nFrames(const SireBase::PropertyMap &map) const; - - void loadFrame(int frame); - void saveFrame(int frame); - void saveFrame(); - void deleteFrame(int frame); - - void loadFrame(int frame, const SireBase::PropertyMap &map); - void saveFrame(int frame, const SireBase::PropertyMap &map); - void saveFrame(const SireBase::PropertyMap &map); - void deleteFrame(int frame, const SireBase::PropertyMap &map); - - const_iterator begin() const; - const_iterator end() const; - - const_iterator constBegin() const; - const_iterator constEnd() const; - - virtual QString toString() const; - -protected: - /** The actual list of molecules */ - QList mols; -}; + SelectorM atoms() const; + SelectorM atoms(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM atoms(const AtomID &atomid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM residues() const; + SelectorM residues(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM residues(const ResID &resid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM chains() const; + SelectorM chains(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM chains(const ChainID &chainid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM segments() const; + SelectorM segments(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM segments(const SegID &segid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectorM cutGroups() const; + SelectorM cutGroups(int i, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const SireBase::Slice &slice, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const QList &idxs, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const QString &name, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + SelectorM cutGroups(const CGID &cgid, + const SireBase::PropertyMap &map = SireBase::PropertyMap()) const; + + SelectResult search(const QString &search_string) const; + SelectResult search(const QString &search_string, + const SireBase::PropertyMap &map) const; + + QVector molNums() const; + + QList IDs() const; + QList indexes() const; + QList numbers() const; + QList names() const; + + int nAtoms() const; + int nResidues() const; + int nChains() const; + int nSegments() const; + int nCutGroups() const; + int nMolecules() const; + + bool isEmpty() const; + + int nFrames() const; + int nFrames(const SireBase::PropertyMap &map) const; + + void loadFrame(int frame); + void saveFrame(int frame); + void saveFrame(); + void deleteFrame(int frame); + + void loadFrame(int frame, const SireBase::PropertyMap &map); + void saveFrame(int frame, const SireBase::PropertyMap &map); + void saveFrame(const SireBase::PropertyMap &map); + void deleteFrame(int frame, const SireBase::PropertyMap &map); + + const_iterator begin() const; + const_iterator end() const; + + const_iterator constBegin() const; + const_iterator constEnd() const; + + virtual QString toString() const; + + protected: + /** The actual list of molecules */ + QList mols; + }; } @@ -335,11 +338,11 @@ Q_DECLARE_METATYPE(SireMol::SelectorM); SIRE_EXPOSE_CLASS(SireMol::SelectorMol) -SIRE_EXPOSE_ALIAS( SireMol::SelectorM, SireMol::SelectorM_Atom_ ) -SIRE_EXPOSE_ALIAS( SireMol::SelectorM, SireMol::SelectorM_Residue_ ) -SIRE_EXPOSE_ALIAS( SireMol::SelectorM, SireMol::SelectorM_Chain_ ) -SIRE_EXPOSE_ALIAS( SireMol::SelectorM, SireMol::SelectorM_Segment_ ) -SIRE_EXPOSE_ALIAS( SireMol::SelectorM, SireMol::SelectorM_CutGroup_ ) +SIRE_EXPOSE_ALIAS(SireMol::SelectorM, SireMol::SelectorM_Atom_) +SIRE_EXPOSE_ALIAS(SireMol::SelectorM, SireMol::SelectorM_Residue_) +SIRE_EXPOSE_ALIAS(SireMol::SelectorM, SireMol::SelectorM_Chain_) +SIRE_EXPOSE_ALIAS(SireMol::SelectorM, SireMol::SelectorM_Segment_) +SIRE_EXPOSE_ALIAS(SireMol::SelectorM, SireMol::SelectorM_CutGroup_) // include this here so that SelectorM is always instantiatable if // SelectorMol has been included @@ -350,61 +353,61 @@ SIRE_EXPOSE_ALIAS( SireMol::SelectorM, SireMol::SelectorM_Cut namespace SireMol { -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol::SelectorMol(const SelectorM &other) - : SireBase::ConcreteProperty() -{ - if (not other.isEmpty()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol::SelectorMol(const SelectorM &other) + : SireBase::ConcreteProperty() { - this->mols.reserve(other.nMolecules()); - - for (int i=0; imols.append(other.molecule(i)); + this->mols.reserve(other.nMolecules()); + + for (int i = 0; i < other.nMolecules(); ++i) + { + this->mols.append(other.molecule(i)); + } } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol::SelectorMol(const SelectorM &other, const QString &name, - const PropertyMap &map) - : SireBase::ConcreteProperty() -{ - this->operator=(SelectorMol(other).molecules(name, map)); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol::SelectorMol(const SelectorM &other, const QString &name, + const PropertyMap &map) + : SireBase::ConcreteProperty() + { + this->operator=(SelectorMol(other).molecules(name, map)); + } -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol::SelectorMol(const SelectorM &other, const SireBase::Slice &slice) - : SireBase::ConcreteProperty() -{ - for (auto it = slice.begin(other.nMolecules()); - not it.atEnd(); it.next()) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol::SelectorMol(const SelectorM &other, const SireBase::Slice &slice) + : SireBase::ConcreteProperty() { - this->mols.append(other.molecule(it.value())); + for (auto it = slice.begin(other.nMolecules()); + not it.atEnd(); it.next()) + { + this->mols.append(other.molecule(it.value())); + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol::SelectorMol(const SelectorM &other, const QList &idxs) - : SireBase::ConcreteProperty() -{ - for (const auto &idx : idxs) + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol::SelectorMol(const SelectorM &other, const QList &idxs) + : SireBase::ConcreteProperty() { - this->mols.append(other.molecule(idx)); + for (const auto &idx : idxs) + { + this->mols.append(other.molecule(idx)); + } } -} -template -SIRE_OUTOFLINE_TEMPLATE -SelectorMol::SelectorMol(const SelectorM &other, const MolID &molid) - : SireBase::ConcreteProperty() -{ - this->operator=(other.molecules().molecules(molid)); -} + template + SIRE_OUTOFLINE_TEMPLATE + SelectorMol::SelectorMol(const SelectorM &other, const MolID &molid) + : SireBase::ConcreteProperty() + { + this->operator=(other.molecules().molecules(molid)); + } } // end of namespace SireMol @@ -420,7 +423,7 @@ template class SireMol::SelectorM; template class SireMol::SelectorM; template class SireMol::SelectorM; -#endif //SIRE_INSTANTIATE_TEMPLATES +#endif // SIRE_INSTANTIATE_TEMPLATES SIRE_END_HEADER diff --git a/doc/source/conf.py b/doc/source/conf.py index 8f0109928..57e70eb71 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -174,7 +174,7 @@ # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = "images/favicon.ico" +html_favicon = "images/favicon.png" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/doc/source/images/favicon.ico b/doc/source/images/favicon.ico deleted file mode 100644 index fb6d36171b10a98d4ddbdf088be4cd6b916a6528..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4286 zcmb_fYiv|S6ut#4(0xB|cemYLC`hG93Wb6^bV(^t3WW*s#hQvoO5)%^f1yNrK{@t}w7^(92gdqe zVQ8phXKQpzsZl+Bpw?N$1-d#!i z(e?u8CKD`?CfE)F=Dk0{SQTRH!cePH9NvfN4Eb^N8zeMlNIaS!FQ1=QvRKMFux>1d zZ5v?S4p?@r)b#p%nCr&Ec;p(4?~xykXJ9<(ijAXGcjJPyCu{6-wv7$&MiS&Q zP{N!GBIlQ4aWWiPLb-Sd!%6a^sZ{2H@d zTuYnbe7#!C7x8A#on372%nnPD1ugnh%euoJ#@>wQ?tR*2c+myb7B?S`oibbo|?^#N&@ z@ni4shMe$ZH^Mg)NX+>Gp1c=hF$$I5FOT}&CW`sR=b@80ge&sldLnigBgK*|~HJ#2cINw+gcM0u()mLx{AGC4y zh#9u+$6>3bep$X+>YpU_-!f3AxZ%w@3vVuQVFqzx7I8DbLgoSLf`N2~eh#&W__^#9 z#o;r!Hj*F3=V2`gP@gD;eJjOf8}*6EGU7rPJx6 zvJ4)okHp!x=a9zCV2} zl1Ba^ZJ=D!++GNV`Y|2VXpq;aciIsC9$d=x{JGt?jPOhR55w%8T`~M&#qbY*0RIHu z#~3!7r`57=@>qDMQ|xoc34KRr2J7K%^_^k!by|A>0;xqv9@-+uYkswIo;WdtI6*wf z8r>1TocFX6X=$RL22x5e;5i^E^?A95v~j$oi3^cD74T)fz~8$#yX6{PNs2Q+d*SyF zMIhxGf~kOiNFxSjSOjkRVB+Q{@Dn$E6Fww9(0{j`bGj?c_I85fx-JJ4tL>C3(K`df9<@UKQ95OvQweBXBQz)iEMJW=Vj^zMzqqj9!FH{-A7 zw0N%O|8qOvgAo^gdUQDy7ggfpqkfMkI>Ox?b*X{qXcbW(-F;L%y1W(`@DBb3-bh-V diff --git a/doc/source/images/favicon.png b/doc/source/images/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..abedad0c6a358be614be8e60a5d3de964a922c96 GIT binary patch literal 1478 zcmV;%1v&bOP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91AfN*P1ONa40RR91AOHXW0IY^$^8f$^FiAu~R9FeES6ysWMHHShGk14e zmP%S7QA86Gm0)=AFUAOwU@+mqK#f3DC`)O#KwF{ohw{Jt2y6wmAT2+(wiKvBQDcY_ zADZ}LLQD`6m8dTmBGNvPLfLkAyL;z&W|xg@yLaz)!=&B2Gv_QSiCOuv=ZWDrr<*X_=jZdd5-KS4y>*#;P~0X&32gE zA?A9}wXi0#&lK`cKzLOG6rT?`W=b$#;S8eO#LH#Xk#6sLe8MhPI=d}_qJqI`g7HSK zl>f$%oOLcBztw@d4#Cx~X5%e^xR8Rp4`z6Nx&(G(wghwl$&g8eOIJ=pbacS>PhA&j zJD3=4$g;0}ZJR{KR0b5SLS{e)Ut0oBa@MoUG($o8=`W{dy9ExNoT57r-}8DgKQ#-& zhN{pq9mK)-{JOfn390r(Z@)J*`_QU;h3RazGF-eE9R*WkwL+;zKsG3q+B$i%>-4=l zu{lhs103;1lHzwl;oGE;+g!0VyN0fM_xb{`-If8fHNGRvty6==T^%{m!6Fz z$=DJ|0$11Fp8^rXXCN!58TS#Hr)Xuq7XS_Z7U%Dq%EQk|fhVXQ<_ZR9=!_Vq@2lu} zRdT)slsTL5wbbu302(XW^DZz(!cHd0_E}pMnSrS4C6nDvEkmVaFSO4`_f`%TS&`7P zr8;n@v!C#yL8q!KnK)&o)~-djU5K?cNg?KkNA3EL_3adKF`1;r{UaAOIbxp{-S+sAi}Rvzkw^fL)2=8 zsW_3?%K;y!=MjoKoBro$i83~_bxBv@O&vE*pt?G;omlUneg_lIEr$<7|LCOY`Ukv& zGo&dFQQ`#xVFW-mE9ZpWm8}re_zuqvmt;lNoa9JLeoZj5Zpo=hSH{GusSG#K|FtoO zEC*Ukhw#{{p$aQ_*K$mIL~DFp1@VH&blq7+elV_OhcOnif|Z2dtqt)<)fv;ucyJL4D~F(|89Xfc-=t0jn4Kxc@X+4 z1(0PYMSKD8&`XXOJ1i03;GCazL|NmCuKZgM$2#u`&H@vgsb=QU-d{jz)E9T={rxaz zJl|6YBpeaiJi(>(Yse4GERrbpMIry-W9t5dD1%*eXH?MH{~O(y>x<7!{BbaRKd@Ne&5BV+1$}3tEVgLXD07*qoM6N<$f*i-I!vFvP literal 0 HcmV?d00001 diff --git a/doc/source/images/logo.svg b/doc/source/images/logo.svg index af2baf0f3..ccea389f5 100644 --- a/doc/source/images/logo.svg +++ b/doc/source/images/logo.svg @@ -1,67 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/src/sire/mol/__init__.py b/src/sire/mol/__init__.py index 8ce6270ca..749d4eaba 100644 --- a/src/sire/mol/__init__.py +++ b/src/sire/mol/__init__.py @@ -1355,7 +1355,9 @@ def _total_energy(obj, other=None, map=None): elif other is None: return calculate_energy(mols.molecules(), map=map) else: - return calculate_energy(mols.molecules(), _to_molecules(other), map=map) + return calculate_energy( + mols.molecules(), _to_molecules(other), map=map + ) Atom.energy = _atom_energy @@ -1404,5 +1406,60 @@ def _total_energy(obj, other=None, map=None): SelectorM_Segment_.view = _viewfunc SelectorM_CutGroup_.view = _viewfunc +if not hasattr(SelectorMol, "__orig__find__"): + + def __find__(obj, views): + """ + Find the index(es) of the passed view(s) in this container. + This returns a single index if a single view is passed, + or a list of indexes if multiple views are passed + (in the same order as the passed views). + + This raises an IndexError if any of the views are + not in this container. + """ + matches = obj.__orig__find__(views) + + if matches is None: + raise IndexError("Cannot find the passed view in the container.") + + if views.is_selector(): + if len(matches) != len(views): + raise IndexError( + "Could not find all of the passed views " + "in the container. We only found " + f"{len(matches)} of the required " + f"{len(views)}." + ) + + return matches + else: + if len(matches) != 1: + raise IndexError( + "We matched too many indexes? " + f"{matches}. Only expected to match one?" + ) + + return matches[0] + + def __fix__find(CLASS): + CLASS.__orig__find__ = CLASS.find + CLASS.find = __find__ + + for C in [ + Selector_Atom_, + Selector_Residue_, + Selector_Chain_, + Selector_CutGroup_, + Selector_Segment_, + SelectorMol, + SelectorM_Atom_, + SelectorM_Residue_, + SelectorM_Chain_, + SelectorM_CutGroup_, + SelectorM_Segment_, + ]: + __fix__find(C) + # Remove some temporary variables del C diff --git a/src/sire/system/_system.py b/src/sire/system/_system.py index 5948ced7e..20c00d2a7 100644 --- a/src/sire/system/_system.py +++ b/src/sire/system/_system.py @@ -85,6 +85,10 @@ def num_molecules(self): """Return the number of molecules in this System""" return self._system.num_molecules() + def find(self, views): + """Return the index(es) of the molecule(s) that are in `views`""" + return self.molecules().find(views) + def names(self): """Return the names of all of the molecules in this System""" return self.molecules().names() diff --git a/tests/mol/test_find.py b/tests/mol/test_find.py new file mode 100644 index 000000000..1e0d996ac --- /dev/null +++ b/tests/mol/test_find.py @@ -0,0 +1,31 @@ +import pytest + + +def test_find(ala_mols): + + mols = ala_mols + + assert mols.atoms().find(mols.atoms()[0]) == 0 + + assert mols.atoms().find(mols.atoms()[1000]) == 1000 + + assert mols.atoms().find(mols.atoms()[10:100]) == list(range(10, 100)) + + idxs = mols.atoms().find(mols["element C"]) + + assert len(idxs) == len(mols["element C"]) + + for idx in idxs: + assert mols.atoms()[idx].element().num_protons() == 6 + + assert mols.residues().find(mols["resname ALA"]) == 1 + + assert mols.find(mols[600]) == 600 + + assert mols.find(mols[3:50:3]) == list(range(3, 50, 3)) + + with pytest.raises(IndexError): + mols[1:].find(mols[0]) + + with pytest.raises(IndexError): + mols[1:].atoms().find(mols["element C"]) diff --git a/wrapper/Mol/Atom.pypp.cpp b/wrapper/Mol/Atom.pypp.cpp index 61327a54a..4eb4a032f 100644 --- a/wrapper/Mol/Atom.pypp.cpp +++ b/wrapper/Mol/Atom.pypp.cpp @@ -94,6 +94,8 @@ namespace bp = boost::python; #include "atomproperty.hpp" +#include "SireMol/core.h" + const SireMM::LJParameter& get_Metadata_SireMM_AtomLJs_function1(const SireMol::Atom &atom, const QString &metakey){ return atom.metadata< SireMM::LJParameter >(metakey); } diff --git a/wrapper/Mol/Bead.pypp.cpp b/wrapper/Mol/Bead.pypp.cpp index bdac5958c..fe1f04f04 100644 --- a/wrapper/Mol/Bead.pypp.cpp +++ b/wrapper/Mol/Bead.pypp.cpp @@ -42,6 +42,8 @@ namespace bp = boost::python; #include "beadproperty.hpp" +#include "SireMol/core.h" + const QString& get_Metadata_SireMol_BeadStringProperty_function1(const SireMol::Bead &atom, const QString &metakey){ return atom.metadata< QString >(metakey); } diff --git a/wrapper/Mol/Chain.pypp.cpp b/wrapper/Mol/Chain.pypp.cpp index 9ce0e5144..1ce7097a8 100644 --- a/wrapper/Mol/Chain.pypp.cpp +++ b/wrapper/Mol/Chain.pypp.cpp @@ -39,6 +39,8 @@ namespace bp = boost::python; #include "chainproperty.hpp" +#include "SireMol/core.h" + const QString& get_Metadata_SireMol_ChainStringProperty_function1(const SireMol::Chain &atom, const QString &metakey){ return atom.metadata< QString >(metakey); } diff --git a/wrapper/Mol/CutGroup.pypp.cpp b/wrapper/Mol/CutGroup.pypp.cpp index e19cd758a..9303a025d 100644 --- a/wrapper/Mol/CutGroup.pypp.cpp +++ b/wrapper/Mol/CutGroup.pypp.cpp @@ -40,6 +40,8 @@ namespace bp = boost::python; #include "cgproperty.hpp" +#include "SireMol/core.h" + const QString& get_Metadata_SireMol_CGStringProperty_function1(const SireMol::CutGroup &atom, const QString &metakey){ return atom.metadata< QString >(metakey); } diff --git a/wrapper/Mol/Residue.pypp.cpp b/wrapper/Mol/Residue.pypp.cpp index 9983880d5..430476f5d 100644 --- a/wrapper/Mol/Residue.pypp.cpp +++ b/wrapper/Mol/Residue.pypp.cpp @@ -41,6 +41,8 @@ namespace bp = boost::python; #include "resproperty.hpp" +#include "SireMol/core.h" + const QString& get_Metadata_SireMol_ResStringProperty_function1(const SireMol::Residue &atom, const QString &metakey){ return atom.metadata< QString >(metakey); } diff --git a/wrapper/Mol/Segment.pypp.cpp b/wrapper/Mol/Segment.pypp.cpp index 0858959d5..8e6dbbeed 100644 --- a/wrapper/Mol/Segment.pypp.cpp +++ b/wrapper/Mol/Segment.pypp.cpp @@ -36,6 +36,8 @@ namespace bp = boost::python; #include "segproperty.hpp" +#include "SireMol/core.h" + const QString& get_Metadata_SireMol_SegStringProperty_function1(const SireMol::Segment &atom, const QString &metakey){ return atom.metadata< QString >(metakey); } diff --git a/wrapper/Mol/SelectorM_Atom_.pypp.cpp b/wrapper/Mol/SelectorM_Atom_.pypp.cpp index 8c82a8db6..5595754ae 100644 --- a/wrapper/Mol/SelectorM_Atom_.pypp.cpp +++ b/wrapper/Mol/SelectorM_Atom_.pypp.cpp @@ -579,6 +579,48 @@ void register_SelectorM_Atom__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::SelectorM< SireMol::Atom >::find + + typedef SireMol::SelectorM< SireMol::Atom > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Atom >::*find_function_type)( ::SireMol::Atom const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Atom >::find ); + + SelectorM_Atom__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Atom >::find + + typedef SireMol::SelectorM< SireMol::Atom > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Atom >::*find_function_type)( ::SireMol::Selector< SireMol::Atom > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Atom >::find ); + + SelectorM_Atom__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Atom >::find + + typedef SireMol::SelectorM< SireMol::Atom > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Atom >::*find_function_type)( ::SireMol::SelectorM< SireMol::Atom > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Atom >::find ); + + SelectorM_Atom__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::SelectorM< SireMol::Atom >::indexes diff --git a/wrapper/Mol/SelectorM_Chain_.pypp.cpp b/wrapper/Mol/SelectorM_Chain_.pypp.cpp index a07980d3c..b3a917790 100644 --- a/wrapper/Mol/SelectorM_Chain_.pypp.cpp +++ b/wrapper/Mol/SelectorM_Chain_.pypp.cpp @@ -579,6 +579,48 @@ void register_SelectorM_Chain__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::SelectorM< SireMol::Chain >::find + + typedef SireMol::SelectorM< SireMol::Chain > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Chain >::*find_function_type)( ::SireMol::Chain const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Chain >::find ); + + SelectorM_Chain__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Chain >::find + + typedef SireMol::SelectorM< SireMol::Chain > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Chain >::*find_function_type)( ::SireMol::Selector< SireMol::Chain > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Chain >::find ); + + SelectorM_Chain__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Chain >::find + + typedef SireMol::SelectorM< SireMol::Chain > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Chain >::*find_function_type)( ::SireMol::SelectorM< SireMol::Chain > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Chain >::find ); + + SelectorM_Chain__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::SelectorM< SireMol::Chain >::indexes diff --git a/wrapper/Mol/SelectorM_CutGroup_.pypp.cpp b/wrapper/Mol/SelectorM_CutGroup_.pypp.cpp index 33161f3bd..2cb0a019b 100644 --- a/wrapper/Mol/SelectorM_CutGroup_.pypp.cpp +++ b/wrapper/Mol/SelectorM_CutGroup_.pypp.cpp @@ -579,6 +579,48 @@ void register_SelectorM_CutGroup__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::SelectorM< SireMol::CutGroup >::find + + typedef SireMol::SelectorM< SireMol::CutGroup > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::CutGroup >::*find_function_type)( ::SireMol::CutGroup const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::CutGroup >::find ); + + SelectorM_CutGroup__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::CutGroup >::find + + typedef SireMol::SelectorM< SireMol::CutGroup > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::CutGroup >::*find_function_type)( ::SireMol::Selector< SireMol::CutGroup > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::CutGroup >::find ); + + SelectorM_CutGroup__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::CutGroup >::find + + typedef SireMol::SelectorM< SireMol::CutGroup > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::CutGroup >::*find_function_type)( ::SireMol::SelectorM< SireMol::CutGroup > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::CutGroup >::find ); + + SelectorM_CutGroup__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::SelectorM< SireMol::CutGroup >::indexes diff --git a/wrapper/Mol/SelectorM_Residue_.pypp.cpp b/wrapper/Mol/SelectorM_Residue_.pypp.cpp index 782ca3bc1..f10148a37 100644 --- a/wrapper/Mol/SelectorM_Residue_.pypp.cpp +++ b/wrapper/Mol/SelectorM_Residue_.pypp.cpp @@ -579,6 +579,48 @@ void register_SelectorM_Residue__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::SelectorM< SireMol::Residue >::find + + typedef SireMol::SelectorM< SireMol::Residue > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Residue >::*find_function_type)( ::SireMol::Residue const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Residue >::find ); + + SelectorM_Residue__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Residue >::find + + typedef SireMol::SelectorM< SireMol::Residue > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Residue >::*find_function_type)( ::SireMol::Selector< SireMol::Residue > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Residue >::find ); + + SelectorM_Residue__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Residue >::find + + typedef SireMol::SelectorM< SireMol::Residue > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Residue >::*find_function_type)( ::SireMol::SelectorM< SireMol::Residue > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Residue >::find ); + + SelectorM_Residue__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::SelectorM< SireMol::Residue >::indexes diff --git a/wrapper/Mol/SelectorM_Segment_.pypp.cpp b/wrapper/Mol/SelectorM_Segment_.pypp.cpp index 2b6984953..76e147759 100644 --- a/wrapper/Mol/SelectorM_Segment_.pypp.cpp +++ b/wrapper/Mol/SelectorM_Segment_.pypp.cpp @@ -579,6 +579,48 @@ void register_SelectorM_Segment__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::SelectorM< SireMol::Segment >::find + + typedef SireMol::SelectorM< SireMol::Segment > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Segment >::*find_function_type)( ::SireMol::Segment const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Segment >::find ); + + SelectorM_Segment__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Segment >::find + + typedef SireMol::SelectorM< SireMol::Segment > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Segment >::*find_function_type)( ::SireMol::Selector< SireMol::Segment > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Segment >::find ); + + SelectorM_Segment__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorM< SireMol::Segment >::find + + typedef SireMol::SelectorM< SireMol::Segment > exported_class_t; + typedef ::QList< long long > ( ::SireMol::SelectorM< SireMol::Segment >::*find_function_type)( ::SireMol::SelectorM< SireMol::Segment > const & ) const; + find_function_type find_function_value( &::SireMol::SelectorM< SireMol::Segment >::find ); + + SelectorM_Segment__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::SelectorM< SireMol::Segment >::indexes diff --git a/wrapper/Mol/SelectorMol.pypp.cpp b/wrapper/Mol/SelectorMol.pypp.cpp index 69de8f0ce..5a3a75ad2 100644 --- a/wrapper/Mol/SelectorMol.pypp.cpp +++ b/wrapper/Mol/SelectorMol.pypp.cpp @@ -474,6 +474,32 @@ void register_SelectorMol_class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::SelectorMol::find + + typedef ::QList< long long > ( ::SireMol::SelectorMol::*find_function_type)( ::SireMol::Molecule const & ) const; + find_function_type find_function_value( &::SireMol::SelectorMol::find ); + + SelectorMol_exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::SelectorMol::find + + typedef ::QList< long long > ( ::SireMol::SelectorMol::*find_function_type)( ::SireMol::SelectorMol const & ) const; + find_function_type find_function_value( &::SireMol::SelectorMol::find ); + + SelectorMol_exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::SelectorMol::indexes diff --git a/wrapper/Mol/Selector_Atom_.pypp.cpp b/wrapper/Mol/Selector_Atom_.pypp.cpp index 4ee98ab8c..9a5f3b2dd 100644 --- a/wrapper/Mol/Selector_Atom_.pypp.cpp +++ b/wrapper/Mol/Selector_Atom_.pypp.cpp @@ -45,6 +45,8 @@ namespace bp = boost::python; #include "atom.h" +#include "SireMol/core.h" + SireMol::Selector __copy__(const SireMol::Selector &other){ return SireMol::Selector(other); } #include "Qt/qdatastream.hpp" @@ -204,6 +206,48 @@ void register_Selector_Atom__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::Selector< SireMol::Atom >::find + + typedef SireMol::Selector< SireMol::Atom > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Atom >::*find_function_type)( ::SireMol::Atom const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Atom >::find ); + + Selector_Atom__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Atom >::find + + typedef SireMol::Selector< SireMol::Atom > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Atom >::*find_function_type)( ::SireMol::Selector< SireMol::Atom > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Atom >::find ); + + Selector_Atom__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Atom >::find + + typedef SireMol::Selector< SireMol::Atom > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Atom >::*find_function_type)( ::SireMol::SelectorM< SireMol::Atom > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Atom >::find ); + + Selector_Atom__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::Selector< SireMol::Atom >::hasMetadata diff --git a/wrapper/Mol/Selector_Chain_.pypp.cpp b/wrapper/Mol/Selector_Chain_.pypp.cpp index 69e297c92..1c7701aad 100644 --- a/wrapper/Mol/Selector_Chain_.pypp.cpp +++ b/wrapper/Mol/Selector_Chain_.pypp.cpp @@ -37,6 +37,8 @@ namespace bp = boost::python; #include "chain.h" +#include "SireMol/core.h" + SireMol::Selector __copy__(const SireMol::Selector &other){ return SireMol::Selector(other); } #include "Qt/qdatastream.hpp" @@ -196,6 +198,48 @@ void register_Selector_Chain__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::Selector< SireMol::Chain >::find + + typedef SireMol::Selector< SireMol::Chain > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Chain >::*find_function_type)( ::SireMol::Chain const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Chain >::find ); + + Selector_Chain__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Chain >::find + + typedef SireMol::Selector< SireMol::Chain > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Chain >::*find_function_type)( ::SireMol::Selector< SireMol::Chain > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Chain >::find ); + + Selector_Chain__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Chain >::find + + typedef SireMol::Selector< SireMol::Chain > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Chain >::*find_function_type)( ::SireMol::SelectorM< SireMol::Chain > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Chain >::find ); + + Selector_Chain__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::Selector< SireMol::Chain >::hasMetadata diff --git a/wrapper/Mol/Selector_CutGroup_.pypp.cpp b/wrapper/Mol/Selector_CutGroup_.pypp.cpp index d12737098..e1204ca27 100644 --- a/wrapper/Mol/Selector_CutGroup_.pypp.cpp +++ b/wrapper/Mol/Selector_CutGroup_.pypp.cpp @@ -37,6 +37,8 @@ namespace bp = boost::python; #include "cutgroup.h" +#include "SireMol/core.h" + SireMol::Selector __copy__(const SireMol::Selector &other){ return SireMol::Selector(other); } #include "Qt/qdatastream.hpp" @@ -196,6 +198,48 @@ void register_Selector_CutGroup__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::Selector< SireMol::CutGroup >::find + + typedef SireMol::Selector< SireMol::CutGroup > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::CutGroup >::*find_function_type)( ::SireMol::CutGroup const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::CutGroup >::find ); + + Selector_CutGroup__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::CutGroup >::find + + typedef SireMol::Selector< SireMol::CutGroup > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::CutGroup >::*find_function_type)( ::SireMol::Selector< SireMol::CutGroup > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::CutGroup >::find ); + + Selector_CutGroup__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::CutGroup >::find + + typedef SireMol::Selector< SireMol::CutGroup > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::CutGroup >::*find_function_type)( ::SireMol::SelectorM< SireMol::CutGroup > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::CutGroup >::find ); + + Selector_CutGroup__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::Selector< SireMol::CutGroup >::hasMetadata diff --git a/wrapper/Mol/Selector_Residue_.pypp.cpp b/wrapper/Mol/Selector_Residue_.pypp.cpp index 70ea1b1f4..ed25f804b 100644 --- a/wrapper/Mol/Selector_Residue_.pypp.cpp +++ b/wrapper/Mol/Selector_Residue_.pypp.cpp @@ -39,6 +39,8 @@ namespace bp = boost::python; #include "residue.h" +#include "SireMol/core.h" + SireMol::Selector __copy__(const SireMol::Selector &other){ return SireMol::Selector(other); } #include "Qt/qdatastream.hpp" @@ -198,6 +200,48 @@ void register_Selector_Residue__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::Selector< SireMol::Residue >::find + + typedef SireMol::Selector< SireMol::Residue > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Residue >::*find_function_type)( ::SireMol::Residue const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Residue >::find ); + + Selector_Residue__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Residue >::find + + typedef SireMol::Selector< SireMol::Residue > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Residue >::*find_function_type)( ::SireMol::Selector< SireMol::Residue > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Residue >::find ); + + Selector_Residue__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Residue >::find + + typedef SireMol::Selector< SireMol::Residue > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Residue >::*find_function_type)( ::SireMol::SelectorM< SireMol::Residue > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Residue >::find ); + + Selector_Residue__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::Selector< SireMol::Residue >::hasMetadata diff --git a/wrapper/Mol/Selector_Segment_.pypp.cpp b/wrapper/Mol/Selector_Segment_.pypp.cpp index a822286d5..3d2c08d4c 100644 --- a/wrapper/Mol/Selector_Segment_.pypp.cpp +++ b/wrapper/Mol/Selector_Segment_.pypp.cpp @@ -33,6 +33,8 @@ namespace bp = boost::python; #include "segment.h" +#include "SireMol/core.h" + SireMol::Selector __copy__(const SireMol::Selector &other){ return SireMol::Selector(other); } #include "Qt/qdatastream.hpp" @@ -192,6 +194,48 @@ void register_Selector_Segment__class(){ , bp::release_gil_policy() , "" ); + } + { //::SireMol::Selector< SireMol::Segment >::find + + typedef SireMol::Selector< SireMol::Segment > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Segment >::*find_function_type)( ::SireMol::Segment const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Segment >::find ); + + Selector_Segment__exposer.def( + "find" + , find_function_value + , ( bp::arg("view") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Segment >::find + + typedef SireMol::Selector< SireMol::Segment > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Segment >::*find_function_type)( ::SireMol::Selector< SireMol::Segment > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Segment >::find ); + + Selector_Segment__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + + } + { //::SireMol::Selector< SireMol::Segment >::find + + typedef SireMol::Selector< SireMol::Segment > exported_class_t; + typedef ::QList< long long > ( ::SireMol::Selector< SireMol::Segment >::*find_function_type)( ::SireMol::SelectorM< SireMol::Segment > const & ) const; + find_function_type find_function_value( &::SireMol::Selector< SireMol::Segment >::find ); + + Selector_Segment__exposer.def( + "find" + , find_function_value + , ( bp::arg("views") ) + , bp::release_gil_policy() + , "" ); + } { //::SireMol::Selector< SireMol::Segment >::hasMetadata diff --git a/wrapper/Mol/special_code.py b/wrapper/Mol/special_code.py index 174582b7e..7a00c0cec 100644 --- a/wrapper/Mol/special_code.py +++ b/wrapper/Mol/special_code.py @@ -25,11 +25,18 @@ return_const = "bp::return_value_policy()" return_self = "bp::return_self< >()" +def fix_Selector(c): + #add in the core header files + c.add_declaration_code( "#include \"SireMol/core.h\"" ) + def fix_MolView(c, molview, props): #now add in all of the header files for header in props.dependencies(): c.add_declaration_code( "#include %s" % header ) + #add in the core header files + c.add_declaration_code( "#include \"SireMol/core.h\"" ) + #add accessor functions for all of the view properties for property in props.properties(): p = property[0] @@ -448,6 +455,12 @@ def fix_SelectResultMover(c): "SireMol::PerturbationSymbols" : fix_PerturbationSymbols, + "SireMol::Selector" : fix_Selector, + "SireMol::Selector" : fix_Selector, + "SireMol::Selector" : fix_Selector, + "SireMol::Selector" : fix_Selector, + "SireMol::Selector" : fix_Selector, + "SireMol::CGIdx" : fix_CGIdx, "SireMol::CGAtomIdx" : fix_CGAtomIdx }