QueryAtom.h
Go to the documentation of this file.
//
// Copyright (C) 2001-2006 Greg Landrum and Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#ifndef _RD_QUERYATOM_H_
#define _RD_QUERYATOM_H_
#include "Atom.h"
#include <Query/QueryObjects.h>
#include <GraphMol/QueryOps.h>
namespace RDKit {
//! Class for storing atomic queries
/*!
QueryAtom objects are derived from Atom objects, so they can be
added to molecules and the like, but they have much fancier
querying capabilities.
*/
class QueryAtom : public Atom {
public:
typedef Queries::Query<int, Atom const *, true> QUERYATOM_QUERY;
QueryAtom() : Atom(), dp_query(NULL){};
explicit QueryAtom(int num) : Atom(num), dp_query(makeAtomNumQuery(num)){};
explicit QueryAtom(const Atom &other)
: Atom(other), dp_query(makeAtomNumQuery(other.getAtomicNum())){};
QueryAtom(const QueryAtom &other) : Atom(other) {
dp_query = other.dp_query->copy();
};
~QueryAtom();
//! returns a copy of this query, owned by the caller
Atom *copy() const;
// This method can be used to distinguish query atoms from standard atoms:
bool hasQuery() const { return dp_query != 0; };
//! replaces our current query with the value passed in
void setQuery(QUERYATOM_QUERY *what) { dp_query = what; }
//! returns our current query
QUERYATOM_QUERY *getQuery() const { return dp_query; };
//! expands our current query
/*!
\param what the Queries::Query to be added
\param how the operator to be used in the expansion
\param maintainOrder (optional) flags whether the relative order of
the queries needs to be maintained, if this is
false, the order is reversed
<b>Notes:</b>
- \c what should probably be constructed using one of the functions
defined in QueryOps.h
- the \c maintainOrder option can be useful because the combination
operators short circuit when possible.
*/
void expandQuery(QUERYATOM_QUERY *what,
Queries::CompositeQueryType how = Queries::COMPOSITE_AND,
bool maintainOrder = true);
//! returns true if we match Atom \c what
bool Match(const Atom::ATOM_SPTR &what) const;
//! \overload
bool Match(Atom const *what) const;
//! returns true if our query details match those of QueryAtom \c what
bool QueryMatch(QueryAtom const *what) const;
private:
QUERYATOM_QUERY *dp_query;
}; // end o' class
}; // end o' namespace
#endif
RDKit::QueryAtom::getQuery
QUERYATOM_QUERY * getQuery() const
returns our current query
Definition: QueryAtom.h:48
RDKit::QueryAtom::QueryAtom
QueryAtom()
Definition: QueryAtom.h:30
RDKit::QueryAtom::QueryAtom
QueryAtom(int num)
Definition: QueryAtom.h:31
Queries::CompositeQueryType
CompositeQueryType
Definition: QueryObjects.h:35
RDKit::QueryAtom
Class for storing atomic queries.
Definition: QueryAtom.h:26
RDKit::QueryAtom::setQuery
void setQuery(QUERYATOM_QUERY *what)
replaces our current query with the value passed in
Definition: QueryAtom.h:46
RDKit::QueryAtom::QUERYATOM_QUERY
Queries::Query< int, Atom const *, true > QUERYATOM_QUERY
Definition: QueryAtom.h:28
RDKit::QueryAtom::~QueryAtom
~QueryAtom()
RDKit::QueryAtom::QueryAtom
QueryAtom(const QueryAtom &other)
Definition: QueryAtom.h:34
RDKit
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDKit::Atom::getAtomicNum
int getAtomicNum() const
returns our atomic number
Definition: Atom.h:115
RDKit::makeAtomNumQuery
T * makeAtomNumQuery(int what, const std::string &descr)
returns a Query for matching atomic number
Definition: QueryOps.h:210
QueryOps.h
RDKit::Atom::ATOM_SPTR
boost::shared_ptr< Atom > ATOM_SPTR
Definition: Atom.h:73
RDKit::QueryAtom::Match
bool Match(const Atom::ATOM_SPTR &what) const
returns true if we match Atom what
Atom.h
Defines the Atom class and associated typedefs.
QueryObjects.h
Pulls in all the query types.
RDKit::QueryAtom::hasQuery
bool hasQuery() const
Definition: QueryAtom.h:43
RDKit::QueryAtom::QueryAtom
QueryAtom(const Atom &other)
Definition: QueryAtom.h:32
Queries::Query
Base class for all queries.
Definition: Query.h:45
Queries::COMPOSITE_AND
Definition: QueryObjects.h:35
RDKit::QueryAtom::copy
Atom * copy() const
returns a copy of this query, owned by the caller
RDKit::Atom
The class for representing atoms.
Definition: Atom.h:67
RDKit::QueryAtom::expandQuery
void expandQuery(QUERYATOM_QUERY *what, Queries::CompositeQueryType how=Queries::COMPOSITE_AND, bool maintainOrder=true)
expands our current query
RDKit::QueryAtom::QueryMatch
bool QueryMatch(QueryAtom const *what) const
returns true if our query details match those of QueryAtom what
Queries::Query::copy
virtual Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
Definition: Query.h:125