|
||||
File indexing completed on 2025-01-31 10:09:05
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2021 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 // ==================================================================== 0012 // SmartRefBase.h 0013 // -------------------------------------------------------------------- 0014 // 0015 // Package : Gaudi/Kernel 0016 // Base class for SmartReference objects 0017 // 0018 // Author : Markus Frank 0019 // 0020 // ==================================================================== 0021 #ifndef KERNEL_SMARTREFBASE_H 0022 #define KERNEL_SMARTREFBASE_H 1 0023 0024 // Framework include files 0025 #include "GaudiKernel/StreamBuffer.h" 0026 0027 class ObjectContainerBase; 0028 class SmartRefBase; 0029 class ContainedObject; 0030 class DataObject; 0031 0032 /** User example objects: SmartRefBase 0033 0034 Description: 0035 Base class of SmartReference objects. The base class handles the 0036 object requests to the data store. 0037 The separation of the SmartReference and the base class is mainly to 0038 avoid code blow up, because if the object is not yet present 0039 serious work must be performed in order to request the object from the 0040 store and invoke object updates to keep pointers in sync. 0041 0042 Base Class: None 0043 0044 Dependencies: None 0045 0046 <P> History : 0047 <PRE> 0048 +---------+----------------------------------------------+--------+ 0049 | Date | Comment | Who | 0050 +---------+----------------------------------------------+--------+ 0051 | 21/06/99| Initial version. | MF | 0052 +---------+----------------------------------------------+--------+ 0053 </PRE> 0054 Author: M.Frank 0055 Version: 1.0 0056 */ 0057 class GAUDI_API SmartRefBase { 0058 public: 0059 /// Object data: ID of the link hint to the identifiable object 0060 mutable long m_hintID; 0061 /// Object data: ID of the object within the identifiable container (if any) 0062 mutable long m_linkID; 0063 /// Object data: Pointer to the identifiable object the link originates 0064 mutable const DataObject* m_data; 0065 /// Object data: Pointer to the Contained object (if applicable) 0066 mutable const ContainedObject* m_contd; 0067 0068 mutable long m_type; 0069 0070 enum { DATAOBJECT, CONTAINEDOBJECT }; 0071 0072 /// Load on demand of ContainedObject like references 0073 const ContainedObject* accessData( const ContainedObject* typ ) const; 0074 /// Load on demand of DataObject like references 0075 const DataObject* accessData( const DataObject* typ ) const; 0076 0077 /// Extended equality check 0078 bool isEqualEx( const DataObject* pObj, const SmartRefBase& c ) const; 0079 /// Extended equality check 0080 bool isEqualEx( const ContainedObject* pObj, const SmartRefBase& c ) const; 0081 /// Equality operator for ContainedObject like references 0082 bool isEqual( const ContainedObject* /* pObj */, const SmartRefBase& c ) const { 0083 return ( m_hintID == c.m_hintID && m_linkID == c.m_linkID && m_data == c.m_data && m_contd == c.m_contd ); 0084 } 0085 /// Equality operator for DataObject like references 0086 bool isEqual( const DataObject* /* pObj */, const SmartRefBase& c ) const { 0087 return m_linkID == c.m_linkID && m_data == c.m_data; 0088 } 0089 /// Output streamer for DataObject like references 0090 void writeObject( const DataObject* pObject, StreamBuffer& s ) const { s.addIdentifiedLink( pObject, m_hintID ); } 0091 /// Output streamer for ContainedObject like references 0092 void writeObject( const ContainedObject* pObject, StreamBuffer& s ) const { 0093 s.addContainedLink( pObject, m_hintID, m_linkID ); 0094 } 0095 /// Input streamer for DataObject like references 0096 DataObject* readObject( const DataObject* /* pObject */, StreamBuffer& s ) const { 0097 DataObject* pObj = 0; 0098 s.getIdentifiedLink( pObj, m_hintID ); 0099 return pObj; 0100 } 0101 /// Output streamer for ContainedObject like references 0102 ContainedObject* readObject( const ContainedObject* /* pObject */, StreamBuffer& s ) const { 0103 ContainedObject* pObj = 0; 0104 s.getContainedLink( pObj, m_hintID, m_linkID ); 0105 return pObj; 0106 } 0107 void setObjectType( const ContainedObject* /* pobj */ ) const { m_type = CONTAINEDOBJECT; } 0108 void setObjectType( const DataObject* /* pobj */ ) const { m_type = DATAOBJECT; } 0109 0110 /// Shortcut to access the path to the linked object. 0111 const std::string& path() const; 0112 0113 public: 0114 long objectType() const { return m_type; } 0115 /// Setup smart reference when reading. Must be allowed from external sources. 0116 void set( DataObject* pObj, long hint_id, long link_id ); 0117 }; 0118 #endif // KERNEL_SMARTREFBASE_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |