Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Check if the data passed to the frame model is not a nullptr #578

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions include/podio/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class Frame {
///
/// @tparam FrameDataT Arbitrary data container that provides access to the
/// collection buffers as well as the metadata, when
/// requested by the Frame.
/// requested by the Frame. The unique_ptr has to be checked
/// for validity or this constructor will throw an std::invalid_argument
template <typename FrameDataT>
Frame(std::unique_ptr<FrameDataT>);

Expand Down Expand Up @@ -391,11 +392,15 @@ const CollT& Frame::put(CollT&& coll, const std::string& name) {

template <typename FrameDataT>
Frame::FrameModel<FrameDataT>::FrameModel(std::unique_ptr<FrameDataT> data) :
m_mapMtx(std::make_unique<std::mutex>()),
m_data(std::move(data)),
m_dataMtx(std::make_unique<std::mutex>()),
m_idTable(std::move(m_data->getIDTable())),
m_parameters(std::move(m_data->getParameters())) {
m_mapMtx(std::make_unique<std::mutex>()), m_dataMtx(std::make_unique<std::mutex>()) {
if (!data) {
throw std::invalid_argument(
"FrameData is a nullptr. If you are reading from a file it may be corrupted or you may reading beyond the end "
"of the file, please check the validity of the data before creating a Frame.");
}
m_data = std::move(data);
m_idTable = std::move(m_data->getIDTable());
m_parameters = std::move(m_data->getParameters());
}

template <typename FrameDataT>
Expand Down