Manages the version control directory structure and core operations.
More...
#include <Repository.hxx>
|
| | ~Repository () override |
| | Virtual destructor.
|
| | Repository (std::filesystem::path rpath) |
| | Constructs the repository manager.
|
| void | initializeDependencies () |
| | Initializes the repository's internal dependencies.
|
| bool | init () |
| | Initializes the basic repository structure (.svcs, objects, refs) on the disk.
|
| bool | is_initialized () const |
| | Checks if the repository structure is fully initialized and valid.
|
| const std::filesystem::path & | getPath () const |
| | Gets the root path of the repository.
|
| ObjectStorage * | getObjectStorage () const |
| | Gets the raw pointer to the managed ObjectStorage instance for database interaction.
|
| void | attach (std::shared_ptr< IObserver > observer) override |
| | Attaches an observer to receive events.
|
| void | detach (std::shared_ptr< IObserver > observer) override |
| | Detaches a registered observer.
|
| void | notify (const Event &event) const override |
| | Notifies all attached observers about an event.
|
| bool | stageFile (const std::string &path) |
| | Stages a file by hashing its content, storing it in the object database, and updating the staging index.
|
| virtual | ~ISubject ()=default |
| | Virtual destructor.
|
|
| static std::shared_ptr< Repository > | findRepository (const std::string &start_path=".") |
| | Statically searches for an existing repository starting from a given path and moving up.
|
| static bool | isRepository (const std::string &path) |
| | Statically checks if a given path is the root of an SVCS repository.
|
|
|
std::vector< IObserver * > | observers |
| | Collection of registered observers.
|
Manages the version control directory structure and core operations.
Implements ISubject to serve as an event publisher for the core VCS operations.
◆ ~Repository()
| svcs::core::Repository::~Repository |
( |
| ) |
|
|
override |
Virtual destructor.
Ensures correct cleanup of managed resources (ObjectStorage).
◆ Repository()
| svcs::core::Repository::Repository |
( |
std::filesystem::path | rpath | ) |
|
|
explicit |
Constructs the repository manager.
- Parameters
-
| rpath | The root directory of the repository. |
◆ attach()
| void svcs::core::Repository::attach |
( |
std::shared_ptr< IObserver > | observer | ) |
|
|
overridevirtual |
Attaches an observer to receive events.
- Parameters
-
| observer | Shared pointer to the observer instance. |
Implements svcs::services::ISubject.
◆ detach()
| void svcs::core::Repository::detach |
( |
std::shared_ptr< IObserver > | observer | ) |
|
|
overridevirtual |
Detaches a registered observer.
- Parameters
-
| observer | Shared pointer to the observer instance to detach. |
Implements svcs::services::ISubject.
◆ findRepository()
| std::shared_ptr< Repository > svcs::core::Repository::findRepository |
( |
const std::string & | start_path = "." | ) |
|
|
static |
Statically searches for an existing repository starting from a given path and moving up.
- Parameters
-
| start_path | The directory path to begin the search from (defaults to "."). |
- Returns
- A shared pointer to the found Repository instance, or nullptr if none is found.
◆ getObjectStorage()
| ObjectStorage * svcs::core::Repository::getObjectStorage |
( |
| ) |
const |
|
inlinenodiscard |
Gets the raw pointer to the managed ObjectStorage instance for database interaction.
- Returns
- ObjectStorage* Pointer to the managed ObjectStorage instance.
◆ getPath()
| const std::filesystem::path & svcs::core::Repository::getPath |
( |
| ) |
const |
|
inlinenodiscard |
Gets the root path of the repository.
- Returns
- const std::filesystem::path& The repository root path.
◆ init()
| bool svcs::core::Repository::init |
( |
| ) |
|
Initializes the basic repository structure (.svcs, objects, refs) on the disk.
- Returns
- bool True if initialization succeeded, false otherwise.
◆ initializeDependencies()
| void svcs::core::Repository::initializeDependencies |
( |
| ) |
|
Initializes the repository's internal dependencies.
This typically involves instantiating and setting up internal components like ObjectStorage.
◆ is_initialized()
| bool svcs::core::Repository::is_initialized |
( |
| ) |
const |
|
nodiscard |
Checks if the repository structure is fully initialized and valid.
- Returns
- true if all necessary directories and files exist.
◆ isRepository()
| bool svcs::core::Repository::isRepository |
( |
const std::string & | path | ) |
|
|
static |
Statically checks if a given path is the root of an SVCS repository.
- Parameters
-
- Returns
- true if the path contains the required repository marker files/directories.
◆ notify()
| void svcs::core::Repository::notify |
( |
const Event & | event | ) |
const |
|
overridevirtual |
Notifies all attached observers about an event.
- Parameters
-
| event | The constant reference to the event data structure. |
Implements svcs::services::ISubject.
◆ stageFile()
| bool svcs::core::Repository::stageFile |
( |
const std::string & | path | ) |
|
Stages a file by hashing its content, storing it in the object database, and updating the staging index.
- Parameters
-
| path | The path to the file to be staged (relative to the repository root). |
- Returns
- bool True if the file was successfully staged, false otherwise (e.g., file ignored, permission error).
- Exceptions
-
| std::runtime_error | if file system or object storage operations fail. |
The documentation for this class was generated from the following files: