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> 57 boost::shared_ptr<FilterMatcherBase> d_matcher;
64 :
RDCatalog::CatalogEntry(), d_matcher(matcher.Clone()) {
69 boost::shared_ptr<FilterMatcherBase> matcher)
70 :
RDCatalog::CatalogEntry(), d_matcher(matcher) {
76 d_matcher(rhs.d_matcher),
77 d_props(rhs.d_props) {}
84 bool isValid()
const {
return d_matcher.get() && d_matcher->isValid(); }
88 std::string getDescription()
const;
95 void setDescription(
const std::string &description);
110 template <
typename T>
112 std::string what(key);
116 template <
typename T>
137 template <
typename T>
142 template <
typename T>
143 void getProp(
const std::string &key, T &res)
const {
147 template <
typename T>
149 return d_props.
getVal<T>(key);
152 template <
typename T>
154 return d_props.
getVal<T>(key);
159 template <
typename T>
164 template <
typename T>
173 return d_props.
hasVal(key);
179 std::string what(key);
200 std::vector<FilterMatch> &matchVect)
const {
201 return this->isValid() && d_matcher->getMatches(mol, matchVect);
211 return this->isValid() && d_matcher->hasMatch(mol);
215 virtual void toStream(std::ostream &ss)
const;
217 virtual std::string Serialize()
const;
219 virtual void initFromStream(std::istream &ss);
221 virtual void initFromString(
const std::string &text);
224 #ifdef RDK_USE_BOOST_SERIALIZATION 225 friend class boost::serialization::access;
226 template <
class Archive>
227 void save(Archive &ar,
const unsigned int version)
const {
229 registerFilterMatcherTypes(ar);
234 std::vector<std::string> string_props;
235 for (
size_t i = 0; i < keys.size(); ++i) {
239 string_props.push_back(keys[i]);
240 string_props.push_back(val);
242 }
catch (
const boost::bad_any_cast &) {
250 template <
class Archive>
251 void load(Archive &ar,
const unsigned int version) {
253 registerFilterMatcherTypes(ar);
256 std::vector<std::string> string_props;
260 for (
size_t i = 0; i < string_props.size() / 2; ++i) {
261 d_props.
setVal(string_props[i * 2], string_props[i * 2 + 1]);
265 BOOST_SERIALIZATION_SPLIT_MEMBER();
270 #ifdef RDK_USE_BOOST_SERIALIZATION 274 #endif //__RD_FILTER_CATALOG_H__ bool hasProp(const std::string &key) const
bool getPropIfPresent(const std::string &key, T &res) const
void setProps(const Dict &props)
virtual ~FilterCatalogEntry()
STR_VECT getPropList() const
returns a list with the names of our properties
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
T getProp(const char *key) const
FilterCatalogEntry(const std::string &name, const FilterMatcherBase &matcher)
const Dict & getProps() const
void clearProp(const std::string &key)
void setProp(const std::string &key, T val)
bool getPropIfPresent(const char *key, T &res) const
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
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...
bool hasVal(const std::string &what) const
Returns whether or not the dictionary contains a particular key.
pulls in the core RDKit functionality
T getProp(const std::string &key) const
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
FilterCatalogEntry(const FilterCatalogEntry &rhs)
void setProp(const char *key, T val)
sets a property value
std::map< std::string, std::string > STRING_PROPS
FilterCatalogEntry(const std::string &name, boost::shared_ptr< FilterMatcherBase > matcher)
bool hasFilterMatch(const ROMol &mol) const
Returns true if the filters in this catalog entry match the molecule.
#define RDKIT_FILTERCATALOG_EXPORT
STR_VECT keys() const
Returns the set of keys in the dictionary.
#define RDUNUSED_PARAM(x)
void getProp(const std::string &key, T &res) const
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.
RDKIT_RDGENERAL_EXPORT std::ostream & toStream(std::ostream &)
void reset()
Clears all keys (and values) from the dictionary.
bool getFilterMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const
Returns the matching filters for this catalog entry.
bool isValid() const
Returns true if the Filters stored in this catalog entry are valid.
The Dict class can be used to store objects of arbitrary type keyed by strings.
std::vector< std::string > STR_VECT