32 #ifndef __RD_FILTER_CATALOG_H__
33 #define __RD_FILTER_CATALOG_H__
40 #ifdef RDK_USE_BOOST_SERIALIZATION
42 #include <boost/archive/text_oarchive.hpp>
43 #include <boost/archive/text_iarchive.hpp>
44 #include <boost/serialization/vector.hpp>
45 #include <boost/serialization/shared_ptr.hpp>
56 boost::shared_ptr<FilterMatcherBase> d_matcher;
63 :
RDCatalog::CatalogEntry(), d_matcher(matcher.Clone()) {
68 boost::shared_ptr<FilterMatcherBase> matcher)
69 :
RDCatalog::CatalogEntry(), d_matcher(matcher) {
75 d_matcher(rhs.d_matcher),
76 d_props(rhs.d_props) {}
83 bool isValid()
const {
return d_matcher.get() && d_matcher->isValid(); }
109 template <
typename T>
111 std::string what(key);
115 template <
typename T>
136 template <
typename T>
141 template <
typename T>
142 void getProp(
const std::string &key, T &res)
const {
146 template <
typename T>
148 return d_props.
getVal<T>(key);
151 template <
typename T>
153 return d_props.
getVal<T>(key);
158 template <
typename T>
163 template <
typename T>
172 return d_props.
hasVal(key);
178 std::string what(key);
199 std::vector<FilterMatch> &matchVect)
const {
200 return this->
isValid() && d_matcher->getMatches(mol, matchVect);
210 return this->
isValid() && d_matcher->hasMatch(mol);
214 virtual void toStream(std::ostream &ss)
const;
223 #ifdef RDK_USE_BOOST_SERIALIZATION
224 friend class boost::serialization::access;
225 template <
class Archive>
226 void save(Archive &ar,
const unsigned int version)
const {
228 registerFilterMatcherTypes(ar);
233 std::vector<std::string> string_props;
234 for (
size_t i = 0; i < keys.size(); ++i) {
238 string_props.push_back(keys[i]);
239 string_props.push_back(val);
241 }
catch (
const boost::bad_any_cast &) {
249 template <
class Archive>
250 void load(Archive &ar,
const unsigned int version) {
252 registerFilterMatcherTypes(ar);
255 std::vector<std::string> string_props;
259 for (
size_t i = 0; i < string_props.size() / 2; ++i) {
260 d_props.
setVal(string_props[i * 2], string_props[i * 2 + 1]);
264 BOOST_SERIALIZATION_SPLIT_MEMBER();
269 #ifdef RDK_USE_BOOST_SERIALIZATION
273 #endif //__RD_FILTER_CATALOG_H__
bool getFilterMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const
Returns the matching filters for this catalog entry.
T getProp(const char *key) const
void setProps(const Dict &props)
virtual ~FilterCatalogEntry()
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
bool getPropIfPresent(const char *key, T &res) const
STR_VECT keys() const
Returns the set of keys in the dictionary.
FilterCatalogEntry(const std::string &name, const FilterMatcherBase &matcher)
T getProp(const std::string &key) const
bool getValIfPresent(const std::string &what, T &res) const
Potentially gets the value associated with a particular key returns true on success/false on failure...
const Dict & getProps() const
std::string getDescription() const
Returns the description of the catalog entry.
void clearProp(const std::string &key)
virtual void initFromString(const std::string &text)
initializes from a string pickle
void getProp(const std::string &key, T &res) const
void setProp(const std::string &key, T val)
void clearProp(const char *key)
clears the value of a property
pulls in the core RDKit functionality
ROMol is a molecule class that is intended to have a fixed topology.
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
FilterCatalogEntry(const FilterCatalogEntry &rhs)
void setProp(const char *key, T val)
sets a property value
bool isValid() const
Returns true if the Filters stored in this catalog entry are valid.
std::map< std::string, std::string > STRING_PROPS
STR_VECT getPropList() const
returns a list with the names of our properties
bool getPropIfPresent(const std::string &key, T &res) const
FilterCatalogEntry(const std::string &name, boost::shared_ptr< FilterMatcherBase > matcher)
virtual void toStream(std::ostream &ss) const
serializes (pickles) to a stream
Includes a bunch of functionality for handling Atom and Bond queries.
void setDescription(const std::string &description)
Sets the description of the catalog entry.
bool hasProp(const char *key) const
returns whether or not we have a property with name key
#define RDUNUSED_PARAM(x)
bool hasVal(const char *what) const
Returns whether or not the dictionary contains a particular key.
void getProp(const char *key, T &res) const
allows retrieval of a particular property value
Abstract base class to be used to represent an entry in a Catalog.
bool hasProp(const std::string &key) const
virtual void initFromStream(std::istream &ss)
initializes from a stream pickle
virtual std::string Serialize() const
returns a string with a serialized (pickled) representation
void reset()
Clears all keys (and values) from the dictionary.
bool hasFilterMatch(const ROMol &mol) const
Returns true if the filters in this catalog entry match the molecule.
The Dict class can be used to store objects of arbitrary type keyed by strings.
std::vector< std::string > STR_VECT