|
SVCS - English Documentation
|
Abstract base class representing any storable, addressable object within the VCS. More...
#include <VcsObject.hxx>
Public Member Functions | |
| VcsObject ()=default | |
| Default constructor. Required for derived classes. | |
| VcsObject (const VcsObject &other)=default | |
| Copy constructor. Required for derived classes to correctly copy the hash_id. | |
| virtual | ~VcsObject ()=default |
| Virtual destructor. | |
| virtual std::string | serialize () const =0 |
| Pure virtual method to serialize the object's core data. | |
| virtual std::string | getType () const =0 |
| Pure virtual method to get the type of the VCS object. | |
| std::string | getHashId () const |
| Returns the unique hash identifier of the object. | |
Static Public Member Functions | |
| static std::string | calculateHash (const std::string &content) |
| Calculates SHA-256 hash for given canonical content. | |
Protected Member Functions | |
| void | computeHash (const std::string &content) |
| Computes the cryptographic hash ID for the object's content. | |
Protected Attributes | |
| std::string | hash_id |
| The unique cryptographic hash identifier (e.g., SHA-256) for this object. | |
Abstract base class representing any storable, addressable object within the VCS.
VcsObject enforces the mandatory presence of a hash ID, serialization logic, and type identification for all derived classes. It serves as the core domain entity for the object database.
|
default |
Copy constructor. Required for derived classes to correctly copy the hash_id.
| other | The VcsObject to copy from. |
|
virtualdefault |
Virtual destructor.
Ensures proper cleanup when deleting derived objects via a base class pointer.
|
static |
Calculates SHA-256 hash for given canonical content.
| content | Git-format object content (header + raw_data). |
|
protected |
Computes the cryptographic hash ID for the object's content.
This method should prepend the object's type and content length (Git-style) before hashing the full content and setting the internal hash_id.
| content | The serialized string data of the object (usually returned by serialize()). |
|
nodiscard |
Returns the unique hash identifier of the object.
|
nodiscardpure virtual |
Pure virtual method to get the type of the VCS object.
This is crucial for object storage and reconstruction (e.g., "commit", "blob", "tree").
Implemented in svcs::core::Blob, svcs::core::Commit, svcs::core::TestableObject, and svcs::core::Tree.
|
nodiscardpure virtual |
Pure virtual method to serialize the object's core data.
The returned string content is what will be hashed and stored in the database.
Implemented in svcs::core::Blob, svcs::core::Commit, svcs::core::TestableObject, and svcs::core::Tree.
|
protected |
The unique cryptographic hash identifier (e.g., SHA-256) for this object.
Protected to allow internal setting via computeHash() but prevent external modification.