00001 // 00002 // Copyright (C) 2001-2006 Greg Landrum and Rational Discovery LLC 00003 // 00004 // @@ All Rights Reserved @@ 00005 // This file is part of the RDKit. 00006 // The contents are covered by the terms of the BSD license 00007 // which is included in the file license.txt, found at the root 00008 // of the RDKit source tree. 00009 // 00010 #ifndef _RD_QUERYATOM_H_ 00011 #define _RD_QUERYATOM_H_ 00012 00013 #include "Atom.h" 00014 #include <Query/QueryObjects.h> 00015 #include <GraphMol/QueryOps.h> 00016 00017 namespace RDKit{ 00018 00019 //! Class for storing atomic queries 00020 /*! 00021 QueryAtom objects are derived from Atom objects, so they can be 00022 added to molecules and the like, but they have much fancier 00023 querying capabilities. 00024 00025 */ 00026 class QueryAtom : public Atom { 00027 public: 00028 typedef Queries::Query<int,Atom const *,true> QUERYATOM_QUERY; 00029 00030 QueryAtom() : Atom(), dp_query(NULL) {}; 00031 explicit QueryAtom(int num) : Atom(num), dp_query(makeAtomNumEqualsQuery(num)) {}; 00032 explicit QueryAtom(const Atom &other) : Atom(other), dp_query(makeAtomNumEqualsQuery(other.getAtomicNum())) {}; 00033 QueryAtom( const QueryAtom & other) : Atom(other),dp_query(other.dp_query->copy()){}; 00034 ~QueryAtom(); 00035 00036 00037 //! returns a copy of this query, owned by the caller 00038 Atom *copy() const; 00039 00040 // This method can be used to distinguish query atoms from standard atoms: 00041 bool hasQuery() const { return dp_query!=0; }; 00042 00043 //! replaces our current query with the value passed in 00044 void setQuery(QUERYATOM_QUERY *what) { dp_query = what; } 00045 //! returns our current query 00046 QUERYATOM_QUERY *getQuery() const { return dp_query; }; 00047 00048 //! expands our current query 00049 /*! 00050 \param what the Queries::Query to be added 00051 \param how the operator to be used in the expansion 00052 \param maintainOrder (optional) flags whether the relative order of 00053 the queries needs to be maintained, if this is 00054 false, the order is reversed 00055 <b>Notes:</b> 00056 - \c what should probably be constructed using one of the functions 00057 defined in QueryOps.h 00058 - the \c maintainOrder option can be useful because the combination 00059 operators short circuit when possible. 00060 00061 */ 00062 void expandQuery(QUERYATOM_QUERY *what, 00063 Queries::CompositeQueryType how=Queries::COMPOSITE_AND, 00064 bool maintainOrder=true); 00065 00066 //! returns true if we match Atom \c what 00067 bool Match(const Atom::ATOM_SPTR what) const; 00068 //! \overload 00069 bool Match(Atom const *what) const; 00070 00071 private: 00072 QUERYATOM_QUERY *dp_query; 00073 00074 }; // end o' class 00075 00076 }; // end o' namespace 00077 00078 00079 #endif
1.7.1