SVCS - English Documentation
Loading...
Searching...
No Matches
RemoteProtocol.hxx
Go to the documentation of this file.
1
19#pragma once
20
23
24#include <string>
25#include <vector>
26#include <unordered_set>
27#include <memory>
28#include <iostream>
29
46 */
47namespace svcs::server {
48
49using namespace svcs::core;
50using namespace svcs::services;
51
67class RemoteProtocol {
68public:
80 RemoteProtocol(std::shared_ptr<ISubject> event_bus,
81 std::shared_ptr<RepositoryManager> repository_manager);
82
90 ~RemoteProtocol() = default;
91
107 bool handleReceivePack();
108
124 bool handleUploadPack();
125
126private:
127 // Receive-pack (Push) Protocol Methods
137 bool processPushNegotiation();
138
150 bool receiveObjects(const std::unordered_set<std::string>& wanted_objects);
151
163 bool updateReferences(const std::vector<std::pair<std::string, std::string>>& ref_updates);
164
165 // Upload-pack (Pull) Protocol Methods
175 bool processPullNegotiation();
176
188 std::unordered_set<std::string> findMissingObjects(const std::unordered_set<std::string>& client_has);
189
201 bool sendObjects(const std::unordered_set<std::string>& objects_to_send);
202
203 // Object and Reference Management Methods
215 bool objectExists(const std::string& object_hash) const;
216
228 std::string readObject(const std::string& object_hash) const;
229
243 bool writeObject(const std::string& object_hash, const std::string& object_data);
244
254 std::unordered_set<std::string> getAllReferences() const;
255
269 bool updateReference(const std::string& ref_name, const std::string& new_hash);
270
271 // Protocol Communication Methods
285 bool readLine(std::string& line) const;
286
300 bool sendLine(const std::string& line) const;
301
313 bool sendData(const std::string& data) const;
314
326 bool sendError(const std::string& error) const;
327
328 // Validation Methods
340 bool isValidObjectHash(const std::string& hash) const;
341
353 bool isValidReference(const std::string& ref_name) const;
354
355 // Notification Methods
365 void notifyDebug(const std::string& message) const;
366
376 void notifyInfo(const std::string& message) const;
377
387 void notifyError(const std::string& message) const;
388
398 void notifyProtocolStart(const std::string& message) const;
399
409 void notifyProtocolSuccess(const std::string& message) const;
410
420 void notifyProtocolError(const std::string& message) const;
421
431 void notifyNetworkSend(const std::string& message) const;
432
442 void notifyNetworkReceive(const std::string& message) const;
443
453 void notifyObjectTransfer(const std::string& message) const;
454
464 void notifyReferenceUpdate(const std::string& message) const;
465
475 void notifyNegotiation(const std::string& message) const;
476
490 bool sendProtocolError(const std::string& error) const;
491
492private:
500 std::shared_ptr<ISubject> event_bus_;
501
509 std::shared_ptr<RepositoryManager> repository_manager_;
510};
511
512}
Defines the interface for the Subject (Publisher) component of the Observer pattern.
Declaration of the RepositoryManager class, managing all repository-level file operations.
RemoteProtocol(std::shared_ptr< ISubject > event_bus, std::shared_ptr< RepositoryManager > repository_manager)
Constructs a RemoteProtocol with necessary dependencies.
Definition RemoteProtocol.cxx:23
~RemoteProtocol()=default
Default destructor.
bool handleUploadPack()
Handles the 'upload-pack' protocol for pull operations.
Definition RemoteProtocol.cxx:42
bool handleReceivePack()
Handles the 'receive-pack' protocol for push operations.
Definition RemoteProtocol.cxx:30
Core VCS data structures and object model.
Server-side components and administration commands.
Service layer components and infrastructure services.