ATransientIntProduct

ArrayProduct

DoubleProduct

DummyProduct

EnumProduct

Int16_tProduct

IntProduct

MaybeUninitializedIntProduct

Prodigal

ProductWithNoDictionary

Simple

SimpleDerived

Sortable

StringProduct

TheEnumProduct

TransientIntParentT

TransientIntProduct

UInt64Product

Unsortable

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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
#ifndef DataFormats_TestObjects_ToyProducts_h
#define DataFormats_TestObjects_ToyProducts_h

/*----------------------------------------------------------------------

Toy EDProducts for testing purposes only.

----------------------------------------------------------------------*/

#include "DataFormats/Common/interface/AssociationVector.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/Common/interface/OwnVector.h"
#include "DataFormats/Common/interface/SortedCollection.h"
#include "DataFormats/Common/interface/Uninitialized.h"
#include "FWCore/Utilities/interface/typedefs.h"

#include <stdexcept>
#include <string>
#include <vector>

namespace edmtest {

  // Toy products

  struct ProductWithNoDictionary {};

  struct DummyProduct {};

  struct ArrayProduct {
    explicit ArrayProduct(int i = 0) : value{i} {}
    int value[1];
  };

  struct EnumProduct {
    enum TheEnumProduct { TheZero = 0, TheOne = 1, TheTwo = 2, TheThree = 3 };
    explicit EnumProduct(TheEnumProduct e = TheZero) : value(e) {}
    ~EnumProduct() {}

    TheEnumProduct value;
  };

  struct IntProduct {
    explicit IntProduct(int i = 0) : value(i) {}
    ~IntProduct() {}

    bool operator==(IntProduct const& rhs) const { return value == rhs.value; }

    cms_int32_t value;
  };

  struct MaybeUninitializedIntProduct {
    explicit MaybeUninitializedIntProduct(edm::Uninitialized) {}
    explicit MaybeUninitializedIntProduct(int i) : value(i) {}
    ~MaybeUninitializedIntProduct() {}

    bool operator==(MaybeUninitializedIntProduct const& rhs) const { return value == rhs.value; }

    cms_int32_t value;
  };

  struct UInt64Product {
    explicit UInt64Product(unsigned long long i = 0) : value(i) {}
    ~UInt64Product() {}

    unsigned long long value;
  };

  struct TransientIntProduct {
    explicit TransientIntProduct(int i = 0) : value(i) {}
    ~TransientIntProduct() {}

    cms_int32_t value;
    ProductWithNoDictionary dummy;
  };

  struct ATransientIntProduct {  // just to have a name earlier in alphabetic
    explicit ATransientIntProduct(int i = 0) : value(i) {}
    ~ATransientIntProduct() {}

    cms_int32_t value;
    ProductWithNoDictionary dummy;
  };

  template <int TAG>
  struct TransientIntParentT {
    explicit TransientIntParentT(int i = 0) : value(i) {}

    cms_int32_t value;
  };
  constexpr int TransientIntParentTag = 1;
  using TransientIntParent = TransientIntParentT<TransientIntParentTag>;

  struct Int16_tProduct {
    explicit Int16_tProduct(int16_t i = 0, uint16_t j = 1) : value(i), uvalue(j) {}
    ~Int16_tProduct() {}
    int16_t value;
    uint16_t uvalue;
  };

  struct DoubleProduct {
    explicit DoubleProduct(double d = 2.2) : value(d) {}
    ~DoubleProduct() {}

    double value;
  };

  struct StringProduct {
    StringProduct() : name_() {}
    explicit StringProduct(std::string const& s) : name_(s) {}
    std::string name_;
  };

  struct Simple {
    Simple() : key(0), value(0.0) {}
    virtual ~Simple();
    typedef cms_int32_t key_type;
    key_type key;
    double value;
    key_type id() const { return key; }
    virtual Simple* clone() const;
  };

  inline bool operator==(Simple const& a, Simple const& b) { return (a.key == b.key && a.value == b.value); }

  inline bool operator<(Simple const& a, Simple const& b) { return a.key < b.key; }

  struct SimpleDerived : public Simple {
    SimpleDerived() : Simple(), dummy(0.0) {}
    ~SimpleDerived() override;
    double dummy;
    SimpleDerived* clone() const override;
  };

  struct Sortable {
    cms_int32_t data;
    Sortable() : data(0) {}
    explicit Sortable(int i) : data(i) {}
  };

  inline bool operator==(Sortable const& a, Sortable const& b) { return (a.data == b.data); }

  inline bool operator<(Sortable const& a, Sortable const& b) { return a.data < b.data; }

  struct Unsortable : public edm::DoNotSortUponInsertion {
    cms_int32_t data;
    Unsortable() : data(0) {}
    explicit Unsortable(int i) : data(i) {}
  };

  inline bool operator<(Unsortable const&, Unsortable const&) {
    throw std::logic_error("operator< called for Unsortable");
  }

  struct Prodigal : public edm::DoNotRecordParents {
    cms_int32_t data;
    Prodigal() : data(0) {}
    explicit Prodigal(int i) : data(i) {}
  };

  typedef edm::SortedCollection<Simple> SCSimpleProduct;
  typedef std::vector<Simple> VSimpleProduct;
  typedef edm::OwnVector<Simple> OVSimpleProduct;
  typedef edm::OwnVector<SimpleDerived> OVSimpleDerivedProduct;
  typedef edm::AssociationVector<edm::RefProd<std::vector<Simple> >, std::vector<Simple> > AVSimpleProduct;
  typedef edm::DetSetVector<Sortable> DSVSimpleProduct;
  typedef edm::DetSetVector<Unsortable> DSVWeirdProduct;

  typedef edmNew::DetSetVector<Sortable> DSTVSimpleProduct;
  typedef edmNew::DetSetVector<SimpleDerived> DSTVSimpleDerivedProduct;
}  // namespace edmtest
#endif