The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
ContainedObject.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include <GaudiKernel/Kernel.h>
16#include <iostream>
17
18template <class TYPE>
19class ObjectVector;
20template <class TYPE>
21class ObjectList;
22
25
26// Definition of the CLID for this class
27static const CLID CLID_ContainedObject = 190;
28
38
40 friend class ObjectVector<ContainedObject>;
41 friend class ObjectList<ContainedObject>;
42
43protected:
45 ContainedObject() = default;
48 // cppcheck-suppress operatorEqVarError; see comment above
49 ContainedObject& operator=( const ContainedObject& ) { return *this; }
51 virtual ~ContainedObject();
52
53public:
55 virtual const CLID& clID() const { return classID(); }
56 static const CLID& classID() { return CLID_ContainedObject; }
57
59 const ObjectContainerBase* parent() const { return m_parent; }
61 void setParent( ObjectContainerBase* value ) { m_parent = value; }
62
64 virtual long index() const { return m_parent ? m_parent->index( this ) : -1; }
66 virtual StreamBuffer& serialize( StreamBuffer& s ) const { return s; }
68 virtual StreamBuffer& serialize( StreamBuffer& s ) { return s; }
70 virtual std::ostream& fillStream( std::ostream& s ) const { return s; }
72 friend std::ostream& operator<<( std::ostream& s, const ContainedObject& obj ) { return obj.fillStream( s ); }
73
74private:
77};
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
ObjectList< ContainedObject > ContainedObjectList
ObjectVector< ContainedObject > ContainedObjectVector
#define GAUDI_API
Definition Kernel.h:49
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
static const CLID & classID()
void setParent(ObjectContainerBase *value)
Update parent member.
ContainedObject & operator=(const ContainedObject &)
ObjectContainerBase * m_parent
Pointer to the parent.
ContainedObject()=default
Constructors.
virtual std::ostream & fillStream(std::ostream &s) const
Fill the output stream (ASCII)
ContainedObject(const ContainedObject &)
Copy constructor and assignement: do NOT copy the parent reference...
virtual StreamBuffer & serialize(StreamBuffer &s)
Serialize the object for reading.
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
friend std::ostream & operator<<(std::ostream &s, const ContainedObject &obj)
Output operator (ASCII)
const ObjectContainerBase * parent() const
Access to parent object.
virtual long index() const
Distance in the parent container.
virtual const CLID & clID() const
Retrieve pointer to class identifier.
ObjectContainerBase is the base class for Gaudi container classes.
ObjectList is one of the basic Gaudi container classes capable of being registered in Data Stores.
Definition ObjectList.h:42
ObjectVector is one of the basic Gaudi container classes capable of being registered in Data Stores.
The stream buffer is a small object collecting object data.