The Gaudi Framework  master (37c0b60a)
ContainedObject.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef GAUDIKERNEL_CONTAINEDOBJECT_H
12 #define GAUDIKERNEL_CONTAINEDOBJECT_H
13 
14 // Include files
15 #include <GaudiKernel/Kernel.h>
18 #include <iostream>
19 
20 // Forward declarations
21 template <class TYPE>
23 template <class TYPE>
24 class ObjectList;
25 
26 // Typedefs
29 
30 // Definition of the CLID for this class
31 static const CLID CLID_ContainedObject = 190;
32 
42 
44  friend class ObjectVector<ContainedObject>;
45  friend class ObjectList<ContainedObject>;
46 
47 protected:
49  ContainedObject() = default;
52  // cppcheck-suppress operatorEqVarError; see comment above
53  ContainedObject& operator=( const ContainedObject& ) { return *this; }
55  virtual ~ContainedObject();
56 
57 public:
59  virtual const CLID& clID() const { return classID(); }
60  static const CLID& classID() { return CLID_ContainedObject; }
61 
63  const ObjectContainerBase* parent() const { return m_parent; }
65  void setParent( ObjectContainerBase* value ) { m_parent = value; }
66 
68  virtual long index() const { return m_parent ? m_parent->index( this ) : -1; }
70  virtual StreamBuffer& serialize( StreamBuffer& s ) const { return s; }
72  virtual StreamBuffer& serialize( StreamBuffer& s ) { return s; }
74  virtual std::ostream& fillStream( std::ostream& s ) const { return s; }
76  friend std::ostream& operator<<( std::ostream& s, const ContainedObject& obj ) { return obj.fillStream( s ); }
77 
78 private:
80  ObjectContainerBase* m_parent = nullptr;
81 };
82 
83 #endif // GAUDIKERNEL_CONTAINEDOBJECT_H
ContainedObjectVector
ObjectVector< ContainedObject > ContainedObjectVector
Definition: ContainedObject.h:24
ObjectVector
Definition: ContainedObject.h:22
gaudirun.s
string s
Definition: gaudirun.py:346
ContainedObject::serialize
virtual StreamBuffer & serialize(StreamBuffer &s)
Serialize the object for reading.
Definition: ContainedObject.h:72
ContainedObject::operator<<
friend std::ostream & operator<<(std::ostream &s, const ContainedObject &obj)
Output operator (ASCII)
Definition: ContainedObject.h:76
StreamBuffer.h
StreamBuffer
Definition: StreamBuffer.h:52
ContainedObject::ContainedObject
ContainedObject(const ContainedObject &)
Copy constructor and assignement: do NOT copy the parent reference...
Definition: ContainedObject.h:51
ContainedObject::ContainedObject
ContainedObject()=default
Constructors.
ContainedObjectList
ObjectList< ContainedObject > ContainedObjectList
Definition: ContainedObject.h:28
std::ostream
STL class.
ContainedObject::classID
static const CLID & classID()
Definition: ContainedObject.h:60
ContainedObject::fillStream
virtual std::ostream & fillStream(std::ostream &s) const
Fill the output stream (ASCII)
Definition: ContainedObject.h:74
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
ObjectList
Definition: ContainedObject.h:24
ContainedObject::index
virtual long index() const
Distance in the parent container.
Definition: ContainedObject.h:68
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:63
ContainedObject::operator=
ContainedObject & operator=(const ContainedObject &)
Definition: ContainedObject.h:53
ContainedObject::clID
virtual const CLID & clID() const
Retrieve pointer to class identifier.
Definition: ContainedObject.h:59
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:65
ObjectContainerBase
Definition: ObjectContainerBase.h:29
Kernel.h
ObjectList::classID
static const CLID & classID()
Definition: ObjectList.h:80
ObjectContainerBase.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
ContainedObject
Definition: ContainedObject.h:41
ContainedObject::serialize
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
Definition: ContainedObject.h:70