Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-19 02:16:28

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   struct ATransientIntProduct {  // just to have a name earlier in alphabetic
0067     explicit ATransientIntProduct(int i = 0) : value(i) {}
0068     ~ATransientIntProduct() {}
0069 
0070     cms_int32_t value;
0071     ProductWithNoDictionary dummy;
0072   };
0073 
0074   template <int TAG>
0075   struct TransientIntParentT {
0076     explicit TransientIntParentT(int i = 0) : value(i) {}
0077 
0078     cms_int32_t value;
0079   };
0080   constexpr int TransientIntParentTag = 1;
0081   using TransientIntParent = TransientIntParentT<TransientIntParentTag>;
0082 
0083   struct Int16_tProduct {
0084     explicit Int16_tProduct(int16_t i = 0, uint16_t j = 1) : value(i), uvalue(j) {}
0085     ~Int16_tProduct() {}
0086     int16_t value;
0087     uint16_t uvalue;
0088   };
0089 
0090   struct DoubleProduct {
0091     explicit DoubleProduct(double d = 2.2) : value(d) {}
0092     ~DoubleProduct() {}
0093 
0094     double value;
0095   };
0096 
0097   struct StringProduct {
0098     StringProduct() : name_() {}
0099     explicit StringProduct(std::string const& s) : name_(s) {}
0100     std::string name_;
0101   };
0102 
0103   struct Simple {
0104     Simple() : key(0), value(0.0) {}
0105     virtual ~Simple();
0106     typedef cms_int32_t key_type;
0107     key_type key;
0108     double value;
0109     key_type id() const { return key; }
0110     virtual Simple* clone() const;
0111   };
0112 
0113   inline bool operator==(Simple const& a, Simple const& b) { return (a.key == b.key && a.value == b.value); }
0114 
0115   inline bool operator<(Simple const& a, Simple const& b) { return a.key < b.key; }
0116 
0117   struct SimpleDerived : public Simple {
0118     SimpleDerived() : Simple(), dummy(0.0) {}
0119     ~SimpleDerived() override;
0120     double dummy;
0121     SimpleDerived* clone() const override;
0122   };
0123 
0124   struct Sortable {
0125     cms_int32_t data;
0126     Sortable() : data(0) {}
0127     explicit Sortable(int i) : data(i) {}
0128   };
0129 
0130   inline bool operator==(Sortable const& a, Sortable const& b) { return (a.data == b.data); }
0131 
0132   inline bool operator<(Sortable const& a, Sortable const& b) { return a.data < b.data; }
0133 
0134   struct Unsortable : public edm::DoNotSortUponInsertion {
0135     cms_int32_t data;
0136     Unsortable() : data(0) {}
0137     explicit Unsortable(int i) : data(i) {}
0138   };
0139 
0140   inline bool operator<(Unsortable const&, Unsortable const&) {
0141     throw std::logic_error("operator< called for Unsortable");
0142   }
0143 
0144   struct Prodigal : public edm::DoNotRecordParents {
0145     cms_int32_t data;
0146     Prodigal() : data(0) {}
0147     explicit Prodigal(int i) : data(i) {}
0148   };
0149 
0150   typedef edm::SortedCollection<Simple> SCSimpleProduct;
0151   typedef std::vector<Simple> VSimpleProduct;
0152   typedef edm::OwnVector<Simple> OVSimpleProduct;
0153   typedef edm::OwnVector<SimpleDerived> OVSimpleDerivedProduct;
0154   typedef edm::AssociationVector<edm::RefProd<std::vector<Simple> >, std::vector<Simple> > AVSimpleProduct;
0155   typedef edm::DetSetVector<Sortable> DSVSimpleProduct;
0156   typedef edm::DetSetVector<Unsortable> DSVWeirdProduct;
0157 
0158   typedef edmNew::DetSetVector<Sortable> DSTVSimpleProduct;
0159   typedef edmNew::DetSetVector<SimpleDerived> DSTVSimpleDerivedProduct;
0160 }  // namespace edmtest
0161 #endif