Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:07:17

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDI_OBJECTCONTAINERBASE_H
0012 #define GAUDI_OBJECTCONTAINERBASE_H 1
0013 
0014 // Include files
0015 #include "GaudiKernel/DataObject.h"
0016 #include "GaudiKernel/Kernel.h"
0017 
0018 // Forward declarations
0019 class ContainedObject;
0020 
0021 /** @class ObjectContainerBase ObjectContainerBase.h GaudiKernel/ObjectContainerBase.h
0022     ObjectContainerBase is the base class for Gaudi container classes. The main motivation
0023     is to allow contained object to be removed from the container on deletion and also for
0024     knowing it own index (e.g. distance, key, ...) in the container.
0025 
0026     @author Pavel Binko
0027     @author Pere Mato
0028 */
0029 class GAUDI_API ObjectContainerBase : public DataObject {
0030 
0031 protected:
0032   /// Constructor
0033   ObjectContainerBase()                                   = default;
0034   ObjectContainerBase( ObjectContainerBase&& )            = default;
0035   ObjectContainerBase& operator=( ObjectContainerBase&& ) = default;
0036   ~ObjectContainerBase() override                         = default;
0037 
0038 public:
0039   /// size_type, to conform the STL container interface
0040   typedef size_t size_type;
0041 
0042   /// Distance of a given object from the beginning of its container
0043   virtual long index( const ContainedObject* obj ) const = 0;
0044 
0045   /// Pointer to an object of a given distance
0046   virtual const ContainedObject* containedObject( long dist ) const = 0;
0047   virtual ContainedObject*       containedObject( long dist )       = 0;
0048 
0049   /// Number of objects in the container
0050   virtual size_type numberOfObjects() const = 0;
0051 
0052   /** Virtual functions (forwards to the concrete container definitions)
0053       Add an object to the container. On success the object's index is
0054       returned.                                                      */
0055   virtual long add( ContainedObject* pObject ) = 0;
0056 
0057   /** Release object from the container (the pointer will be removed
0058       from the container, but the object itself will remain alive).
0059       If the object was fount it's index is returned.                */
0060   virtual long remove( ContainedObject* value ) = 0;
0061 };
0062 
0063 #endif // GAUDI_OBJECTCONTAINERBASE_H