PODIO
  • Introduction
  • Quick-start
  • Design and Implementation Details
    • Layout of Objects
      • The User Layer
      • The Internal Data Layer
      • The POD Layer
      • The Collections
      • Vectorization support / notebook pattern
    • Handling mutability
  • Data Models and Data Model Definitions
    • Basic Concepts and Supported Features
    • Mandatory fields
    • Definition of custom components
    • Definition of custom data classes
      • Defining members
      • Definition of references between objects:
      • Explicit definition of methods
    • Definition of custom interfaces
    • Definition of links
      • Assigning to interface types
    • Global options
    • Embedding a datamodel version
    • Extending a datamodel / using types from an upstream datamodel
      • Potential pitfalls
  • Examples for Supported Interface
    • Object Ownership
    • Object Creation and Storage
    • Object References
    • Looping through Collections
    • Cloning objects
    • Support for Notebook-Pattern
    • podio::Frame container
    • Object Retrieval
    • User defined Meta Data
      • Python Interface
  • ROOT Support in Podio
    • C++
      • Reading
      • Writing
    • Python
      • Reading
      • Writing
  • The Frame concept
    • Basic functionality of a Frame
      • Usage examples for collection data
        • Putting collection data into the Frame
        • Getting collection (references) from the Frame
      • Usage for Parameters
    • I/O basics and philosophy
      • Writing a Frame
      • Reading a Frame
      • Schema evolution
  • Frame implementation and design
  • Writing extra data outside an EDM
    • Example usage
    • Some limitations
      • No relations to other collections
      • Limited supported types
  • Linking unrelated objects with each other
    • Link basics
    • How to use Links
      • Enabling I/O capabilities for Links
    • The LinkNavigator utility
    • Implementation details
      • File structure
      • Default and Mutable Link classes
  • Storage details of files produced by podio
    • ROOT
      • Storage of Collection data
      • Storage of Frame parameters
      • Storage of podio related metadata
    • SIO
  • Building a new data model library with CMake
    • Exported CMake functions and macros
    • A simple example
    • More advanced data model generation
    • Example usage of Advanced options
  • Advanced Topics
    • Writing extra data outside the EDM
    • Changing / creating new templates
    • Persistency
      • Writing Back-End
      • Reading Back-End
      • Dumping JSON
    • Thread-safety
      • Changing user data
      • Serialization
      • Not-thread-safe components
    • Running pre-commit
    • Retrieving the EDM definition from a data file
      • Accessing the EDM definition programmatically
      • Technical details on EDM definition embedding
        • The DatamodelRegistry
        • I/O helpers for EDM definition storing
  • Changing / creating new templates
    • Preprocessing of yaml file
    • Existing templates
    • Adding a new template
    • Available information in the templates
      • General information
      • Components
      • Datatypes
      • MemberVariable
      • DataType
      • Julia code generation
  • Python interface for data models
    • Pythonizations
      • Developing new pythonizations
      • Considerations
  • PODIO Collection as a Container
    • Container Types
    • Container member functions and operators
    • Collection as an AllocatorAwareContainer
      • AllocatorAwareContainer types
      • AllocatorAwareContainer expression and statements
    • Collection iterators as an Iterator
      • Iterator summary
      • LegacyIterator
      • LegacyInputIterator
      • LegacyForwardIterator
      • LegacyOutputIterator
    • Collection iterators and standard iterator adaptors
    • Collection as a range
    • Collection and standard algorithms
    • Collection and standard range algorithms
  • C++ API documentation
    • Class list
      • Class podio::CollectionBase
        • CollectionBase
      • Class podio::CollectionBufferFactory
        • CollectionBufferFactory
      • Class podio::CollectionIDTable
        • CollectionIDTable
      • Class podio::DataSource
        • DataSource
      • Class podio::DatamodelDefinitionCollector
        • DatamodelDefinitionCollector
      • Class podio::DatamodelDefinitionHolder
        • DatamodelDefinitionHolder
      • Class podio::DatamodelRegistry
        • DatamodelRegistry
      • Class podio::Frame
        • Frame
      • Class podio::GenericParameters
        • GenericParameters
      • Class podio::ICollectionProvider
        • ICollectionProvider
      • Class podio::LinkCollection
        • LinkCollection
      • Class podio::LinkCollectionData
        • LinkCollectionData
      • Class podio::LinkCollectionIteratorT
        • LinkCollectionIteratorT
      • Class podio::LinkNavigator
        • LinkNavigator
      • Class podio::LinkObj
        • LinkObj
      • Class podio::LinkSIOBlock
        • LinkSIOBlock
      • Class podio::LinkT
        • LinkT
      • Class podio::ObjectID
        • ObjectID
      • Class podio::RNTupleReader
        • RNTupleReader
      • Class podio::RNTupleWriter
        • RNTupleWriter
      • Class podio::ROOTFrameData
        • ROOTFrameData
      • Class podio::ROOTLegacyReader
        • ROOTLegacyReader
      • Class podio::ROOTReader
        • ROOTReader
      • Class podio::ROOTWriter
        • ROOTWriter
      • Class podio::Reader
        • Reader
      • Class podio::RelationRange
        • RelationRange
      • Class podio::SIOBlock
        • SIOBlock
      • Class podio::SIOBlockFactory
        • SIOBlockFactory
      • Class podio::SIOBlockLibraryLoader
        • SIOBlockLibraryLoader
      • Class podio::SIOBlockUserData
        • SIOBlockUserData
      • Class podio::SIOCollectionIDTableBlock
        • SIOCollectionIDTableBlock
      • Class podio::SIOEventMetaDataBlock
        • SIOEventMetaDataBlock
      • Class podio::SIOFileTOCRecord
        • SIOFileTOCRecord
      • Class podio::SIOFrameData
        • SIOFrameData
      • Class podio::SIOLegacyReader
        • SIOLegacyReader
      • Class podio::SIONumberedMetaDataBlock
        • SIONumberedMetaDataBlock
      • Class podio::SIOReader
        • SIOReader
      • Class podio::SIOWriter
        • SIOWriter
      • Class podio::SchemaEvolution
        • SchemaEvolution
      • Class podio::UserDataCollection
        • UserDataCollection
      • Class podio::Writer
        • Writer
      • Class podio::utils::MaybeSharedPtr
        • MaybeSharedPtr
    • Struct list
      • Struct podio::CollectionReadBuffers
        • CollectionReadBuffers
      • Struct podio::CollectionWriteBuffers
        • CollectionWriteBuffers
      • Struct podio::Frame::FrameConcept
        • FrameConcept
      • Struct podio::Frame::FrameModel
        • FrameModel
      • Struct podio::LinkData
        • LinkData
      • Struct podio::RNTupleWriter::CategoryInfo
        • CategoryInfo
      • Struct podio::ROOTReader::CategoryInfo
        • CategoryInfo
      • Struct podio::ROOTWriter::CategoryInfo
        • CategoryInfo
      • Struct podio::Reader::ReaderConcept
        • ReaderConcept
      • Struct podio::Reader::ReaderModel
        • ReaderModel
      • Struct podio::RelationNames
        • RelationNames
      • Struct podio::SIOFileTOCRecordBlock
        • SIOFileTOCRecordBlock
      • Struct podio::SIOMapBlock
        • SIOMapBlock
      • Struct podio::SIOVersionBlock
        • SIOVersionBlock
      • Struct podio::SchemaEvolution::MapIndex
        • MapIndex
      • Struct podio::Writer::WriterConcept
        • WriterConcept
      • Struct podio::Writer::WriterModel
        • WriterModel
      • Struct podio::det::nonesuch
        • nonesuch
      • Struct podio::root_utils::CollectionBranches
        • CollectionBranches
      • Struct podio::root_utils::CollectionWriteInfo
        • CollectionWriteInfo
      • Struct podio::root_utils::ParamStorage
        • ParamStorage
      • Struct podio::utils::MaybeSharedPtr::ControlBlock
        • ControlBlock
      • Struct podio::utils::TypeList
        • TypeList
      • Struct podio::utils::static_concatenate
        • static_concatenate
      • Struct podio::version::Version
        • Version
    • Namespace list
      • Namespace ROOT
        • ROOT
      • Namespace ROOT::RDF
        • RDF
      • Namespace podio
        • podio
      • Namespace podio::Category
        • Category
      • Namespace podio::det
        • det
      • Namespace podio::root_compat
        • root_compat
      • Namespace podio::root_utils
        • root_utils
      • Namespace podio::sio_helpers
        • sio_helpers
      • Namespace podio::utils
        • utils
      • Namespace podio::version
        • version
      • Namespace sio
        • sio
  • python
    • podio package
      • Subpackages
        • podio.pythonizations package
      • Submodules
      • podio.base_reader module
        • BaseReaderMixin
      • podio.base_writer module
        • AllWriters
        • BaseWriterMixin
      • podio.data_source module
      • podio.frame module
        • Frame
      • podio.frame_iterator module
        • FrameCategoryIterator
      • podio.reading module
        • RootFileFormat
        • get_reader()
      • podio.root_io module
        • LegacyReader
        • RNTupleReader
        • RNTupleWriter
        • Reader
        • Writer
      • podio.sio_io module
        • LegacyReader
        • Reader
        • Writer
      • podio.utils module
        • convert_to_str_paths()
        • expand_glob()
      • podio.version module
        • parse()
      • Module contents
        • Frame
    • podio_class_generator module
      • clang_format_file()
      • has_clang_format()
      • parse_version()
      • read_upstream_edm()
    • podio_gen package
      • Submodules
      • podio_gen.cpp_generator module
        • CPPClassGenerator
        • IncludeFrom
        • replace_component_in_paths()
      • podio_gen.generator_base module
        • ClassGeneratorBaseMixin
        • write_file_if_changed()
      • podio_gen.generator_utils module
        • DataModel
        • DataModelJSONEncoder
        • DataType
        • DefinitionError
        • MemberVariable
        • get_julia_type()
      • podio_gen.julia_generator module
        • JuliaClassGenerator
      • podio_gen.podio_config_reader module
        • ClassDefinitionValidator
        • MemberParser
        • PodioConfigReader
      • Module contents
    • podio_schema_evolution module
      • AddedComponent
      • AddedDatatype
      • AddedMember
      • AddedMultiRelation
      • AddedSingleRelation
      • AddedVectorMember
      • ChangedMemberType
      • DataModelComparator
        • DataModelComparator.check_rename()
        • DataModelComparator.compare()
        • DataModelComparator.filter_types_with_adds_and_drops()
        • DataModelComparator.get_changed_schemata()
        • DataModelComparator.heuristics()
        • DataModelComparator.heuristics_members()
        • DataModelComparator.print_comparison()
        • DataModelComparator.read()
        • DataModelComparator.read_evolution_file()
        • DataModelComparator.unsupported_changes
      • DroppedComponent
      • DroppedDatatype
      • DroppedMember
      • DroppedMultiRelation
      • DroppedSingleRelation
      • DroppedVectorMember
      • RenamedDataType
      • RenamedMember
      • RootIoRule
      • SchemaChange
      • root_filter()
      • sio_filter()
