File indexing completed on 2025-01-18 09:14:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef EXAMPLES_DDDB_SRC_PLUGINS_DETSERVICE_H
0020 #define EXAMPLES_DDDB_SRC_PLUGINS_DETSERVICE_H
0021
0022
0023 #include "Detector/IDetService.h"
0024 #include "DD4hep/ComponentProperties.h"
0025
0026
0027 #include <mutex>
0028
0029
0030 namespace gaudi {
0031
0032
0033
0034
0035
0036
0037
0038 class DetService : virtual public IDetService,
0039 public dd4hep::PropertyConfigurable
0040 {
0041
0042 class CacheEntry
0043 {
0044 public:
0045 Slice slice;
0046 dd4hep::IOV iov{0};
0047 int age = 0;
0048 CacheEntry() = default;
0049 CacheEntry(CacheEntry &&) = delete;
0050 CacheEntry(const CacheEntry &) = delete;
0051 CacheEntry &operator=(const CacheEntry &) = delete;
0052 };
0053
0054
0055 typedef dd4hep::cond::ConditionsManager ConditionsManager;
0056
0057 typedef std::vector<CacheEntry *> CachedSlices;
0058
0059 typedef std::pair<std::string, Content> ContentEntry;
0060
0061 typedef std::vector<ContentEntry> CachedContents;
0062
0063
0064 std::mutex m_contentLock;
0065
0066 std::mutex m_sliceLock;
0067
0068 ConditionsManager m_manager;
0069
0070 CachedContents m_activeContents;
0071
0072 CachedContents m_openContents;
0073
0074 CachedSlices m_cache;
0075
0076 int m_ageLimit;
0077
0078 protected:
0079
0080 void _age();
0081
0082 Slice _find(Content &content, const IOVType *typ, EventStamp stamp);
0083
0084 Slice _create(Content &content, Context *ctx, const IOVType *typ, EventStamp stamp);
0085
0086 Slice _project(Content &content, Context *ctx, const IOVType *typ, EventStamp stamp);
0087
0088 bool _remove(CachedContents &cache, Content &content);
0089
0090 bool _addContent(Content &content, Condition::key_type key, const std::string &address);
0091
0092 public:
0093
0094 DetService() = delete;
0095
0096 DetService(ConditionsManager m);
0097
0098 DetService(const DetService ©) = delete;
0099
0100 virtual ~DetService() = default;
0101
0102 DetService &operator=(const DetService ©) = delete;
0103
0104
0105 virtual int initialize();
0106
0107 virtual int finalize();
0108
0109
0110
0111 virtual ConditionsManager manager() const override;
0112
0113
0114 virtual const IOVType *iovType(const std::string &identifier) const override;
0115
0116
0117 virtual Content openContent(const std::string &name) override;
0118
0119
0120 virtual Content getContent(const std::string &name) override;
0121
0122
0123 virtual void addContent(Content &content,
0124 Condition::key_type key,
0125 const std::string &address) override;
0126
0127
0128 virtual void addContent(Content &content,
0129 DetElement det,
0130 const std::string &item,
0131 const std::string &address) override;
0132
0133
0134 virtual void addContent(Content &content, Dependency *call) override;
0135
0136
0137 virtual void closeContent(Content &content) override;
0138
0139
0140 virtual bool removeContent(Content &content) override;
0141
0142
0143 virtual Slice project(Content &content,
0144 Context *ctx,
0145 const IOVType *typ,
0146 EventStamp stamp) override;
0147
0148 virtual Slice project(Content &content,
0149 Context *ctx,
0150 const std::string &typ,
0151 EventStamp stamp) override;
0152
0153 virtual Slice project(const std::string &content,
0154 Context *ctx,
0155 const std::string &typ,
0156 EventStamp stamp) override;
0157
0158 virtual void cleanup(const Cleanup &cleaner) override;
0159 };
0160 }
0161 #endif