Loading...
Searching...
No Matches
MolCatalogEntry.h
Go to the documentation of this file.
//
// Copyright (C) 2006 Greg Landrum
//
#include <RDGeneral/export.h>
#ifndef _RD_MOLCATALOGENTRY_H_
#define _RD_MOLCATALOGENTRY_H_
#include <RDGeneral/Dict.h>
#include <Catalogs/CatalogEntry.h>
#include <fstream>
#include <string>
namespace RDKit {
class ROMol;
//! This class is used to store ROMol objects in a MolCatalog
class RDKIT_MOLCATALOG_EXPORT MolCatalogEntry : public RDCatalog::CatalogEntry {
public:
MolCatalogEntry() : d_descrip("") {
dp_props = new Dict();
setBitId(-1);
}
//! copy constructor
MolCatalogEntry(const MolCatalogEntry &other);
//! create an entry to hold the provided ROMol
/*!
The MolCatalogEntry takes ownership of the pointer
*/
MolCatalogEntry(const ROMol *omol);
//! construct from a pickle
MolCatalogEntry(const std::string &pickle) { this->initFromString(pickle); }
~MolCatalogEntry() override;
std::string getDescription() const override { return d_descrip; }
void setDescription(std::string val) { d_descrip = val; }
unsigned int getOrder() const { return d_order; }
void setOrder(unsigned int order) { d_order = order; }
const ROMol *getMol() const { return dp_mol; }
//! hold the provided ROMol
/*!
The MolCatalogEntry takes ownership of the pointer.
If the MolCatalogEntry already has a molecule, this one will be deleted.
*/
void setMol(const ROMol *molPtr);
//! set a named property
template <typename T>
void setProp(const char *key, T &val) const {
dp_props->setVal(key, val);
}
//! \overload
template <typename T>
void setProp(const std::string &key, T &val) const {
setProp(key.c_str(), val);
}
//! get the value of a named property
template <typename T>
void getProp(const char *key, T &res) const {
dp_props->getVal(key, res);
}
//! \overload
template <typename T>
void getProp(const std::string &key, T &res) const {
getProp(key.c_str(), res);
}
//! returns true if such a property exists
bool hasProp(const char *key) const {
if (!dp_props) {
return false;
}
return dp_props->hasVal(key);
}
//! \overload
bool hasProp(const std::string &key) const { return hasProp(key.c_str()); }
//! clears a named property
void clearProp(const char *key) const { dp_props->clearVal(key); }
//! \overload
void clearProp(const std::string &key) const { clearProp(key.c_str()); }
//! serializes this entry to the stream
void toStream(std::ostream &ss) const override;
//! returns a serialized (pickled) form of the entry
std::string Serialize() const override;
//! initialize from a stream containing a pickle
void initFromStream(std::istream &ss) override;
//! initialize from a string containing a pickle
void initFromString(const std::string &text) override;
private:
const ROMol *dp_mol{nullptr};
Dict *dp_props;
unsigned int d_order{0};
std::string d_descrip;
};
} // namespace RDKit
#endif
CatalogEntry.h
Dict.h
Defines the Dict class.
RDCatalog::CatalogEntry
Abstract base class to be used to represent an entry in a Catalog.
Definition CatalogEntry.h:20
RDCatalog::CatalogEntry::setBitId
void setBitId(int bid)
sets our bit Id
Definition CatalogEntry.h:25
RDKit::Dict
The Dict class can be used to store objects of arbitrary type keyed by strings.
Definition Dict.h:36
RDKit::MolCatalogEntry::getOrder
unsigned int getOrder() const
Definition MolCatalogEntry.h:42
RDKit::MolCatalogEntry::clearProp
void clearProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition MolCatalogEntry.h:89
RDKit::MolCatalogEntry::setMol
void setMol(const ROMol *molPtr)
hold the provided ROMol
RDKit::MolCatalogEntry::initFromString
void initFromString(const std::string &text) override
initialize from a string containing a pickle
RDKit::MolCatalogEntry::MolCatalogEntry
MolCatalogEntry(const std::string &pickle)
construct from a pickle
Definition MolCatalogEntry.h:34
RDKit::MolCatalogEntry::getMol
const ROMol * getMol() const
Definition MolCatalogEntry.h:45
RDKit::MolCatalogEntry::setOrder
void setOrder(unsigned int order)
Definition MolCatalogEntry.h:43
RDKit::MolCatalogEntry::getProp
void getProp(const char *key, T &res) const
get the value of a named property
Definition MolCatalogEntry.h:67
RDKit::MolCatalogEntry::setProp
void setProp(const char *key, T &val) const
set a named property
Definition MolCatalogEntry.h:55
RDKit::MolCatalogEntry::setProp
void setProp(const std::string &key, T &val) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition MolCatalogEntry.h:61
RDKit::MolCatalogEntry::MolCatalogEntry
MolCatalogEntry(const MolCatalogEntry &other)
copy constructor
RDKit::MolCatalogEntry::clearProp
void clearProp(const char *key) const
clears a named property
Definition MolCatalogEntry.h:87
RDKit::MolCatalogEntry::toStream
void toStream(std::ostream &ss) const override
serializes this entry to the stream
RDKit::MolCatalogEntry::setDescription
void setDescription(std::string val)
Definition MolCatalogEntry.h:40
RDKit::MolCatalogEntry::initFromStream
void initFromStream(std::istream &ss) override
initialize from a stream containing a pickle
RDKit::MolCatalogEntry::~MolCatalogEntry
~MolCatalogEntry() override
RDKit::MolCatalogEntry::Serialize
std::string Serialize() const override
returns a serialized (pickled) form of the entry
RDKit::MolCatalogEntry::getDescription
std::string getDescription() const override
returns a text description of this entry
Definition MolCatalogEntry.h:38
RDKit::MolCatalogEntry::getProp
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...
Definition MolCatalogEntry.h:72
RDKit::MolCatalogEntry::MolCatalogEntry
MolCatalogEntry(const ROMol *omol)
create an entry to hold the provided ROMol
RDKit::MolCatalogEntry::hasProp
bool hasProp(const char *key) const
returns true if such a property exists
Definition MolCatalogEntry.h:77
RDKit::MolCatalogEntry::MolCatalogEntry
MolCatalogEntry()
Definition MolCatalogEntry.h:19
RDKit::MolCatalogEntry::hasProp
bool hasProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition MolCatalogEntry.h:84
RDKit::ROMol
Definition ROMol.h:199
export.h
RDKIT_MOLCATALOG_EXPORT
#define RDKIT_MOLCATALOG_EXPORT
Definition export.h:297
RDKit
Std stuff.
Definition Abbreviations.h:19