PODIO
  • File Link.h

File Link.h

namespace podio

Functions

template<typename FromT, typename ToT>
std::ostream &operator<<(std::ostream &os, const Link<FromT, ToT> &link)
template<typename FromT, typename ToT, bool Mutable>
class LinkT
#include <podio/detail/Link.h>

Generalized Link type for both Mutable and immutable (default) versions.

User facing classes with the expected naming scheme are defined via template aliases in LinkFwd.h

Public Types

using mutable_type = podio::MutableLink<FromT, ToT>
using value_type = podio::Link<FromT, ToT>
using collection_type = podio::LinkCollection<FromT, ToT>

Public Functions

inline LinkT()

Constructor.

inline LinkT(float weight)

Constructor with weight.

LinkT(const LinkT &other) = default

Copy constructor.

inline LinkT &operator=(LinkT other) &

Assignment operators.

LinkT &operator=(LinkT other) && = delete
template<typename FromU, typename ToU> inline &&sameTypes< FromU, ToU > operator LinkT< FromU, ToU, false > () const

Implicit conversion of mutable to immutable links.

template<typename FromU = FromT, typename ToU = ToT>
inline MutableLink<FromU, ToU> clone(bool cloneRelations = true) const

Create a mutable deep-copy.

Parameters:

cloneRelations – if set to false only the weight will be cloned but not the relations to the objects this link points to. Defaults to true

