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