Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-17 23:57:20

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