mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Change wording in the MessageReference bitsery ext
I had to reread the docstrings to remember what `deseerialization_store` was, so it probably needed a better name.
This commit is contained in:
@@ -29,9 +29,9 @@ namespace ext {
|
|||||||
* An adapter for serializing zero-copy references to objects using
|
* An adapter for serializing zero-copy references to objects using
|
||||||
* `MessageHandler<T>`. The idea is that when serializing, we just read data
|
* `MessageHandler<T>`. The idea is that when serializing, we just read data
|
||||||
* from the object pointed at by the reference. Then when deserializing, we'll
|
* from the object pointed at by the reference. Then when deserializing, we'll
|
||||||
* write the data to some `std::option<T>` (so we don't have to initialize an
|
* write the data to some backing `std::option<T>` (so we don't have to
|
||||||
* unused object on the serializing side), and we'll then change our reference
|
* initialize an unused object on the serializing side), and we'll then change
|
||||||
* to point to the value contained within that option.
|
* our reference to point to the value contained within that option.
|
||||||
*
|
*
|
||||||
* This lets us serialize 'references' to objects that can be backed by actual
|
* This lets us serialize 'references' to objects that can be backed by actual
|
||||||
* persistent objects. That way we can avoid allocations during the processing
|
* persistent objects. That way we can avoid allocations during the processing
|
||||||
@@ -41,12 +41,12 @@ template <typename T>
|
|||||||
class MessageReference {
|
class MessageReference {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @param deseerialization_store The object we'll deserialize into, so we
|
* @param backing_object The object we'll deserialize into, so we can point
|
||||||
* can point the `MessageReference<T>` to this object. On the serializing
|
* the `MessageReference<T>` to this object. On the serializing side this
|
||||||
* side this won't be touched.
|
* won't be touched.
|
||||||
*/
|
*/
|
||||||
MessageReference(std::optional<T>& deseerialization_store)
|
MessageReference(std::optional<T>& backing_object)
|
||||||
: deseerialization_store(deseerialization_store){};
|
: backing_object(backing_object){};
|
||||||
|
|
||||||
template <typename Ser, typename Fnc>
|
template <typename Ser, typename Fnc>
|
||||||
void serialize(Ser& ser,
|
void serialize(Ser& ser,
|
||||||
@@ -57,23 +57,23 @@ class MessageReference {
|
|||||||
|
|
||||||
template <typename Des, typename Fnc>
|
template <typename Des, typename Fnc>
|
||||||
void deserialize(Des& des, ::MessageReference<T>& object_ref, Fnc&&) const {
|
void deserialize(Des& des, ::MessageReference<T>& object_ref, Fnc&&) const {
|
||||||
if (!deseerialization_store) {
|
if (!backing_object) {
|
||||||
deseerialization_store.emplace();
|
backing_object.emplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since we cannot directly deserialize into a reference, we'll
|
// Since we cannot directly deserialize into a reference, we'll
|
||||||
// deserialize into this (persistent) backing object and then point the
|
// deserialize into this (persistent) backing object and then point the
|
||||||
// reference to this object.
|
// reference to this object.
|
||||||
des.object(*deseerialization_store);
|
des.object(*backing_object);
|
||||||
object_ref = *deseerialization_store;
|
object_ref = *backing_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The actual `T` we'll deserialize into so we can point the reference to
|
* This contains the actual `T` we'll deserialize into so we can point the
|
||||||
* that object after deserializing.
|
* reference to that object after deserializing.
|
||||||
*/
|
*/
|
||||||
std::optional<T>& deseerialization_store;
|
std::optional<T>& backing_object;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ext
|
} // namespace ext
|
||||||
|
|||||||
Reference in New Issue
Block a user