Warning, file /include/edm4eic/MutableTensor.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003 #ifndef EDM4EIC_MutableTensor_H
0004 #define EDM4EIC_MutableTensor_H
0005
0006 #include "edm4eic/TensorObj.h"
0007
0008 #include "edm4eic/Tensor.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 edm4eic {
0024 class TensorCollection;
0025 }
0026
0027
0028 namespace edm4eic {
0029
0030
0031
0032
0033
0034
0035 class MutableTensor {
0036
0037 friend class TensorCollection;
0038 friend class TensorMutableCollectionIterator;
0039 friend class Tensor;
0040
0041 public:
0042 using object_type = Tensor;
0043 using collection_type = TensorCollection;
0044
0045
0046 MutableTensor() = default;
0047
0048
0049 MutableTensor(const std::int32_t elementType);
0050
0051
0052 MutableTensor(const MutableTensor& other) = default;
0053
0054
0055 MutableTensor& operator=(MutableTensor other) &;
0056 MutableTensor& operator=(MutableTensor other) && = delete;
0057
0058
0059
0060 MutableTensor clone(bool cloneRelations=true) const;
0061
0062
0063 ~MutableTensor() = default;
0064
0065
0066 public:
0067
0068
0069 std::int32_t getElementType() const;
0070
0071
0072
0073
0074 void setElementType(const std::int32_t elementType);
0075
0076 std::int32_t& getElementType();
0077
0078 [[deprecated("use getElementType instead")]]
0079 std::int32_t& elementType();
0080
0081
0082
0083 void addToShape(const std::int64_t&);
0084 std::size_t shape_size() const;
0085 std::int64_t getShape(std::size_t) const;
0086 std::vector<std::int64_t>::const_iterator shape_begin() const;
0087 std::vector<std::int64_t>::const_iterator shape_end() const;
0088 podio::RelationRange<std::int64_t> getShape() const;
0089 void addToFloatData(const float&);
0090 std::size_t floatData_size() const;
0091 float getFloatData(std::size_t) const;
0092 std::vector<float>::const_iterator floatData_begin() const;
0093 std::vector<float>::const_iterator floatData_end() const;
0094 podio::RelationRange<float> getFloatData() const;
0095 void addToInt64Data(const std::int64_t&);
0096 std::size_t int64Data_size() const;
0097 std::int64_t getInt64Data(std::size_t) const;
0098 std::vector<std::int64_t>::const_iterator int64Data_begin() const;
0099 std::vector<std::int64_t>::const_iterator int64Data_end() const;
0100 podio::RelationRange<std::int64_t> getInt64Data() const;
0101
0102
0103
0104
0105 bool isAvailable() const;
0106
0107 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TensorObj>{nullptr}; }
0108
0109 bool operator==(const MutableTensor& other) const { return m_obj == other.m_obj; }
0110 bool operator==(const Tensor& other) const;
0111
0112 bool operator!=(const MutableTensor& other) const { return !(*this == other); }
0113 bool operator!=(const Tensor& other) const { return !(*this == other); }
0114
0115
0116 bool operator<(const MutableTensor& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0117
0118 podio::ObjectID id() const { return getObjectID(); }
0119
0120 const podio::ObjectID getObjectID() const;
0121
0122 friend std::hash<MutableTensor>;
0123
0124 friend void swap(MutableTensor& a, MutableTensor& b) {
0125 using std::swap;
0126 swap(a.m_obj, b.m_obj);
0127 }
0128
0129 private:
0130
0131 explicit MutableTensor(podio::utils::MaybeSharedPtr<TensorObj> obj);
0132
0133 podio::utils::MaybeSharedPtr<TensorObj> m_obj{new TensorObj{}, podio::utils::MarkOwned};
0134 };
0135
0136 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0137 void to_json(nlohmann::json& j, const MutableTensor& value);
0138 #endif
0139
0140
0141 }
0142
0143
0144
0145 template<>
0146 struct std::hash<edm4eic::MutableTensor> {
0147 std::size_t operator()(const edm4eic::MutableTensor& obj) const {
0148 return std::hash<edm4eic::TensorObj*>{}(obj.m_obj.get());
0149 }
0150 };
0151
0152
0153 #endif