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__ 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