-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge CMSSW_10_5_X into CMSSW_10_5_DEVEL_X.
- Loading branch information
Showing
24 changed files
with
776 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#ifndef FWCore_Framework_ESValidHandle_h | ||
#define FWCore_Framework_ESValidHandle_h | ||
// -*- C++ -*- | ||
// | ||
// Package: Framework | ||
// Class : ESValidHandle | ||
// | ||
/**\class ESValidHandle ESValidHandle.h FWCore/Framework/interface/ESValidHandle.h | ||
Description: <one line class summary> | ||
Usage: | ||
<usage> | ||
*/ | ||
// | ||
// Author: Chris Jones | ||
// Created: Tue Feb 5 14:47:35 EST 2019 | ||
// | ||
|
||
// system include files | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/ComponentDescription.h" | ||
|
||
#include <exception> | ||
#include <memory> | ||
#include <utility> | ||
|
||
namespace edm { | ||
|
||
namespace esvhhelper { | ||
void throwIfNotValid(const void*) noexcept(false); | ||
} | ||
|
||
template<typename T> | ||
class ESValidHandle { | ||
public: | ||
typedef T value_type; | ||
|
||
ESValidHandle() = delete; | ||
ESValidHandle(T const& iData, edm::eventsetup::ComponentDescription const* desc) noexcept : | ||
data_{&iData}, | ||
description_{desc} {} | ||
|
||
ESValidHandle(ESValidHandle<T> const&) = default; | ||
ESValidHandle(ESValidHandle<T>&&) = default; | ||
ESValidHandle& operator=(ESValidHandle<T> const&) = default; | ||
ESValidHandle& operator=(ESValidHandle<T>&&) = default; | ||
|
||
// ---------- const member functions --------------------- | ||
T const* product() const noexcept { return data_; } | ||
T const* operator->() const noexcept { return product(); } | ||
T const& operator*() const noexcept { return *product(); } | ||
// ---------- static member functions -------------------- | ||
static constexpr bool transientAccessOnly = false; | ||
|
||
// ---------- member functions --------------------------- | ||
private: | ||
T const* data_{nullptr}; | ||
edm::eventsetup::ComponentDescription const* description_{nullptr}; | ||
|
||
}; | ||
|
||
/** Take a handle (e.g. edm::ESHandle<T>) and | ||
create a edm::ESValidHandle<T>. If the argument is an invalid handle, | ||
an exception will be thrown. | ||
*/ | ||
template<typename U> | ||
auto | ||
makeESValid(const U& iOtherHandleType) noexcept(false) { | ||
esvhhelper::throwIfNotValid(iOtherHandleType.product()); | ||
//because of the check, we know this is valid and do not have to check again | ||
return ESValidHandle<typename U::value_type>(*iOtherHandleType.product(), iOtherHandleType.description()); | ||
} | ||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "FWCore/Framework/interface/ESValidHandle.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
|
||
namespace edm::esvhhelper { | ||
void | ||
throwIfNotValid(const void* iProduct) noexcept(false) { | ||
if(nullptr == iProduct) { | ||
throw cms::Exception("Invalid Product")<<"Attempted to fill a edm::ESValidHandle with an invalid product"; | ||
} | ||
} | ||
} |
Oops, something went wrong.