24 #ifndef LSST_AFW_TYPEHANDLING_PYTHON_H
25 #define LSST_AFW_TYPEHANDLING_PYTHON_H
27 #include "pybind11/pybind11.h"
39 namespace typehandling {
53 template <
class Base = Storable>
70 template<
typename... Args>
89 PYBIND11_OVERLOAD_NAME(
bool, Base,
"__eq__",
equals,
other);
99 PYBIND11_OVERLOAD_NAME(
105 PYBIND11_OVERLOAD_NAME(
132 class StorableHelperPersistenceHelper {
135 table::Key<table::Array<std::uint8_t>>
bytes;
137 static StorableHelperPersistenceHelper
const &get() {
138 static StorableHelperPersistenceHelper instance;
143 StorableHelperPersistenceHelper(StorableHelperPersistenceHelper
const &) =
delete;
144 StorableHelperPersistenceHelper &
operator=(StorableHelperPersistenceHelper
const &) =
delete;
147 StorableHelperPersistenceHelper(StorableHelperPersistenceHelper &&) =
delete;
148 StorableHelperPersistenceHelper &
operator=(StorableHelperPersistenceHelper &&) =
delete;
151 StorableHelperPersistenceHelper() :
154 "bytes",
"an opaque bytestring representation of a Storable",
""
160 class StorableHelperFactory :
public table::io::PersistableFactory {
163 table::io::PersistableFactory(
name),
169 InputArchive
const &archive,
170 CatalogVector
const &catalogs
172 pybind11::gil_scoped_acquire gil;
173 auto const &
keys = StorableHelperPersistenceHelper::get();
177 auto const &record = catalogs.front().front();
179 auto cls = pybind11::module::import(_module.
c_str()).attr(_name.
c_str());
192 template <
typename Base>
194 pybind11::gil_scoped_acquire gil;
195 pybind11::function overload = pybind11::get_overload(
static_cast<const Base *
>(
this),
"_write");
199 auto const &
keys = StorableHelperPersistenceHelper::get();
table::Key< std::string > name
ItemVariant const * other
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
table::Key< table::Array< std::uint8_t > > bytes
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
"Trampoline" for Storable to let it be used as a base class in Python.
std::string toString() const override
Create a string representation of this object (optional operation).
std::shared_ptr< Storable > cloneStorable() const override
Create a new object that is a copy of this one (optional operation).
std::size_t hash_value() const override
Return a hash of this object (optional operation).
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
bool equals(Storable const &other) const noexcept override
Compare this object to another Storable.
void write(table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Interface supporting iteration over heterogenous containers.
FilterProperty & operator=(FilterProperty const &)=default
std::string declareGenericMapRestrictions(std::string const &className, std::string const &keyName)
A base class for image defects.