|
SVCS - English Documentation
|
Manages the version control object database, including persistence and object restoration. More...
#include <ObjectStorage.hxx>
Public Member Functions | |
| ObjectStorage (const std::string &root_path, const std::shared_ptr< ISubject > &subject=nullptr) | |
| Constructor for ObjectStorage. | |
| virtual | ~ObjectStorage () |
| Destructor. | |
| void | setSubject (std::shared_ptr< ISubject > subj) |
| Sets or replaces the event subject used by the ObjectStorage. | |
| std::string | getObjectPath (const std::string &hash) const |
| Forms the full filesystem path for an object based on its hash. | |
| virtual bool | saveObject (const VcsObject &obj) const |
| Saves a VcsObject to the object database. | |
| virtual std::unique_ptr< VcsObject > | loadObject (const std::string &hash) const |
| Loads an object from the disk by its hash ID. | |
| bool | objectExists (const std::string &hash) const |
| Checks if an object with the given hash exists on disk. | |
Manages the version control object database, including persistence and object restoration.
Implements low-level file system operations (path generation, reading, writing), compression, decompression, and object deserialization.
|
explicit |
Constructor for ObjectStorage.
| root_path | The root path of the repository (e.g., the directory containing ".svcs"). |
| subject | Shared pointer to the ISubject interface for event logging. Defaults to nullptr if logging is not required yet. |
|
nodiscard |
Forms the full filesystem path for an object based on its hash.
Uses the first two characters of the hash for the subdirectory name and the remaining 38 characters for the filename.
| hash | The full 40-character SHA-1 hash ID. |
|
nodiscardvirtual |
Loads an object from the disk by its hash ID.
Reads the compressed file, decompresses it, performs integrity checks, and deserializes the object using the internal factory method.
| hash | The hash ID of the object to load. |
| std::runtime_error | if the object is not found, corrupted, or invalid. |
Reimplemented in svcs::test::core::MockObjectStorage.
|
nodiscard |
Checks if an object with the given hash exists on disk.
| hash | The hash ID to check. |
|
nodiscardvirtual |
Saves a VcsObject to the object database.
Serializes the object, prefixes it with a header, compresses it, and writes it to a file. Publishes events on success/failure.
| obj | The VcsObject to save. |
| std::runtime_error | if hash is invalid or file IO fails. |
Reimplemented in svcs::test::core::MockObjectStorage.
|
inline |
Sets or replaces the event subject used by the ObjectStorage.
| subj | The new ISubject pointer to use for publishing events. |