Returns:

A mutable deep-copy of this link which is independent of the original one

~LinkT() = default

Destructor.

inline float getWeight() const

Get the weight of the link.

template<bool Mut = Mutable>
inline void setWeight(float value)

Set the weight of the link.

inline const FromT getFrom() const

Access the related-from object.

template<typename FromU>
inline void setFrom(FromU value)

Set the related-from object.

Note

All setFrom overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename FromU>
inline void setFrom(FromU value)

Set the related-from object.

Note

All setFrom overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename FromU>
inline void setFrom(FromU value)

Set the related-from object.

Note

All setFrom overloads are equivalent and the correct one is selected at compile time. We need this overload to allow for an implicit conversion to interface types in case the relation contains an interface type.

inline const ToT getTo() const

Access the related-to object.

template<typename ToU>
inline void setTo(ToU value)

Set the related-to object.

Note

All setTo overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename ToU>
inline void setTo(ToU value)

Set the related-to object.

Note

All setTo overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename ToU>
inline void setTo(ToU value)

Set the related-to object.

Note

All setTo overloads are equivalent and the correct one is selected at compile time. We need this overload to allow for an implicit conversion to interface types in case the relation contains an interface type.

template<typename T>
inline T get() const

Templated version for getting an element of the link by type.

