Class MetadataEntry
Defined in File metadata.h
Inheritance Relationships
Derived Types
public ouster::sdk::osf::MetadataEntryHelper< CollationStreamMeta >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryHelper< Extrinsics >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryHelper< LidarScanStreamMeta >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryHelper< LidarSensor >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryHelper< SensorInfoStreamMeta >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryHelper< StreamingInfo >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryHelper< DerivedMetadataEntry >(Template Class MetadataEntryHelper)public ouster::sdk::osf::MetadataEntryRef(Class MetadataEntryRef)
Class Documentation
-
class MetadataEntry
Base abstract metadata entry type for every metadata that can be stored as OSF metadata.
Metadata object that is stored/serialized to OSF is a triplet:
{id, type, buffer}id- is a unique identifier per OSF file and used for references from other metadata objects or from messages (chunk.StampedMessage.id in chunk.fbs) to link messages with the streams.type- string that is unique per OSF generation (i.e. v2) and used to link datum buffer representation to the concrete metadata object.Type is specified when concrete metadata type class defined via MetadataTraits struct specialization, example:
template <> struct MetadataTraits<MyMeta> { static const std::string type() { return "ouster/v1/something/MyMeta"; } };
buffer- byte representation of the metadata content whatever it is defined by concrete metadata type. Every metadata object should have a recipe how to serialize itself to the bytes buffer by overwriting the buffer() function. And the recipe how to recover itserf by providing static from_buffer(buf, type) function.Subclassed by ouster::sdk::osf::MetadataEntryHelper< CollationStreamMeta >, ouster::sdk::osf::MetadataEntryHelper< Extrinsics >, ouster::sdk::osf::MetadataEntryHelper< LidarScanStreamMeta >, ouster::sdk::osf::MetadataEntryHelper< LidarSensor >, ouster::sdk::osf::MetadataEntryHelper< SensorInfoStreamMeta >, ouster::sdk::osf::MetadataEntryHelper< StreamingInfo >, ouster::sdk::osf::MetadataEntryHelper< DerivedMetadataEntry >, ouster::sdk::osf::MetadataEntryRef
Public Types
-
using from_buffer_func = std::unique_ptr<MetadataEntry> (*)(const OsfBuffer buf)
Function type to recover metadata object from buffer.
Public Functions
-
virtual std::string type() const = 0
- Returns:
Type of the metadata, used to identify the object type in serialized OSF and as key in deserialization registry
-
virtual std::string static_type() const = 0
- Returns:
Same as type with the difference that type() can be dynamic and static_type() should always be defined in compile time. NOTE: Introduced as a convenience/(HACK?) to simpler reconstruct and cast dynamic objects from MetadataEntryRef
-
virtual std::unique_ptr<MetadataEntry> clone() const = 0
Should be provided by derived class and is used in handling polymorphic objects and avoid object slicing.
- Returns:
Should return a clone of the current MetadataEntry
-
virtual std::vector<uint8_t> buffer() const = 0
Byte represantation of the internal derived metadata type, used as serialization function when saving to OSF file.
- Returns:
The byte vector representation of the metadata.
-
virtual std::string repr() const
String representation of the internal metadata object, used in to_string() for debug/info outputs.
- Returns:
The string representation for the internal metadata object.
-
virtual std::string to_string() const
String representation of the whole metadata entry with type and id.
- Returns:
The string representation of the whole metadata entry.
-
void set_id(uint32_t id)
Unique id used inside the flatbuffer metadata store to refer to metadata entries.
- Parameters:
id[in] – The unique id to set.
- inline OUSTER_DIAGNOSTIC_PUSH OUSTER_DIAGNOSTIC_IGNORE_UNUSED void setId (uint32_t id)
- Deprecated:
Use set_id() instead.
- Parameters:
id[in] – Deprecated.
-
template<typename T>
inline std::unique_ptr<T> as() const Casting of the base class to concrete derived metadata entry type.
Always creates new object with allocation via clone() if the pointer/ref is a polymorphic object, or as reconstruction from buffer() representation when it used from MetadataEntryRef (i.e. wrapper on underlying bytes)
- Template Parameters:
T – The derived metadata type
- Returns:
A unique pointer to the derived metadata object, nullptr on error.
-
virtual ~MetadataEntry() = default
Public Static Functions
-
static std::unique_ptr<MetadataEntry> from_buffer(const OsfBuffer buf, const std::string type_str)
Recover metadata object from the bytes representation if possible.
If recovery is not possible returns nullptr
- Parameters:
buf[in] – The buffer to recover the metadata object from.
type_str[in] – The type string from the derived type.
- Returns:
A new object of the derived type cast as a MetadataEntry
-
static std::map<std::string, from_buffer_func> &get_registry()
Method to return the registry that holds from_buffer function by type string and is used during deserialization.
The registry is a static variable defined within the get_registry method.
- Returns:
The static registry used to register metadata types.
- OUSTER_DIAGNOSTIC_POP uint32_t id () const
Unique id used inside the flatbuffer metadata store to refer to metadata entries.
- Returns:
The unique id of this object.
-
using from_buffer_func = std::unique_ptr<MetadataEntry> (*)(const OsfBuffer buf)