Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-12 03:12:13

0001 #ifndef DataFormats_TestObjects_ToyProducts_h
0002 #define DataFormats_TestObjects_ToyProducts_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 Toy EDProducts for testing purposes only.
0007 
0008 ----------------------------------------------------------------------*/
0009 
0010 #include "DataFormats/Common/interface/AssociationVector.h"
0011 #include "DataFormats/Common/interface/DetSetVector.h"
0012 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0013 #include "DataFormats/Common/interface/OwnVector.h"
0014 #include "DataFormats/Common/interface/SortedCollection.h"
0015 #include "DataFormats/Common/interface/Uninitialized.h"
0016 #include "FWCore/Utilities/interface/typedefs.h"
0017 
0018 #include <stdexcept>
0019 #include <string>
0020 #include <vector>
0021 
0022 namespace edmtest {
0023 
0024   // Toy products
0025 
0026   struct ProductWithNoDictionary {};
0027 
0028   struct DummyProduct {};
0029 
0030   struct ArrayProduct {
0031     explicit ArrayProduct(int i = 0) : value{i} {}
0032     int value[1];
0033   };
0034 
0035   struct EnumProduct {
0036     enum TheEnumProduct { TheZero = 0, TheOne = 1, TheTwo = 2, TheThree = 3 };
0037     explicit EnumProduct(TheEnumProduct e = TheZero) : value(e) {}
0038     ~EnumProduct() {}
0039 
0040     TheEnumProduct value;
0041   };
0042 
0043   struct IntProduct {
0044     explicit IntProduct(int i = 0) : value(i) {}
0045     ~IntProduct() {}
0046 
0047     bool operator==(IntProduct const& rhs) const { return value == rhs.value; }
0048 
0049     cms_int32_t value;
0050   };
0051 
0052   struct MaybeUninitializedIntProduct {
0053     explicit MaybeUninitializedIntProduct(edm::Uninitialized) {}
0054     explicit MaybeUninitializedIntProduct(int i) : value(i) {}
0055     ~MaybeUninitializedIntProduct() {}
0056 
0057     bool operator==(MaybeUninitializedIntProduct const& rhs) const { return value == rhs.value; }
0058 
0059     cms_int32_t value;
0060   };
0061 
0062   struct UInt64Product {
0063     explicit UInt64Product(unsigned long long i = 0) : value(i) {}
0064     ~UInt64Product() {}
0065 
0066     unsigned long long value;
0067   };
0068 
0069   struct TransientIntProduct {
0070     explicit TransientIntProduct(int i = 0) : value(i) {}
0071     ~TransientIntProduct() {}
0072 
0073     cms_int32_t value;
0074     ProductWithNoDictionary dummy;
0075   };
0076 
0077   struct ATransientIntProduct {  // just to have a name earlier in alphabetic
0078     explicit ATransientIntProduct(int i = 0) : value(i) {}
0079     ~ATransientIntProduct() {}
0080 
0081     cms_int32_t value;
0082     ProductWithNoDictionary dummy;
0083   };
0084 
0085   template <int TAG>
0086   struct TransientIntParentT {
0087     explicit TransientIntParentT(int i = 0) : value(i) {}
0088 
0089     cms_int32_t value;
0090   };
0091   constexpr int TransientIntParentTag = 1;
0092   using TransientIntParent = TransientIntParentT<TransientIntParentTag>;
0093 
0094   struct Int16_tProduct {
0095     explicit Int16_tProduct(int16_t i = 0, uint16_t j = 1) : value(i), uvalue(j) {}
0096     ~Int16_tProduct() {}
0097     int16_t value;
0098     uint16_t uvalue;
0099   };
0100 
0101   struct DoubleProduct {
0102     explicit DoubleProduct(double d = 2.2) : value(d) {}
0103     ~DoubleProduct() {}
0104 
0105     double value;
0106   };
0107 
0108   struct StringProduct {
0109     StringProduct() : name_() {}
0110     explicit StringProduct(std::string const& s) : name_(s) {}
0111     std::string name_;
0112   };
0113 
0114   struct Simple {
0115     Simple() : key(0), value(0.0) {}
0116     virtual ~Simple();
0117     typedef cms_int32_t key_type;
0118     key_type key;
0119     double value;
0120     key_type id() const { return key; }
0121     virtual Simple* clone() const;
0122   };
0123 
0124   inline bool operator==(Simple const& a, Simple const& b) { return (a.key == b.key && a.value == b.value); }
0125 
0126   inline bool operator<(Simple const& a, Simple const& b) { return a.key < b.key; }
0127 
0128   struct SimpleDerived : public Simple {
0129     SimpleDerived() : Simple(), dummy(0.0) {}
0130     ~SimpleDerived() override;
0131     double dummy;
0132     SimpleDerived* clone() const override;
0133   };
0134 
0135   struct Sortable {
0136     cms_int32_t data;
0137     Sortable() : data(0) {}
0138     explicit Sortable(int i) : data(i) {}
0139   };
0140 
0141   inline bool operator==(Sortable const& a, Sortable const& b) { return (a.data == b.data); }
0142 
0143   inline bool operator<(Sortable const& a, Sortable const& b) { return a.data < b.data; }
0144 
0145   struct Unsortable : public edm::DoNotSortUponInsertion {
0146     cms_int32_t data;
0147     Unsortable() : data(0) {}
0148     explicit Unsortable(int i) : data(i) {}
0149   };
0150 
0151   inline bool operator<(Unsortable const&, Unsortable const&) {
0152     throw std::logic_error("operator< called for Unsortable");
0153   }
0154 
0155   struct Prodigal : public edm::DoNotRecordParents {
0156     cms_int32_t data;
0157     Prodigal() : data(0) {}
0158     explicit Prodigal(int i) : data(i) {}
0159   };
0160 
0161   typedef edm::SortedCollection<Simple> SCSimpleProduct;
0162   typedef std::vector<Simple> VSimpleProduct;
0163   typedef edm::OwnVector<Simple> OVSimpleProduct;
0164   typedef edm::OwnVector<SimpleDerived> OVSimpleDerivedProduct;
0165   typedef edm::AssociationVector<edm::RefProd<std::vector<Simple> >, std::vector<Simple> > AVSimpleProduct;
0166   typedef edm::DetSetVector<Sortable> DSVSimpleProduct;
0167   typedef edm::DetSetVector<Unsortable> DSVWeirdProduct;
0168 
0169   typedef edmNew::DetSetVector<Sortable> DSTVSimpleProduct;
0170   typedef edmNew::DetSetVector<SimpleDerived> DSTVSimpleDerivedProduct;
0171 }  // namespace edmtest
0172 #endif