vg
tools for working with variation graphs
|
#include <registry.hpp>
Classes | |
struct | Tables |
Static Public Member Functions | |
static bool | register_everything () |
template<typename Message > | |
static void | register_protobuf (const string &tag) |
template<typename Handled , typename... Bases> | |
static void | register_loader_saver (const string &tag, load_function_t loader, save_function_t saver) |
template<typename Handled , typename... Bases> | |
static void | register_loader_saver (const std::vector< std::string > &tags, load_function_t loader, save_function_t saver) |
template<typename Handled , typename... Bases> | |
static void | register_bare_loader_saver (const string &tag, bare_load_function_t loader, bare_save_function_t saver) |
template<typename Handled , typename... Bases> | |
static void | register_bare_loader_saver_with_magic (const string &tag, const string &magic, bare_load_function_t loader, bare_save_function_t saver) |
template<typename Handled , typename... Bases> | |
static void | register_bare_loader_saver_with_magics (const string &tag, const vector< string > &magics, bare_load_function_t loader, bare_save_function_t saver) |
template<typename Handled , typename... Bases> | |
static void | register_loader (const string &tag, load_function_t loader) |
template<typename Handled , typename... Bases> | |
static void | register_loader (const std::vector< std::string > &tags, load_function_t loader) |
static bool | is_valid_tag (const string &tag) |
template<typename Message > | |
static const string & | get_protobuf_tag () |
template<typename Message > | |
static bool | check_protobuf_tag (const string &tag) |
template<typename Want > | |
static const load_function_t * | find_loader (const string &tag) |
template<typename Want > | |
static const vector< pair< bare_load_function_t, string > > * | find_bare_loaders () |
template<typename Have > | |
static const pair< string, save_function_t > * | find_saver () |
Static Public Attributes | |
static const size_t | MAX_TAG_LENGTH = 25 |
Static Private Member Functions | |
static Tables & | get_tables () |
::google::protobuf::util::TypeResolver & | get_resolver () |
template<typename Handled , typename... Bases> | |
static void | register_bare_loader (bare_load_function_t loader, const string &prefix="") |
template<typename Handled > | |
static void | register_saver (const string &tag, save_function_t saver) |
A registry mapping between tag strings for serialized message groups and the Protobuf types or serialization/deserialization handlers to use for them. All registration anmd lookup is done through static methods. Static methods are safe to call from other static initialization code.
We handle two kinds of registration right now:
|
static |
Check to see if the given tag is expected when deserializing Protobuf messages of the given tag.
|
static |
Look up the appropriate loader functions to use to load an object of the given type from a bare stream. If there are any registered, return a pointer to a vector of functions and their possibly empty stream prefixes that they require. The caller has to call the appropriate function and and cast the result to the right type. If there are no functions available, returns nullptr.
|
static |
Look up the appropriate loader function to use to load an object of the given type from data with the given tag. If there is one registered, return a pointer to it. The caller has to call it and cast the result to the right type. If there isn't, returns nullptr.
|
static |
Look up the appropriate saver function to use to save an object of the given type. If there is one registered, return a pointer to a pair of the tag to use and the function. The caller has to call it and cast the result to the right type. If there isn't, returns nullptr.
|
static |
Get the correct tag to use when serializing Protobuf messages of the given type.
|
staticprivate |
Get a single shared Protobuf resolver we will use for the duration of the program. The Protobuf docs say the resolver must be thread safe.
|
staticprivate |
Get or create the registry tables in which things are registerd.
|
static |
Determine if the given tag string loaded from a file is a valid/possible tag, or if it should be interpreted as message data from a pre-tags VG file instead. Only tag values literally registered with the registry are valid. NOT thread-safe to run simultaneously with tag registrations.
|
staticprivate |
Register a load function for loading the given types from non-type-tagged-message "bare" streams witht he given possibly empty prefix, which is retained in the stream data.
|
static |
Register a loading function and a saving function with the given tag for the given object type and list of base classes. The functions operate on bare streams; conversion to type-tagged messages of chunks of stream data is performed automatically. The load function will also be registered to load from non-type-tagged-message-format files, when trying to load the actual handled type, for backward compatibility.
|
static |
Like register_bare_loader_saver(), except that additionally the function will be used when attempting to load any of the base classes when the file begins with the specified magic bytes.
|
static |
Like register_bare_loader_saver(), except that additionally the function will be used when attempting to load any of the base classes when the file begins with any of the the specified magic byte sequences.
|
static |
Register everything. Main entry point. When you have new things to register, add calls to your function to this method. Returns true on success.
|
static |
Register a loading function for the given collection of tags. If "" appears in the list of tags, the loader can be deployed on untagged message groups (for backward compatibility).
|
static |
Register a load function for a tag. The empty tag means it can run on untagged message groups. If any Bases are passed, we will use this loader to load when one of those types is requested and this tag is encountered.
|
static |
Register a loading function and a saving function with the given collection of tags for the given object type and list of base classes. The first tag in the collection will be used for saving. If "" appears in the list of tags, the loader can be deployed on untagged message groups (for backward compatibility).
|
static |
Register a loading function and a saving function with the given tag for the given object type and the given base classes.
|
static |
Register a Protobuf Message type to be associated with the given string tag. By default, Protobuf types use the name string from the Protobuf library as a tag. But this can and should be overridden with something short that will never change.
|
staticprivate |
Register a save function to save a type with a given tag. The empty tag is not permitted.
|
static |
To help with telling messages from tags, we enforce a max tag length. If we ever allow tags of 139 bytes or longer, we risk having uncompressed files starting with the gzip magic number.