67 const std::filesystem::path root_path;
76 std::unique_ptr<ObjectStorage> objects;
87 std::vector<std::weak_ptr<IObserver>> observers;
96 std::unique_ptr<Index> index;
119 explicit Repository(std::filesystem::path rpath);
163 [[nodiscard]]
const std::filesystem::path&
getPath()
const {
return root_path; }
185 void attach(std::shared_ptr<IObserver> observer)
override;
196 void detach(std::shared_ptr<IObserver> observer)
override;
207 void notify(
const Event& event)
const override;
220 static std::shared_ptr<Repository>
findRepository(
const std::string& start_path =
".");
Defines the interface for the Subject (Publisher) component of the Observer pattern.
Definition of IndexEntry data structure and Index struct.
Manages the reading, writing, and lifecycle of VCS objects on the disk using the Git format.
Manages the version control object database, including persistence and object restoration.
Definition ObjectStorage.hxx:40
~Repository() override
Virtual destructor.
Definition Repository.cxx:28
void detach(std::shared_ptr< IObserver > observer) override
Detaches a registered observer.
Definition Repository.cxx:142
const std::filesystem::path & getPath() const
Gets the root path of the repository.
Definition Repository.hxx:108
ObjectStorage * getObjectStorage() const
Gets the raw pointer to the managed ObjectStorage instance for database interaction.
Definition Repository.hxx:115
void notify(const Event &event) const override
Notifies all attached observers about an event.
Definition Repository.cxx:154
void initializeDependencies()
Initializes the repository's internal dependencies.
Definition Repository.cxx:40
Repository(std::filesystem::path rpath)
Constructs the repository manager.
Definition Repository.cxx:33
bool stageFile(const std::string &path)
Stages a file by hashing its content, storing it in the object database, and updating the staging ind...
Definition Repository.cxx:210
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.
Definition Repository.cxx:167
bool is_initialized() const
Checks if the repository structure is fully initialized and valid.
Definition Repository.cxx:117
void attach(std::shared_ptr< IObserver > observer) override
Attaches an observer to receive events.
Definition Repository.cxx:131
bool init()
Initializes the basic repository structure (.svcs, objects, refs) on the disk.
Definition Repository.cxx:46
static bool isRepository(const std::string &path)
Statically checks if a given path is the root of an SVCS repository.
Definition Repository.cxx:195
The Subject (Publisher) Interface (Abstract Base Class).
Definition ISubject.hxx:38
Core VCS data structures and object model.