Skip to content

Commit

Permalink
Make SIOBlocks use the schema version appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed May 3, 2023
1 parent 25dd42d commit b1fc1f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions python/templates/SIOBlock.cc.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
{{ utils.namespace_open(class.namespace) }}
{% with block_class = class.bare_type + 'SIOBlock' %}

void {{ block_class }}::read(sio::read_device& device, sio::version_type) {
void {{ block_class }}::read(sio::read_device& device, sio::version_type version) {
const auto& bufferFactory = podio::CollectionBufferFactory::instance();
// TODO:
// - Actually handle schema versions, instead of going for a hardcoded one
// - Error handling of empty optional
auto maybeBuffers = bufferFactory.createBuffers("{{ class.full_type }}Collection", 1, m_subsetColl);
auto maybeBuffers = bufferFactory.createBuffers("{{ class.full_type }}Collection", sio::version::major_version(version), m_subsetColl);
m_buffers = maybeBuffers.value_or(podio::CollectionReadBuffers{});

if (not m_subsetColl) {
Expand Down
7 changes: 4 additions & 3 deletions python/templates/SIOBlock.h.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef {{ package_name.upper() }}_{{ class.bare_type }}SIOBlock_H
#define {{ package_name.upper() }}_{{ class.bare_type }}SIOBlock_H

#include "{{ incfolder }}DatamodelDefinition.h"

#include "podio/SIOBlock.h"

#include <sio/api.h>
Expand All @@ -23,13 +25,12 @@ namespace podio {
class {{ block_class }}: public podio::SIOBlock {
public:
{{ block_class }}() :
SIOBlock("{{ class.bare_type }}", sio::version::encode_version(0, 1)) {
SIOBlock("{{ class.bare_type }}", sio::version::encode_version({{ package_name }}::meta::schemaVersion, 0)) {
podio::SIOBlockFactory::instance().registerBlockForCollection("{{class.full_type}}", this);
}

{{ block_class }}(const std::string& name) :
// SIOBlock(name + "__{{ class.bare_type }}", sio::version::encode_version(0, 1)) {}
SIOBlock(name, sio::version::encode_version(0, 1)) {}
SIOBlock(name, sio::version::encode_version({{ package_name }}::meta::schemaVersion, 0)) {}

// Read the collection data from the device
void read(sio::read_device& device, sio::version_type version) override;
Expand Down

0 comments on commit b1fc1f0

Please sign in to comment.