|
|
| ModelArchive (const ModelArchive &)=delete |
| | ModelArchive (const std::string &filepath, std::unique_ptr< ArchiveSerializer > serializer, OpenMode mode) |
| | Construct archive with serializer and automatically open for specified mode.
|
|
| ModelArchive (ModelArchive &&other) noexcept |
|
| ~ModelArchive () |
| | Destructor automatically closes the serializer.
|
| void | addMetadata (const std::string &key, const std::string &value) |
| | Add simple metadata key-value pair.
|
|
void | close () |
|
const std::string & | getFilepath () const noexcept |
|
size_t | getFileSize (const std::string &path) const |
| std::string | getMetadata (const std::string &key) const |
| | Retrieve simple metadata value.
|
|
OpenMode | getMode () const noexcept |
|
bool | hasFile (const std::string &path) const |
|
bool | isClosed () const noexcept |
|
std::vector< std::string > | listFiles () const |
|
ModelArchive & | operator= (const ModelArchive &)=delete |
|
ModelArchive & | operator= (ModelArchive &&other) noexcept |
|
void | popScope () |
|
void | pushScope (const std::string &scope) |
| std::vector< uint8_t > | readBlob (const std::string &path) const |
| | Read raw binary blob from archive into returned vector.
|
| size_t | readBlobInto (const std::string &path, void *buffer, size_t buffer_size) const |
| | Read binary blob directly into provided buffer.
|
| SerializationMetadata | readMetadata (const std::string &path) const |
| | Read type-safe metadata from the archive.
|
| void | writeBlob (const std::string &path, const void *data, size_t size) |
| | Write raw binary blob to archive.
|
|
void | writeMetadata (const std::string &path, const SerializationMetadata &metadata) |
ModelArchive provides high-level helpers for component serialization.
Responsibilities:
- Coordinate ModelSerializer lifecycle (open/close)
- Write/read type-safe metadata (abstracts JSON implementation)
- Write/read arbitrary binary blobs
- Enforce OpenMode for type-safe operations
Metadata Abstraction:
- User code interacts with SerializationMetadata (type-safe, format-agnostic)
- ModelArchive handles conversion to/from JSON internally
- Future format changes (XML, binary, etc.) won't break user code
A simple scoping API (pushScope/popScope / ScopedScope) allows callers to set a logical directory prefix used by subsequent read/write operations.
- Examples
- /home/runner/work/Mila/Mila/Mila/Src/Dnn/Core/ComponentFactory.ixx, and /home/runner/work/Mila/Mila/Mila/Src/Dnn/Core/NetworkFactory.ixx.