Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:52

0001 #ifndef FWCore_ParameterSet_VParameterSetEntry_h
0002 #define FWCore_ParameterSet_VParameterSetEntry_h
0003 
0004 /** How ParameterSets are nested inside ParameterSets
0005     The main feature is that they're made persistent
0006     using a ParameterSetID, and only reconstituted as needed,
0007     when the value_ptr = 0;
0008   */
0009 
0010 #include "FWCore/ParameterSet/interface/ParameterSetEntry.h"
0011 #include "FWCore/Utilities/interface/value_ptr.h"
0012 #include "FWCore/Utilities/interface/atomic_value_ptr.h"
0013 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0014 
0015 #include <iosfwd>
0016 #include <string>
0017 #include <vector>
0018 
0019 namespace edm {
0020 
0021   // forward declaration
0022   class ParameterSet;
0023 
0024   class VParameterSetEntry {
0025   public:
0026     // default ctor for serialization
0027     VParameterSetEntry();
0028     VParameterSetEntry(std::vector<ParameterSet> const& vpset, bool isTracked);
0029     VParameterSetEntry(std::string_view rep);
0030 
0031     ~VParameterSetEntry() = default;
0032     VParameterSetEntry(VParameterSetEntry const&) = default;
0033     VParameterSetEntry(VParameterSetEntry&&) = default;
0034     VParameterSetEntry& operator=(VParameterSetEntry const&) = default;
0035     VParameterSetEntry& operator=(VParameterSetEntry&&) = default;
0036 
0037     std::string toString() const;
0038     void toString(std::string& result) const;
0039     void toDigest(cms::Digest& digest) const;
0040 
0041     bool isTracked() const { return tracked_; }
0042 
0043     /// returns the VPSet
0044     std::vector<ParameterSet> const& vpset() const;
0045     std::vector<ParameterSet>& vpsetForUpdate();
0046     /// reconstitutes the VPSet from the registry
0047     void fillVPSet() const;
0048     ParameterSet& psetInVector(int i);
0049 
0050     std::vector<ParameterSet>::size_type size() const;
0051 
0052     void registerPsetsAndUpdateIDs();
0053 
0054     std::string dump(unsigned int indent = 0) const;
0055     friend std::ostream& operator<<(std::ostream& os, VParameterSetEntry const& vpsetEntry);
0056 
0057   private:
0058     bool tracked_;
0059     CMS_THREAD_SAFE mutable atomic_value_ptr<std::vector<ParameterSet> > theVPSet_;
0060     value_ptr<std::vector<ParameterSetID> > theIDs_;
0061   };
0062 }  // namespace edm
0063 #endif