Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:52

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework includes
0015 #include <DD4hep/IOV.h>
0016 #include <DD4hep/InstanceCount.h>
0017 #include <DD4hep/detail/Handle.inl>
0018 #include <DD4hep/detail/ConditionsInterna.h>
0019 
0020 using namespace dd4hep;
0021 
0022 #if defined(DD4HEP_CONDITIONS_HAVE_NAME)
0023 DD4HEP_INSTANTIATE_HANDLE_NAMED(detail::ConditionObject);
0024 #else
0025 DD4HEP_INSTANTIATE_HANDLE_UNNAMED(detail::ConditionObject);
0026 #endif
0027 
0028 namespace {
0029   /// Simple cast union to perform pointer arithmetic on raw byte based memory
0030   union  _P {
0031     const char* character;
0032     const void* p_void;
0033     void**      pp_void;
0034     const detail::ConditionObject* o;
0035     _P(const void* val) { p_void = val; }
0036   };
0037 }
0038 
0039 /// Default constructor
0040 detail::ConditionObject::ConditionObject()
0041 {
0042   InstanceCount::increment(this);
0043 }
0044 
0045 /// Standard constructor
0046 #if defined(DD4HEP_CONDITIONS_HAVE_NAME)
0047 detail::ConditionObject::ConditionObject(const std::string& nam,const std::string& tit)
0048   : NamedObject(nam, tit), data()
0049 #else
0050 detail::ConditionObject::ConditionObject(const std::string& ,const std::string& )
0051   : data()
0052 #endif
0053 {
0054   InstanceCount::increment(this);
0055 }
0056 
0057 /// Standard Destructor
0058 detail::ConditionObject::~ConditionObject()  {
0059   InstanceCount::decrement(this);
0060 }
0061 
0062 /// Release object (Used by persistency mechanism)
0063 void detail::ConditionObject::release()  {
0064   if ( --refCount <= 0 ) delete this;
0065 }
0066 
0067 /// Data offset from the opaque data block pointer to the condition
0068 size_t detail::ConditionObject::offset()   {
0069   static _P p((void*)0x1000);
0070   static std::size_t off = _P(&p.o->data.grammar).character - p.character + sizeof(OpaqueData::grammar);
0071   return off;
0072 }
0073 
0074 /// Access the bound data payload. Exception id object is unbound
0075 void* detail::ConditionObject::payload() const   {
0076   return *(_P(_P(this).character+offset()).pp_void);
0077 }
0078 
0079 /// Move data content: 'from' will be reset to NULL
0080 detail::ConditionObject& detail::ConditionObject::move(ConditionObject& /* from */)   {
0081   return *this;
0082 }
0083 
0084 /// Access safely the IOV
0085 const dd4hep::IOV* detail::ConditionObject::iovData() const    {
0086   if ( iov ) return iov;
0087   invalidHandleError<IOV>();
0088   return 0;
0089 }
0090 
0091 /// Access safely the IOV-type
0092 const dd4hep::IOVType* detail::ConditionObject::iovType() const    {
0093   if ( iov && iov->iovType ) return iov->iovType;
0094   invalidHandleError<IOVType>();
0095   return 0;
0096 }
0097 
0098 
0099 #include <DD4hep/GrammarUnparsed.h>
0100 static auto s_registry = GrammarRegistry::pre_note<std::vector<Condition> >(1);