Sen API
Sen Libraries
Loading...
Searching...
No Matches
snapshot.h
Go to the documentation of this file.
1// === snapshot.h ======================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_DB_SNAPSHOT_H
9#define SEN_DB_SNAPSHOT_H
10
11#include "sen/core/meta/type.h"
12#include "sen/core/obj/object.h"
13
14namespace sen::db
15{
16
17class Input;
18
21class Snapshot
22{
23 SEN_COPY_MOVE(Snapshot)
24
25public:
26 ~Snapshot() = default;
27
28public:
30 [[nodiscard]] ObjectId getObjectId() const noexcept;
31
33 [[nodiscard]] const std::string& getName() const noexcept;
34
36 [[nodiscard]] const std::string& getSessionName() const noexcept;
37
39 [[nodiscard]] const std::string& getBusName() const noexcept;
40
42 [[nodiscard]] const ConstTypeHandle<ClassType>& getType() const noexcept { return type_; }
43
44public:
46 [[nodiscard]] const Var& getPropertyAsVariant(const Property* property) const;
47
49 [[nodiscard]] Span<const uint8_t> getPropertyAsBuffer(const Property* property) const;
50
52 [[nodiscard]] Span<const uint8_t> getAllPropertiesBuffer() const noexcept;
53
54private:
55 friend class Input;
56 Snapshot(ObjectId objectId,
57 std::string objectName,
58 std::string sessionName,
59 std::string busName,
60 ConstTypeHandle<ClassType> type,
61 std::vector<uint8_t> buffer);
62
63private:
64 void extractBuffersIfNeeded() const;
65
66private:
67 ObjectId objectId_;
68 std::string objectName_;
69 std::string sessionName_;
70 std::string busName_;
71 ConstTypeHandle<ClassType> type_;
72 std::vector<uint8_t> buffer_;
73 mutable bool buffersExtracted_ = false;
74 mutable std::unordered_map<const Property*, Var> varCache_;
75 mutable std::unordered_map<MemberHash, Span<const uint8_t>> bufferCache_;
76};
77
78} // namespace sen::db
79
80#endif // SEN_DB_SNAPSHOT_H
Represents a property.
Definition property.h:79
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition span.h:34
Allows you to access an existing recording in the file system.
Definition input.h:63
Span< const uint8_t > getPropertyAsBuffer(const Property *property) const
Get the value of a property as a serialized buffer.
const std::string & getSessionName() const noexcept
The session where the object was published.
const ConstTypeHandle< ClassType > & getType() const noexcept
The class of the object.
Definition snapshot.h:42
~Snapshot()=default
ObjectId getObjectId() const noexcept
The ID of the object.
Span< const uint8_t > getAllPropertiesBuffer() const noexcept
Get the buffer containing all the serialized properties.
const std::string & getName() const noexcept
The name of the object.
friend class Input
Definition snapshot.h:55
const std::string & getBusName() const noexcept
The bus where the object was published.
const Var & getPropertyAsVariant(const Property *property) const
Get the value of a property as a variant.
TypeHandle< const T > ConstTypeHandle
Definition type.h:319
Definition annotation.h:20
STL namespace.
The hash of a member.
Definition type.h:39
Can hold any supported value type. Wraps std::variant to allow recursion and implements some helpers.
Definition var.h:119