Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef ParameterSet_ParameterSetEntry_h
0002 #define ParameterSet_ParameterSetEntry_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/Utilities/interface/atomic_value_ptr.h"
0011 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0012 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0013 
0014 namespace cms {
0015   class Digest;
0016 }
0017 
0018 namespace edm {
0019 
0020   // forward declaration
0021   class ParameterSet;
0022 
0023   class ParameterSetEntry {
0024   public:
0025     // default ctor for serialization
0026     ParameterSetEntry();
0027     ParameterSetEntry(ParameterSet const& pset, bool isTracked);
0028     ParameterSetEntry(ParameterSetID const& id, bool isTracked);
0029     explicit ParameterSetEntry(std::string_view rep);
0030 
0031     ~ParameterSetEntry() = default;
0032     ParameterSetEntry(ParameterSetEntry const&) = default;
0033     ParameterSetEntry(ParameterSetEntry&&) = default;
0034     ParameterSetEntry& operator=(ParameterSetEntry const&) = default;
0035     ParameterSetEntry& operator=(ParameterSetEntry&&) = 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 isTracked_; }
0042     void setIsTracked(bool v) { isTracked_ = v; }
0043 
0044     ParameterSetID id() const { return theID_; }
0045 
0046     /// returns the PSet
0047     ParameterSet const& pset() const;
0048     ParameterSet& psetForUpdate();
0049     /// reconstitutes the PSet from the registry
0050     void fillPSet() const;
0051 
0052     void updateID();
0053 
0054     std::string dump(unsigned int indent = 0) const;
0055     friend std::ostream& operator<<(std::ostream& os, ParameterSetEntry const& psetEntry);
0056 
0057   private:
0058     bool isTracked_;
0059     // can be internally reconstituted from the ID, in an
0060     // ostensibly const function
0061     CMS_THREAD_SAFE mutable atomic_value_ptr<ParameterSet> thePSet_;
0062 
0063     ParameterSetID theID_;
0064   };
0065 
0066 }  // namespace edm
0067 
0068 #endif