File indexing completed on 2025-07-14 08:50:46
0001
0002
0003 #ifndef EDM4HEP_MutableTimeSeries_H
0004 #define EDM4HEP_MutableTimeSeries_H
0005
0006 #include "edm4hep/TimeSeriesObj.h"
0007
0008 #include "edm4hep/TimeSeries.h"
0009
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015
0016 #include <cstdint>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4hep {
0024 class TimeSeriesCollection;
0025 }
0026
0027 namespace edm4hep {
0028
0029
0030
0031
0032
0033 class MutableTimeSeries {
0034
0035 friend class TimeSeriesCollection;
0036 friend class TimeSeriesMutableCollectionIterator;
0037 friend class TimeSeries;
0038
0039 public:
0040 using object_type = TimeSeries;
0041 using collection_type = TimeSeriesCollection;
0042
0043
0044 MutableTimeSeries();
0045
0046
0047 MutableTimeSeries(std::uint64_t cellID, float time, float interval);
0048
0049
0050 MutableTimeSeries(const MutableTimeSeries& other) = default;
0051
0052
0053 MutableTimeSeries& operator=(MutableTimeSeries other);
0054
0055
0056
0057 MutableTimeSeries clone(bool cloneRelations = true) const;
0058
0059
0060 ~MutableTimeSeries() = default;
0061
0062 public:
0063
0064 std::uint64_t getCellID() const;
0065
0066
0067 float getTime() const;
0068
0069
0070 float getInterval() const;
0071
0072
0073 void setCellID(std::uint64_t value);
0074
0075 std::uint64_t& getCellID();
0076
0077 [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0078
0079
0080 void setTime(float value);
0081
0082 float& getTime();
0083
0084 [[deprecated("use getTime instead")]] float& time();
0085
0086
0087 void setInterval(float value);
0088
0089 float& getInterval();
0090
0091 [[deprecated("use getInterval instead")]] float& interval();
0092
0093 void addToAmplitude(const float&);
0094 std::size_t amplitude_size() const;
0095 float getAmplitude(std::size_t) const;
0096 std::vector<float>::const_iterator amplitude_begin() const;
0097 std::vector<float>::const_iterator amplitude_end() const;
0098 podio::RelationRange<float> getAmplitude() const;
0099
0100
0101 bool isAvailable() const;
0102
0103 void unlink() {
0104 m_obj = podio::utils::MaybeSharedPtr<TimeSeriesObj>{nullptr};
0105 }
0106
0107 bool operator==(const MutableTimeSeries& other) const {
0108 return m_obj == other.m_obj;
0109 }
0110 bool operator==(const TimeSeries& other) const;
0111
0112 bool operator!=(const MutableTimeSeries& other) const {
0113 return !(*this == other);
0114 }
0115 bool operator!=(const TimeSeries& other) const {
0116 return !(*this == other);
0117 }
0118
0119
0120 bool operator<(const MutableTimeSeries& other) const {
0121 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0122 }
0123
0124 podio::ObjectID id() const {
0125 return getObjectID();
0126 }
0127
0128 const podio::ObjectID getObjectID() const;
0129
0130 friend void swap(MutableTimeSeries& a, MutableTimeSeries& b) {
0131 using std::swap;
0132 swap(a.m_obj, b.m_obj);
0133 }
0134
0135 private:
0136
0137 explicit MutableTimeSeries(podio::utils::MaybeSharedPtr<TimeSeriesObj> obj);
0138
0139 podio::utils::MaybeSharedPtr<TimeSeriesObj> m_obj{nullptr};
0140 };
0141
0142 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0143 void to_json(nlohmann::json& j, const MutableTimeSeries& value);
0144 #endif
0145
0146 }
0147
0148 #endif