Only available for Links where FromT and ToT are not the same type, and if the requested type is actually part of the Link. It is only possible to get the immutable types from this. Will result in a compilation error if any of these conditions is not met.

Template Parameters:

T – the desired type

Returns:

T the element of the Link

template<size_t Index>
inline auto get() const

Tuple like index based access to the elements of the Link.

Returns only immutable types of the links. This method enables structured bindings for Links.

Template Parameters:

Index – an index (smaller than 3) to access an element of the Link

Returns:

Depending on the value of Index:

  • 0: The From element of the Link

  • 1: The To element of the Link

  • 2: The weight of the Link

template<typename T>
inline void set(T value)

Templated version for setting an element of the link by type.

Only available for Links where FromT and ToT are not the same type, and if the requested type is actually part of the Link. Will result in a compilation error if any of these conditions is not met.

Template Parameters:

T – type of value (inferred!)

Parameters:

value – the element to set for this link.

inline bool isAvailable() const

check whether the object is actually available

inline void unlink()

disconnect from Link instance

inline podio::ObjectID getObjectID() const

Get the ObjectID.

inline podio::ObjectID id() const
inline bool operator==(const LinkT &other) const
inline bool operator!=(const LinkT &other) const
template<typename FromU, typename ToU>
inline bool operator==(const LinkT<FromU, ToU, !Mutable> &other) const
template<typename FromU, typename ToU>
inline bool operator!=(const LinkT<FromU, ToU, !Mutable> &other) const
inline bool operator<(const LinkT &other) const

Public Static Functions

template<bool Mut = Mutable>
static inline Link<FromT, ToT> makeEmpty()

Create an empty Link handle.

Public Static Attributes

static std::string_view typeName = utils::static_concatenate_v<detail::link_name_prefix, FromT::typeName, detail::link_name_infix, ToT::typeName, detail::link_name_suffix>

Private Types

using LinkObjT = LinkObj<FromT, ToT>

Private Functions

inline explicit LinkT(podio::utils::MaybeSharedPtr<LinkObjT> obj)

Constructor from existing LinkObj.

template<bool Mut = Mutable>
inline LinkT(LinkObjT *obj)

Private Members

friend LinkCollection< FromT, ToT >
friend LinkCollectionIteratorT< FromT, ToT, Mutable >
friend LinkT< FromT, ToT, !Mutable >
podio::utils::MaybeSharedPtr<LinkObjT> m_obj = {nullptr}

Private Static Attributes

template<typename FromU, typename ToU>
static bool sameTypes = std::is_same_v<FromU, FromT> && std::is_same_v<ToU, ToT>

Helper member variable to check whether FromU and ToU can be used for this Link.

We need this to make SFINAE trigger in some cases below

template<typename T>
static bool isFromOrToT = detail::isInTuple<T, std::tuple<FromT, ToT>>

Variable template to for determining whether T is either FromT or ToT.

Mainly defined for convenience

template<typename T>
static bool isMutableFromOrToT = detail::isInTuple<T, std::tuple<FromT, ToT, detail::GetMutableHandleType<FromT>, detail::GetMutableHandleType<ToT>>>

Variable template to for determining whether T is either FromT or ToT or any of their mutable versions.

Friends

inline friend void swap(LinkT &a, LinkT &b)

© Copyright 2023, Key4hep authors.

Built with Sphinx using a theme provided by Read the Docs.