ParameterSetEntry

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#ifndef ParameterSet_ParameterSetEntry_h
#define ParameterSet_ParameterSetEntry_h

/** How ParameterSets are nested inside ParameterSets
    The main feature is that they're made persistent
    using a ParameterSetID, and only reconstituted as needed,
    when the value_ptr = 0;
  */

#include "FWCore/Utilities/interface/atomic_value_ptr.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "DataFormats/Provenance/interface/ParameterSetID.h"

namespace cms {
  class Digest;
}

namespace edm {

  // forward declaration
  class ParameterSet;

  class ParameterSetEntry {
  public:
    // default ctor for serialization
    ParameterSetEntry();
    ParameterSetEntry(ParameterSet const& pset, bool isTracked);
    ParameterSetEntry(ParameterSetID const& id, bool isTracked);
    explicit ParameterSetEntry(std::string_view rep);

    ~ParameterSetEntry() = default;
    ParameterSetEntry(ParameterSetEntry const&) = default;
    ParameterSetEntry(ParameterSetEntry&&) = default;
    ParameterSetEntry& operator=(ParameterSetEntry const&) = default;
    ParameterSetEntry& operator=(ParameterSetEntry&&) = default;

    std::string toString() const;
    void toString(std::string& result) const;
    void toDigest(cms::Digest& digest) const;

    bool isTracked() const { return isTracked_; }
    void setIsTracked(bool v) { isTracked_ = v; }

    ParameterSetID id() const { return theID_; }

    /// returns the PSet
    ParameterSet const& pset() const;
    ParameterSet& psetForUpdate();
    /// reconstitutes the PSet from the registry
    void fillPSet() const;

    void updateID();

    std::string dump(unsigned int indent = 0) const;
    friend std::ostream& operator<<(std::ostream& os, ParameterSetEntry const& psetEntry);

  private:
    bool isTracked_;
    // can be internally reconstituted from the ID, in an
    // ostensibly const function
    CMS_THREAD_SAFE mutable atomic_value_ptr<ParameterSet> thePSet_;

    ParameterSetID theID_;
  };

}  // namespace edm

#endif