Search through config for schema of specified flatbuffer type
Allow user to call function that returns a schema reflection in
the config for flatbuffer type instead of having to find a
matching schema manually.
Signed-off-by: Nathan Leong <100028864@mvla.net>
Change-Id: I40e836e8f379ac48f32633d49d8c01a1530697df
Signed-off-by: Nathan Leong <100028864@mvla.net>
diff --git a/aos/configuration.h b/aos/configuration.h
index 8515b18..4d84b23 100644
--- a/aos/configuration.h
+++ b/aos/configuration.h
@@ -212,7 +212,20 @@
// Returns the number of scratch buffers in the queue.
int QueueScratchBufferSize(const Channel *channel);
-// TODO(austin): GetSchema<T>(const Flatbuffer<Configuration> &config);
+// Searches through configurations for schemas that include a certain type.
+const reflection::Schema *GetSchema(const Configuration *config,
+ std::string_view schema_type);
+
+// GetSchema template
+template <typename T>
+const reflection::Schema *GetSchema(const Configuration *config) {
+ return GetSchema(config, T::GetFullyQualifiedName());
+}
+
+// Copy schema reflection into detached flatbuffer
+std::optional<FlatbufferDetachedBuffer<reflection::Schema>>
+GetSchemaDetachedBuffer(const Configuration *config,
+ std::string_view schema_type);
} // namespace configuration
@@ -222,6 +235,7 @@
const FlatbufferDetachedBuffer<Channel> &rhs);
bool operator==(const FlatbufferDetachedBuffer<Channel> &lhs,
const FlatbufferDetachedBuffer<Channel> &rhs);
+
} // namespace aos
#endif // AOS_CONFIGURATION_H_