File indexing completed on 2024-04-06 12:12:05
0001 #ifndef FWCore_Framework_PrincipalCache_h
0002 #define FWCore_Framework_PrincipalCache_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "FWCore/Utilities/interface/ReusableObjectHolder.h"
0015
0016 #include <memory>
0017 #include <vector>
0018
0019 namespace edm {
0020
0021 class ProcessBlockPrincipal;
0022 class RunPrincipal;
0023 class LuminosityBlockPrincipal;
0024 class EventPrincipal;
0025 class ProductRegistry;
0026 class PreallocationConfiguration;
0027
0028 class PrincipalCache {
0029 public:
0030 PrincipalCache();
0031 ~PrincipalCache();
0032 PrincipalCache(PrincipalCache&&) = default;
0033
0034 ProcessBlockPrincipal& processBlockPrincipal() const { return *processBlockPrincipal_; }
0035 ProcessBlockPrincipal& inputProcessBlockPrincipal() const { return *inputProcessBlockPrincipal_; }
0036
0037 enum class ProcessBlockType { New, Input };
0038 ProcessBlockPrincipal& processBlockPrincipal(ProcessBlockType processBlockType) const {
0039 return processBlockType == ProcessBlockType::Input ? *inputProcessBlockPrincipal_ : *processBlockPrincipal_;
0040 }
0041
0042 std::shared_ptr<RunPrincipal> getAvailableRunPrincipalPtr();
0043 std::shared_ptr<LuminosityBlockPrincipal> getAvailableLumiPrincipalPtr();
0044
0045 EventPrincipal& eventPrincipal(unsigned int iStreamIndex) const { return *(eventPrincipals_[iStreamIndex]); }
0046
0047 void setNumberOfConcurrentPrincipals(PreallocationConfiguration const&);
0048 void insert(std::unique_ptr<ProcessBlockPrincipal>);
0049 void insertForInput(std::unique_ptr<ProcessBlockPrincipal>);
0050 void insert(std::unique_ptr<RunPrincipal>);
0051 void insert(std::unique_ptr<LuminosityBlockPrincipal>);
0052 void insert(std::shared_ptr<EventPrincipal>);
0053
0054 void adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const>);
0055
0056 void adjustIndexesAfterProductRegistryAddition();
0057
0058 private:
0059 std::unique_ptr<ProcessBlockPrincipal> processBlockPrincipal_;
0060 std::unique_ptr<ProcessBlockPrincipal> inputProcessBlockPrincipal_;
0061 edm::ReusableObjectHolder<RunPrincipal> runHolder_;
0062 edm::ReusableObjectHolder<LuminosityBlockPrincipal> lumiHolder_;
0063 std::vector<std::shared_ptr<EventPrincipal>> eventPrincipals_;
0064 };
0065 }
0066
0067 #endif