diff --git a/include/podio/AssociationCollection.h b/include/podio/AssociationCollection.h index d5b704771..13f77f943 100644 --- a/include/podio/AssociationCollection.h +++ b/include/podio/AssociationCollection.h @@ -9,7 +9,9 @@ #include "podio/AssociationCollectionIterator.h" #include "podio/CollectionBase.h" #include "podio/CollectionBuffers.h" +#include "podio/DatamodelRegistry.h" #include "podio/ICollectionProvider.h" +#include "podio/SchemaEvolution.h" #ifdef PODIO_JSON_OUTPUT #include "nlohmann/json.hpp" @@ -152,25 +154,25 @@ class AssociationCollection : public podio::CollectionBase { return m_storage.getCollectionBuffers(m_isSubsetColl); } - podio::CollectionReadBuffers createBuffers() override /*const*/ { - // Very cumbersome way at the moment. We get the actual buffers to have the - // references and vector members sized appropriately (we will use this - // information to create new buffers outside) - auto collBuffers = m_storage.getCollectionBuffers(m_isSubsetColl); - auto readBuffers = podio::CollectionReadBuffers{}; - readBuffers.references = collBuffers.references; - readBuffers.vectorMembers = collBuffers.vectorMembers; - readBuffers.createCollection = [](podio::CollectionReadBuffers buffers, bool isSubsetColl) { - CollectionDataT data(buffers, isSubsetColl); - return std::make_unique(std::move(data), isSubsetColl); - }; - readBuffers.recast = [](podio::CollectionReadBuffers& buffers) { - if (buffers.data) { - buffers.data = podio::CollectionWriteBuffers::asVector(buffers.data); - } - }; - return readBuffers; - } + // podio::CollectionReadBuffers createBuffers() override /*const*/ { + // // Very cumbersome way at the moment. We get the actual buffers to have the + // // references and vector members sized appropriately (we will use this + // // information to create new buffers outside) + // auto collBuffers = m_storage.getCollectionBuffers(m_isSubsetColl); + // auto readBuffers = podio::CollectionReadBuffers{}; + // readBuffers.references = collBuffers.references; + // readBuffers.vectorMembers = collBuffers.vectorMembers; + // readBuffers.createCollection = [](podio::CollectionReadBuffers buffers, bool isSubsetColl) { + // CollectionDataT data(buffers, isSubsetColl); + // return std::make_unique(std::move(data), isSubsetColl); + // }; + // readBuffers.recast = [](podio::CollectionReadBuffers& buffers) { + // if (buffers.data) { + // buffers.data = podio::CollectionWriteBuffers::asVector(buffers.data); + // } + // }; + // return readBuffers; + // } std::string getTypeName() const override { return std::string("podio::AssociationCollection<") + FromT::TypeName + "," + ToT::TypeName + ">"; @@ -247,6 +249,16 @@ class AssociationCollection : public podio::CollectionBase { return m_storage.setReferences(collectionProvider, m_isSubsetColl); } + static constexpr SchemaVersionT schemaVersion = 1; + + SchemaVersionT getSchemaVersion() const override { + return schemaVersion; + } + + size_t getDatamodelRegistryIndex() const override { + return podio::DatamodelRegistry::NoDefinitionNecessary; + } + private: // For setReferences, we need to give our own CollectionData access to our // private entries. Otherwise we would need to expose a public member function diff --git a/include/podio/detail/AssociationSIOBlock.h b/include/podio/detail/AssociationSIOBlock.h index 587bb965c..4c9a2767d 100644 --- a/include/podio/detail/AssociationSIOBlock.h +++ b/include/podio/detail/AssociationSIOBlock.h @@ -4,7 +4,6 @@ #include "podio/detail/AssociationFwd.h" #include "podio/CollectionBuffers.h" - #include "podio/SIOBlock.h" #include @@ -19,12 +18,14 @@ template class AssociationSIOBlock : public podio::SIOBlock { public: AssociationSIOBlock() : - SIOBlock(podio::detail::associationSIOName(), sio::version::encode_version(0, 1)) { + SIOBlock(podio::detail::associationSIOName(), + sio::version::encode_version(AssociationCollection::schemaVersion, 0)) { podio::SIOBlockFactory::instance().registerBlockForCollection(podio::detail::associationSIOName(), this); } - AssociationSIOBlock(const std::string& name) : SIOBlock(name, sio::version::encode_version(0, 1)) { + AssociationSIOBlock(const std::string& name) : + SIOBlock(name, sio::version::encode_version(AssociationCollection::schemaVersion, 0)) { } void read(sio::read_device& device, sio::version_type) override { @@ -68,20 +69,20 @@ class AssociationSIOBlock : public podio::SIOBlock { } } - void createBuffers(const bool subsetCollection = false) override { - m_subsetColl = subsetCollection; + // void createBuffers(const bool subsetCollection = false) override { + // m_subsetColl = subsetCollection; - m_buffers.references = new podio::CollRefCollection(); - m_buffers.vectorMembers = new podio::VectorMembersInfo(); + // m_buffers.references = new podio::CollRefCollection(); + // m_buffers.vectorMembers = new podio::VectorMembersInfo(); - m_buffers.createCollection = [](podio::CollectionReadBuffers buffers, bool isSubsetColl) { - AssociationCollectionData data(buffers, isSubsetColl); - return std::make_unique>(std::move(data), isSubsetColl); - }; + // m_buffers.createCollection = [](podio::CollectionReadBuffers buffers, bool isSubsetColl) { + // AssociationCollectionData data(buffers, isSubsetColl); + // return std::make_unique>(std::move(data), isSubsetColl); + // }; - // setCollection(new AssociationCollection()); - // _col->setSubsetCollection(subsetCollection); - } + // // setCollection(new AssociationCollection()); + // // _col->setSubsetCollection(subsetCollection); + // } SIOBlock* create(const std::string& name) const override { return new AssociationSIOBlock(name); diff --git a/python/templates/CMakeLists.txt b/python/templates/CMakeLists.txt index 475d80492..8091bb150 100644 --- a/python/templates/CMakeLists.txt +++ b/python/templates/CMakeLists.txt @@ -15,7 +15,6 @@ set(PODIO_TEMPLATES ${CMAKE_CURRENT_LIST_DIR}/SIOBlock.cc.jinja2 ${CMAKE_CURRENT_LIST_DIR}/SIOBlock.h.jinja2 ${CMAKE_CURRENT_LIST_DIR}/DatamodelDefinition.h.jinja2 - ${CMAKE_CURRENT_LIST_DIR}/Associations.h.jinja2 ${CMAKE_CURRENT_LIST_DIR}/AssociationsRootDict.h.jinja2 ${CMAKE_CURRENT_LIST_DIR}/AssociationsSIOBlock.cc.jinja2 ${CMAKE_CURRENT_LIST_DIR}/macros/collections.jinja2