SVCS - English Documentation
Loading...
Searching...
No Matches
VcsObject.hxx
Go to the documentation of this file.
1
17#pragma once
18
19#include <string>
20
33 */
34namespace svcs::core {
35
51class VcsObject {
52protected:
62 std::string hash_id;
77 void computeHash(const std::string& content);
79public:
87 VcsObject() = default;
88
98 VcsObject(const VcsObject& other) = default;
99
103
109 virtual ~VcsObject() = default;
110
113 * @brief Pure virtual method to serialize the object's core data.
114 * @details The returned string content is what will be hashed and stored in the database.
115 * @return std::string The standardized, serialized data of the object.
116 *
117 * @russian
118 * @brief Чисто виртуальный метод для сериализации основных данных объекта.
119 * @details Возвращаемое строковое содержимое будет хешировано и сохранено в базе данных.
120 * @return std::string Стандартизированные, сериализованные данные объекта.
121 */
122 [[nodiscard]] virtual std::string serialize() const = 0;
123
135 [[nodiscard]] virtual std::string getType() const = 0;
136
148 static std::string calculateHash(const std::string& content);
149
150
159 [[nodiscard]] std::string getHashId() const;
160};
161
162
178class TestableObject : public VcsObject {
179private:
187 std::string type_name;
188
196 std::string content_data;
197
198public:
210 TestableObject(std::string type, std::string data);
211
220 [[nodiscard]] std::string serialize() const override;
221
230 [[nodiscard]] std::string getType() const override;
231};
232
233}
Helper class for testing the non-abstract methods of VcsObject.
Definition VcsObject.hxx:113
std::string serialize() const override
Implementation of the pure virtual method. Returns the stored content.
Definition VcsObject.cxx:58
std::string getType() const override
Implementation of the pure virtual method. Returns the stored type name.
Definition VcsObject.cxx:62
TestableObject(std::string type, std::string data)
Primary constructor.
Definition VcsObject.cxx:53
Abstract base class representing any storable, addressable object within the VCS.
Definition VcsObject.hxx:33
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.
Definition VcsObject.cxx:34
virtual std::string serialize() const =0
Pure virtual method to serialize the object's core data.
void computeHash(const std::string &content)
Computes the cryptographic hash ID for the object's content.
Definition VcsObject.cxx:20
VcsObject()=default
Default constructor. Required for derived classes.
virtual ~VcsObject()=default
Virtual destructor.
static std::string calculateHash(const std::string &content)
Calculates SHA-256 hash for given canonical content.
Definition VcsObject.cxx:38
std::string hash_id
The unique cryptographic hash identifier (e.g., SHA-256) for this object.
Definition VcsObject.hxx:40
Core VCS data structures and object model.