File indexing completed on 2021-02-14 12:54:48
0001 #ifndef DataFormats_TestObjects_ToyProducts_h
0002 #define DataFormats_TestObjects_ToyProducts_h
0003
0004
0005
0006
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
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 struct Int16_tProduct {
0067 explicit Int16_tProduct(int16_t i = 0, uint16_t j = 1) : value(i), uvalue(j) {}
0068 ~Int16_tProduct() {}
0069 int16_t value;
0070 uint16_t uvalue;
0071 };
0072
0073 struct DoubleProduct {
0074 explicit DoubleProduct(double d = 2.2) : value(d) {}
0075 ~DoubleProduct() {}
0076
0077 double value;
0078 };
0079
0080 struct StringProduct {
0081 StringProduct() : name_() {}
0082 explicit StringProduct(std::string const& s) : name_(s) {}
0083 std::string name_;
0084 };
0085
0086 struct Simple {
0087 Simple() : key(0), value(0.0) {}
0088 virtual ~Simple();
0089 typedef cms_int32_t key_type;
0090 key_type key;
0091 double value;
0092 key_type id() const { return key; }
0093 virtual Simple* clone() const;
0094 };
0095
0096 inline bool operator==(Simple const& a, Simple const& b) { return (a.key == b.key && a.value == b.value); }
0097
0098 inline bool operator<(Simple const& a, Simple const& b) { return a.key < b.key; }
0099
0100 struct SimpleDerived : public Simple {
0101 SimpleDerived() : Simple(), dummy(0.0) {}
0102 ~SimpleDerived() override;
0103 double dummy;
0104 SimpleDerived* clone() const override;
0105 };
0106
0107 struct Sortable {
0108 cms_int32_t data;
0109 Sortable() : data(0) {}
0110 explicit Sortable(int i) : data(i) {}
0111 };
0112
0113 inline bool operator==(Sortable const& a, Sortable const& b) { return (a.data == b.data); }
0114
0115 inline bool operator<(Sortable const& a, Sortable const& b) { return a.data < b.data; }
0116
0117 struct Unsortable : public edm::DoNotSortUponInsertion {
0118 cms_int32_t data;
0119 Unsortable() : data(0) {}
0120 explicit Unsortable(int i) : data(i) {}
0121 };
0122
0123 inline bool operator<(Unsortable const&, Unsortable const&) {
0124 throw std::logic_error("operator< called for Unsortable");
0125 }
0126
0127 struct Prodigal : public edm::DoNotRecordParents {
0128 cms_int32_t data;
0129 Prodigal() : data(0) {}
0130 explicit Prodigal(int i) : data(i) {}
0131 };
0132
0133 typedef edm::SortedCollection<Simple> SCSimpleProduct;
0134 typedef std::vector<Simple> VSimpleProduct;
0135 typedef edm::OwnVector<Simple> OVSimpleProduct;
0136 typedef edm::OwnVector<SimpleDerived> OVSimpleDerivedProduct;
0137 typedef edm::AssociationVector<edm::RefProd<std::vector<Simple> >, std::vector<Simple> > AVSimpleProduct;
0138 typedef edm::DetSetVector<Sortable> DSVSimpleProduct;
0139 typedef edm::DetSetVector<Unsortable> DSVWeirdProduct;
0140
0141 typedef edmNew::DetSetVector<Sortable> DSTVSimpleProduct;
0142 typedef edmNew::DetSetVector<SimpleDerived> DSTVSimpleDerivedProduct;
0143 }
0144 #endif