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
|
#ifndef DataFormats_FWLite_ESHandle_h
#define DataFormats_FWLite_ESHandle_h
// -*- C++ -*-
//
// Package: FWLite
// Class : ESHandle
//
/**\class ESHandle ESHandle.h DataFormats/FWLite/interface/ESHandle.h
Description: Used with fwlite::Record to retrieve conditions information
Usage:
<usage>
*/
//
// Original Author: Chris Jones
// Created: Mon Dec 14 15:16:07 CST 2009
//
// system include files
#include <memory>
#include <typeinfo>
#include <vector>
// user include files
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/propagate_const.h"
// forward declarations
namespace fwlite {
class Record;
std::shared_ptr<cms::Exception> eshandle_not_set_exception();
template <class T>
class ESHandle {
friend class fwlite::Record;
public:
ESHandle() : m_data(nullptr), m_exception(eshandle_not_set_exception()) {}
// ---------- const member functions ---------------------
bool isValid() const { return nullptr != m_data; }
const T& operator*() const {
if (nullptr != m_exception.get()) {
throw *m_exception;
}
return *m_data;
}
const T* operator->() const {
if (nullptr != m_exception.get()) {
throw *m_exception;
}
return m_data;
}
const std::type_info& typeInfo() const { return typeid(T); }
// ---------- static member functions --------------------
// ---------- member functions ---------------------------
private:
ESHandle(const void* iData) : m_data(static_cast<const T*>(iData)), m_exception() {}
ESHandle(cms::Exception* iException) : m_data(nullptr), m_exception(iException) {}
//ESHandle(const ESHandle&); // stop default
//const ESHandle& operator=(const ESHandle&); // stop default
// ---------- member data --------------------------------
const T* m_data;
std::shared_ptr<cms::Exception const> m_exception;
};
} // namespace fwlite
#endif
|