Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
stored_property.hpp
Go to the documentation of this file.
1// (C) Copyright 2025, SECO Mind Srl
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef ASTARTE_DEVICE_SDK_STORED_PROPERTY_H
6#define ASTARTE_DEVICE_SDK_STORED_PROPERTY_H
7
15
16#include <cstdint>
17#include <ostream>
18#include <string>
19#include <string_view>
20
24
25namespace astarte::device {
26
34 public:
44 explicit StoredProperty(std::string_view interface_name, std::string_view path,
45 int32_t version_major, Ownership ownership, Data data);
50 [[nodiscard]] auto get_interface_name() const -> const std::string&;
55 [[nodiscard]] auto get_path() const -> const std::string&;
60 [[nodiscard]] auto get_version_major() const -> int32_t;
65 [[nodiscard]] auto get_ownership() const -> const Ownership&;
70 [[nodiscard]] auto get_value() const -> const Data&;
76 [[nodiscard]] auto operator==(const StoredProperty& other) const -> bool;
82 [[nodiscard]] auto operator!=(const StoredProperty& other) const -> bool;
83
84 private:
85 std::string interface_name_;
86 std::string path_;
87 int32_t version_major_;
88 Ownership ownership_;
89 Data data_;
90};
91
92} // namespace astarte::device
93
95template <>
104 template <typename ParseContext>
105 constexpr auto parse(ParseContext& ctx) const {
106 return ctx.begin();
107 }
108
116 template <typename FormatContext>
117 auto format(const astarte::device::StoredProperty& prop, FormatContext& ctx) const {
118 return astarte_fmt::format_to(ctx.out(),
119 "Interface: {} v{}, Path: {}, Ownership: {}, Value: {}",
121 prop.get_path(), prop.get_ownership(), prop.get_value());
122 }
123};
124
132inline auto operator<<(std::ostream& out, const astarte::device::StoredProperty& prop)
133 -> std::ostream& {
134 out << astarte_fmt::format("{}", prop);
135 return out;
136}
137
138#endif // ASTARTE_DEVICE_SDK_STORED_PROPERTY_H
Represents a single Astarte data value.
Definition data.hpp:61
Represents a stored property on the device.
Definition stored_property.hpp:33
auto get_value() const -> const Data &
Retrieves the value of the property.
auto get_version_major() const -> int32_t
Retrieves the major version of the interface.
auto get_ownership() const -> const Ownership &
Retrieves the ownership of the interface.
auto get_path() const -> const std::string &
Retrieves the property path.
auto get_interface_name() const -> const std::string &
Retrieves the interface name.
StoredProperty(std::string_view interface_name, std::string_view path, int32_t version_major, Ownership ownership, Data data)
Constructs a new Stored Property instance.
Astarte data class and its related methods.
auto operator<<(std::ostream &out, const astarte::device::Data &data) -> std::ostream &
Stream insertion operator for Data.
Definition data.hpp:243
Data formatting utilities for Astarte types.
Umbrella namespace for the Astarte device library.
Definition data.hpp:29
Ownership
Possible Astarte ownership.
Definition ownership.hpp:23
Namespace alias for the formatting library (std or fmt).
Definition formatter.hpp:45
Global namespace for all Astarte related functionality.
Definition data.hpp:29
Ownership definitions for communication with Astarte.
auto format(const astarte::device::StoredProperty &prop, FormatContext &ctx) const
Formats the StoredProperty object.
Definition stored_property.hpp:117
constexpr auto parse(ParseContext &ctx) const
Parses the format string.
Definition stored_property.hpp:105
Base formatter struct declaration for Doxygen.
Definition formatter.hpp:48