From ad1160e7dcf6e61e531ac9c764116200cfe4c7f8 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 13 Aug 2023 23:49:20 -0400 Subject: [PATCH] python/templates: add references between Objects and Collection types --- python/templates/Collection.h.jinja2 | 1 + python/templates/MutableObject.h.jinja2 | 2 ++ python/templates/Object.h.jinja2 | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/python/templates/Collection.h.jinja2 b/python/templates/Collection.h.jinja2 index 24265eef1..cda71791e 100644 --- a/python/templates/Collection.h.jinja2 +++ b/python/templates/Collection.h.jinja2 @@ -48,6 +48,7 @@ A Collection is identified by an ID. */ class {{ class.bare_type }}Collection : public podio::CollectionBase { public: + using value_type = {{ class.bare_type }}; using const_iterator = {{ class.bare_type }}CollectionIterator; using iterator = {{ class.bare_type }}MutableCollectionIterator; diff --git a/python/templates/MutableObject.h.jinja2 b/python/templates/MutableObject.h.jinja2 index ab39778a0..ebdac4f53 100644 --- a/python/templates/MutableObject.h.jinja2 +++ b/python/templates/MutableObject.h.jinja2 @@ -32,6 +32,8 @@ class Mutable{{ class.bare_type }} { friend class {{ class.bare_type }}; public: + using object_type = {{ class.bare_type }}; + using collection_type = {{ class.bare_type }}Collection; {{ macros.constructors_destructors(class.bare_type, Members, prefix='Mutable') }} /// conversion to const object diff --git a/python/templates/Object.h.jinja2 b/python/templates/Object.h.jinja2 index 0a6de9296..42d737cb5 100644 --- a/python/templates/Object.h.jinja2 +++ b/python/templates/Object.h.jinja2 @@ -22,6 +22,7 @@ {{ utils.namespace_open(class.namespace) }} class Mutable{{ class.bare_type }}; +class {{ class.bare_type }}Collection; {{ macros.class_description(class.bare_type, Description, Author) }} class {{ class.bare_type }} { @@ -31,6 +32,9 @@ class {{ class.bare_type }} { friend class {{ class.bare_type }}CollectionIterator; public: + using mutable_type = Mutable{{ class.bare_type }}; + using collection_type = {{ class.bare_type }}Collection; + {{ macros.constructors_destructors(class.bare_type, Members) }} public: