Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_ParameterSet_Entry_h
0002 #define FWCore_ParameterSet_Entry_h
0003 
0004 // ----------------------------------------------------------------------
0005 // interface to Entry and related types
0006 //
0007 //
0008 // The functions here are expected to go away.  The exception
0009 // processing is not ideal and is not a good model to follow.
0010 //
0011 // ----------------------------------------------------------------------
0012 
0013 #include <string>
0014 #include <vector>
0015 #include <iosfwd>
0016 
0017 #include "FWCore/Utilities/interface/FileInPath.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 #include "FWCore/Utilities/interface/ESInputTag.h"
0020 //@@ not needed, but there might be trouble if we take it out
0021 #include "DataFormats/Provenance/interface/EventRange.h"
0022 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0023 #include "DataFormats/Provenance/interface/LuminosityBlockRange.h"
0024 #include "DataFormats/Provenance/interface/EventID.h"
0025 
0026 // ----------------------------------------------------------------------
0027 // contents
0028 
0029 namespace cms {
0030   class Digest;
0031 }
0032 
0033 namespace edm {
0034   // forward declarations:
0035   class ParameterSet;
0036 
0037   // ----------------------------------------------------------------------
0038   // Entry
0039 
0040   class Entry {
0041   public:
0042     // Bool
0043     Entry(std::string const& name, bool val, bool is_tracked);
0044     bool getBool() const;
0045 
0046     // Int32
0047     Entry(std::string const& name, int val, bool is_tracked);
0048     int getInt32() const;
0049 
0050     // vInt32
0051     Entry(std::string const& name, std::vector<int> const& val, bool is_tracked);
0052     std::vector<int> getVInt32() const;
0053 
0054     // Uint32
0055     Entry(std::string const& name, unsigned val, bool is_tracked);
0056     unsigned getUInt32() const;
0057 
0058     // vUint32
0059     Entry(std::string const& name, std::vector<unsigned> const& val, bool is_tracked);
0060     std::vector<unsigned> getVUInt32() const;
0061 
0062     // Int64
0063     Entry(std::string const& name, long long val, bool is_tracked);
0064     long long getInt64() const;
0065 
0066     // vInt64
0067     Entry(std::string const& name, std::vector<long long> const& val, bool is_tracked);
0068     std::vector<long long> getVInt64() const;
0069 
0070     // Uint64
0071     Entry(std::string const& name, unsigned long long val, bool is_tracked);
0072     unsigned long long getUInt64() const;
0073 
0074     // vUint64
0075     Entry(std::string const& name, std::vector<unsigned long long> const& val, bool is_tracked);
0076     std::vector<unsigned long long> getVUInt64() const;
0077 
0078     // Double
0079     Entry(std::string const& name, double val, bool is_tracked);
0080     double getDouble() const;
0081 
0082     // vDouble
0083     Entry(std::string const& name, std::vector<double> const& val, bool is_tracked);
0084     std::vector<double> getVDouble() const;
0085 
0086     // String
0087     Entry(std::string const& name, std::string const& val, bool is_tracked);
0088     std::string getString() const;
0089 
0090     // vString
0091     Entry(std::string const& name, std::vector<std::string> const& val, bool is_tracked);
0092     std::vector<std::string> getVString() const;
0093 
0094     // FileInPath
0095     Entry(std::string const& name, FileInPath const& val, bool is_tracked);
0096     FileInPath getFileInPath() const;
0097 
0098     // InputTag
0099     Entry(std::string const& name, InputTag const& tag, bool is_tracked);
0100     InputTag getInputTag() const;
0101 
0102     // InputTag
0103     Entry(std::string const& name, std::vector<InputTag> const& vtag, bool is_tracked);
0104     std::vector<InputTag> getVInputTag() const;
0105 
0106     // ESInputTag
0107     Entry(std::string const& name, ESInputTag const& tag, bool is_tracked);
0108     ESInputTag getESInputTag() const;
0109 
0110     // VESInputTag
0111     Entry(std::string const& name, std::vector<ESInputTag> const& vtag, bool is_tracked);
0112     std::vector<ESInputTag> getVESInputTag() const;
0113 
0114     // EventID
0115     Entry(std::string const& name, EventID const& tag, bool is_tracked);
0116     EventID getEventID() const;
0117 
0118     // VEventID
0119     Entry(std::string const& name, std::vector<EventID> const& vtag, bool is_tracked);
0120     std::vector<EventID> getVEventID() const;
0121 
0122     // LuminosityBlockID
0123     Entry(std::string const& name, LuminosityBlockID const& tag, bool is_tracked);
0124     LuminosityBlockID getLuminosityBlockID() const;
0125 
0126     // VLuminosityBlockID
0127     Entry(std::string const& name, std::vector<LuminosityBlockID> const& vtag, bool is_tracked);
0128     std::vector<LuminosityBlockID> getVLuminosityBlockID() const;
0129 
0130     // LuminosityBlockRange
0131     Entry(std::string const& name, LuminosityBlockRange const& tag, bool is_tracked);
0132     LuminosityBlockRange getLuminosityBlockRange() const;
0133 
0134     // VLuminosityBlockRange
0135     Entry(std::string const& name, std::vector<LuminosityBlockRange> const& vtag, bool is_tracked);
0136     std::vector<LuminosityBlockRange> getVLuminosityBlockRange() const;
0137 
0138     // EventRange
0139     Entry(std::string const& name, EventRange const& tag, bool is_tracked);
0140     EventRange getEventRange() const;
0141 
0142     // VEventRange
0143     Entry(std::string const& name, std::vector<EventRange> const& vtag, bool is_tracked);
0144     std::vector<EventRange> getVEventRange() const;
0145 
0146     // ParameterSet
0147     Entry(std::string const& name, ParameterSet const& val, bool is_tracked);
0148     ParameterSet getPSet() const;
0149 
0150     // vPSet
0151     Entry(std::string const& name, std::vector<ParameterSet> const& val, bool is_tracked);
0152 
0153     std::vector<ParameterSet> getVPSet() const;
0154 
0155     // coded string
0156     Entry(std::string name, std::string_view);
0157     Entry(std::string name, std::string_view type, std::string_view value, bool is_tracked);
0158     Entry(std::string name, std::string_view type, std::vector<std::string> const& value, bool is_tracked);
0159 
0160     ~Entry() = default;
0161     Entry(Entry const&) = default;
0162     Entry(Entry&&) = default;
0163     Entry& operator=(Entry const&) = default;
0164     Entry& operator=(Entry&&) = default;
0165     // encode
0166 
0167     std::string toString() const;
0168     void toString(std::string& result) const;
0169     void toDigest(cms::Digest& digest) const;
0170 
0171     size_t sizeOfString() const { return rep_.size() + 4; }
0172 
0173     // access
0174     bool isTracked() const { return tracked_ == '+'; }
0175 
0176     char typeCode() const { return type_; }
0177 
0178     friend std::ostream& operator<<(std::ostream& ost, Entry const& entry);
0179 
0180     //empty string view denotes failure to find bounds
0181     static std::string_view bounds(std::string_view, std::size_t iEndHint);
0182 
0183   private:
0184     std::string name_;
0185     std::string rep_;
0186     char type_;
0187     char tracked_;
0188 
0189     // verify class invariant
0190     void validate() const;
0191 
0192     // decode
0193     bool fromString(std::string_view::const_iterator b, std::string_view::const_iterator e);
0194 
0195     // helpers to throw exceptions
0196     void throwValueError(char const* expectedType) const;
0197     void throwEntryError(char const* expectedType, std::string const& badRep) const;
0198     void throwEncodeError(char const* type) const;
0199 
0200   };  // Entry
0201 
0202   inline bool operator==(Entry const& a, Entry const& b) { return a.toString() == b.toString(); }
0203 
0204   inline bool operator!=(Entry const& a, Entry const& b) { return !(a == b); }
0205 }  // namespace edm
0206 
0207 #endif