File indexing completed on 2023-03-17 10:49:24
0001 #ifndef DataFormats_Common_OrphanHandleBase_h
0002 #define DataFormats_Common_OrphanHandleBase_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include "DataFormats/Provenance/interface/ProductID.h"
0024 #include <cassert>
0025 #include <algorithm>
0026
0027 namespace edm {
0028 class OrphanHandleBase {
0029 public:
0030 OrphanHandleBase() : product_(), id_(ProductID()) {}
0031
0032 OrphanHandleBase(void const* iProd, ProductID const& iId) : product_(iProd), id_(iId) { assert(iProd); }
0033
0034 ~OrphanHandleBase() {}
0035
0036 void clear() {
0037 product_ = nullptr;
0038 id_ = ProductID();
0039 }
0040
0041 void swap(OrphanHandleBase& other) {
0042 using std::swap;
0043 swap(product_, other.product_);
0044 std::swap(id_, other.id_);
0045 }
0046
0047 OrphanHandleBase& operator=(OrphanHandleBase const& rhs) {
0048 OrphanHandleBase temp(rhs);
0049 this->swap(temp);
0050 return *this;
0051 }
0052
0053 bool isValid() const { return product_ && id_ != ProductID(); }
0054
0055 ProductID id() const;
0056
0057 protected:
0058 void const* productStorage() const;
0059
0060 private:
0061 void const* product_;
0062 ProductID id_;
0063 };
0064
0065
0066 inline void swap(OrphanHandleBase& a, OrphanHandleBase& b) { a.swap(b); }
0067 }
0068
0069 #endif