Skip to content

Commit

Permalink
[wip] Make things compile again after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Mar 22, 2023
1 parent b429e3c commit 22256bf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
50 changes: 31 additions & 19 deletions include/podio/AssociationCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<CollectionT>(std::move(data), isSubsetColl);
};
readBuffers.recast = [](podio::CollectionReadBuffers& buffers) {
if (buffers.data) {
buffers.data = podio::CollectionWriteBuffers::asVector<float>(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<CollectionT>(std::move(data), isSubsetColl);
// };
// readBuffers.recast = [](podio::CollectionReadBuffers& buffers) {
// if (buffers.data) {
// buffers.data = podio::CollectionWriteBuffers::asVector<float>(buffers.data);
// }
// };
// return readBuffers;
// }

std::string getTypeName() const override {
return std::string("podio::AssociationCollection<") + FromT::TypeName + "," + ToT::TypeName + ">";
Expand Down Expand Up @@ -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
Expand Down
29 changes: 15 additions & 14 deletions include/podio/detail/AssociationSIOBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "podio/detail/AssociationFwd.h"

#include "podio/CollectionBuffers.h"

#include "podio/SIOBlock.h"

#include <sio/api.h>
Expand All @@ -19,12 +18,14 @@ template <typename FromT, typename ToT>
class AssociationSIOBlock : public podio::SIOBlock {
public:
AssociationSIOBlock() :
SIOBlock(podio::detail::associationSIOName<FromT, ToT>(), sio::version::encode_version(0, 1)) {
SIOBlock(podio::detail::associationSIOName<FromT, ToT>(),
sio::version::encode_version(AssociationCollection<FromT, ToT>::schemaVersion, 0)) {
podio::SIOBlockFactory::instance().registerBlockForCollection(podio::detail::associationSIOName<FromT, ToT>(),
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<FromT, ToT>::schemaVersion, 0)) {
}

void read(sio::read_device& device, sio::version_type) override {
Expand Down Expand Up @@ -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<FromT, ToT> data(buffers, isSubsetColl);
return std::make_unique<AssociationCollection<FromT, ToT>>(std::move(data), isSubsetColl);
};
// m_buffers.createCollection = [](podio::CollectionReadBuffers buffers, bool isSubsetColl) {
// AssociationCollectionData<FromT, ToT> data(buffers, isSubsetColl);
// return std::make_unique<AssociationCollection<FromT, ToT>>(std::move(data), isSubsetColl);
// };

// setCollection(new AssociationCollection<FromT, ToT>());
// _col->setSubsetCollection(subsetCollection);
}
// // setCollection(new AssociationCollection<FromT, ToT>());
// // _col->setSubsetCollection(subsetCollection);
// }

SIOBlock* create(const std::string& name) const override {
return new AssociationSIOBlock(name);
Expand Down
1 change: 0 additions & 1 deletion python/templates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22256bf

Please sign in to comment.