 |
RDKit
Open-source cheminformatics and machine learning.
|
Go to the documentation of this file.
33 #ifndef __RD_FILTER_CATALOG_H__
34 #define __RD_FILTER_CATALOG_H__
41 #ifdef RDK_USE_BOOST_SERIALIZATION
43 #include <boost/archive/text_oarchive.hpp>
44 #include <boost/archive/text_iarchive.hpp>
45 #include <boost/serialization/vector.hpp>
46 #include <boost/serialization/shared_ptr.hpp>
58 boost::shared_ptr<FilterMatcherBase> d_matcher;
65 :
RDCatalog::CatalogEntry(), d_matcher(matcher.copy()) {
70 boost::shared_ptr<FilterMatcherBase> matcher)
71 :
RDCatalog::CatalogEntry(), d_matcher(matcher) {
77 d_matcher(rhs.d_matcher),
78 d_props(rhs.d_props) {}
85 bool isValid()
const {
return d_matcher.get() && d_matcher->isValid(); }
89 std::string getDescription()
const;
96 void setDescription(
const std::string &description);
111 template <
typename T>
113 std::string what(key);
117 template <
typename T>
138 template <
typename T>
143 template <
typename T>
144 void getProp(
const std::string &key, T &res)
const {
148 template <
typename T>
150 return d_props.
getVal<T>(key);
153 template <
typename T>
155 return d_props.
getVal<T>(key);
160 template <
typename T>
165 template <
typename T>
174 return d_props.
hasVal(key);
180 std::string what(key);
201 std::vector<FilterMatch> &matchVect)
const {
202 return this->isValid() && d_matcher->getMatches(mol, matchVect);
212 return this->isValid() && d_matcher->hasMatch(mol);
216 virtual void toStream(std::ostream &ss)
const;
218 virtual std::string Serialize()
const;
220 virtual void initFromStream(std::istream &ss);
222 virtual void initFromString(
const std::string &text);
225 #ifdef RDK_USE_BOOST_SERIALIZATION
226 friend class boost::serialization::access;
227 template <
class Archive>
228 void save(Archive &ar,
const unsigned int version)
const {
230 registerFilterMatcherTypes(ar);
235 std::vector<std::string> string_props;
236 for (
size_t i = 0; i < keys.size(); ++i) {
240 string_props.push_back(keys[i]);
241 string_props.push_back(val);
243 }
catch (
const boost::bad_any_cast &) {
251 template <
class Archive>
252 void load(Archive &ar,
const unsigned int version) {
254 registerFilterMatcherTypes(ar);
257 std::vector<std::string> string_props;
261 for (
size_t i = 0; i < string_props.size() / 2; ++i) {
262 d_props.
setVal(string_props[i * 2], string_props[i * 2 + 1]);
266 BOOST_SERIALIZATION_SPLIT_MEMBER();
271 #ifdef RDK_USE_BOOST_SERIALIZATION
275 #endif //__RD_FILTER_CATALOG_H__
The Dict class can be used to store objects of arbitrary type keyed by strings.
void setProp(const char *key, T val)
sets a property value
std::map< std::string, std::string > STRING_PROPS
bool getPropIfPresent(const char *key, T &res) const
Abstract base class to be used to represent an entry in a Catalog.
T getProp(const char *key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
#define RDUNUSED_PARAM(x)
bool hasVal(const std::string &what) const
Returns whether or not the dictionary contains a particular key.
void getProp(const std::string &key, T &res) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< std::string > STR_VECT
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.
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
FilterCatalogEntry(const std::string &name, boost::shared_ptr< FilterMatcherBase > matcher)
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
bool isValid() const
Returns true if the Filters stored in this catalog entry are valid.
bool hasProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool hasFilterMatch(const ROMol &mol) const
Returns true if the filters in this catalog entry match the molecule.
bool getPropIfPresent(const std::string &key, T &res) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
void setProps(const Dict &props)
virtual ~FilterCatalogEntry()
pulls in the core RDKit functionality
void reset()
Clears all keys (and values) from the dictionary.
void setProp(const std::string &key, T val)
This is an overloaded member function, provided for convenience. It differs from the above function o...
FilterCatalogEntry(const FilterCatalogEntry &rhs)
FilterCatalogEntry(const std::string &name, const FilterMatcherBase &matcher)
STR_VECT getPropList() const
returns a list with the names of our properties
void getProp(const char *key, T &res) const
allows retrieval of a particular property value
STR_VECT keys() const
Returns the set of keys in the dictionary.
bool getFilterMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const
Returns the matching filters for this catalog entry.
const Dict & getProps() const
void clearProp(const std::string &key)
This is an overloaded member function, provided for convenience. It differs from the above function o...
#define RDKIT_FILTERCATALOG_EXPORT
void clearProp(const char *key)
clears the value of a property
bool hasProp(const char *key) const
returns whether or not we have a property with name key
RDKIT_RDGENERAL_EXPORT std::ostream & toStream(std::ostream &)
T getProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...