|
Mila 0.13.48
Deep Neural Network Library
|
ModelArchive provides high-level helpers for component serialization. More...
Classes | |
| class | ScopedScope |
Public Member Functions | |
| 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 |
| 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) |
Private Member Functions | |
| std::string | currentPrefix () const |
| bool | isAbsolutePath (const std::string &path) const noexcept |
| void | requireMode (OpenMode expected, const char *op) const |
| void | requireOpen (const char *op) const |
| std::string | scopedPath (const std::string &path) const |
Private Attributes | |
| bool | closed_ { false } |
| std::string | filepath_ |
| OpenMode | mode_ |
| std::vector< std::string > | scope_stack_ |
| std::unique_ptr< ArchiveSerializer > | serializer_ |
Static Private Attributes | |
| static const std::vector< std::string > | kAbsoluteRoots = { "network/", "components/", "modules/" } |
ModelArchive provides high-level helpers for component serialization.
Responsibilities:
Metadata Abstraction:
A simple scoping API (pushScope/popScope / ScopedScope) allows callers to set a logical directory prefix used by subsequent read/write operations.
|
inlineexplicit |
Construct archive with serializer and automatically open for specified mode.
The serializer is automatically opened for reading or writing based on the specified mode. Throws if the serializer cannot be opened.
| filepath | Path to the archive file |
| serializer | Owned serializer instance (typically ZipSerializer) |
| mode | Read or Write mode for the archive |
| std::invalid_argument | if serializer is null |
| std::runtime_error | if serializer cannot be opened in the specified mode |

|
inline |
Destructor automatically closes the serializer.

|
delete |

|
inlinenoexcept |

|
inline |
Add simple metadata key-value pair.
For simple string metadata (archive-level tags, format markers, etc.). Use writeMetadata() for structured component metadata.

|
inline |

|
inlineprivate |

|
inlinenoexcept |

|
inline |

|
inline |
Retrieve simple metadata value.
For simple string metadata (archive-level tags, format markers, etc.). Use readMetadata() for structured component metadata.
|
inlinenoexcept |
|
inline |

|
inlineprivatenoexcept |

|
inlinenoexcept |
|
inline |

|
delete |

|
inlinenoexcept |

|
inline |
|
inline |
|
inline |
Read raw binary blob from archive into returned vector.
| path | Archive path for binary data |
| std::runtime_error | if archive is not in Read mode |
| std::runtime_error | if file missing or read fails |

|
inline |
Read binary blob directly into provided buffer.
| path | Archive path |
| buffer | Pre-allocated buffer |
| buffer_size | Size of buffer |
| std::runtime_error | if file missing or buffer too small |


|
inline |


|
inlineprivate |


|
inlineprivate |

|
inlineprivate |


|
inline |
Write raw binary blob to archive.
| path | Archive path for binary data |
| data | Pointer to source bytes |
| size | Number of bytes to write |
| std::runtime_error | if archive is not in Write mode |
| std::runtime_error | on write failure |


|
inline |


|
private |
|
private |
|
inlinestaticprivate |
|
private |
|
private |
|
private |