From 8bc624a08055cca2e4e2ce0919d17f5c5fd07286 Mon Sep 17 00:00:00 2001 From: Quinten Mennen Date: Thu, 18 Sep 2025 17:33:33 +0200 Subject: [PATCH] Update class diagram: refine Server, Client, and ServerConfig classes, and add LocationConfig details --- docs/ClassDiagram.mmd | 120 ++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 45 deletions(-) diff --git a/docs/ClassDiagram.mmd b/docs/ClassDiagram.mmd index cdf92c1..5827246 100644 --- a/docs/ClassDiagram.mmd +++ b/docs/ClassDiagram.mmd @@ -2,65 +2,95 @@ classDiagram direction TB class Server { - +run() - +handle_new_connection(int) - +handle_client_event(int, int) - +setup_listeners() - +add_to_epoll(int) - +remove_from_epoll(int) - +std::vector> listeners_ - +std::unordered_map> clients_ - +int epoll_fd_ - +const Configuration* config_ + +Server(const ConfigManager&) + +~Server() + +start() + +addToEpoll(Socket&, uint32_t) + +removeFromEpoll(Socket&) + +setupServerSocket(ServerConfig&) + +handleConnection(epoll_event*) + +handleRequest(epoll_event*) + +responseReady(int) + +eventLoop() + +getListener(int) Socket& + +getClient(int) Client& + +getConfig(int) ServerConfig& + +getConfig(Socket&) ServerConfig& + -int epoll_fd_ + -ConfigManager& configManager_ + -vector> listeners_ + -unordered_map fdToConfig_ + -unordered_map> clients_ } class Socket { - +Socket(int) +Socket() + +Socket(int) +~Socket() - +bind(const sockaddr_in&) int - +listen(int) int - +accept() Socket + +listen(int) void + +bind(string, int) void + +accept() Socket* +recv(void*, size_t) ssize_t +send(const void*, size_t) ssize_t - +set_non_blocking() - -fd_ int + +setNonBlocking() void + +getFd() int + -int _fd } class Client { - +Client(unique_ptr) - +~Client() - +process_event(int) - +handle_read() - +handle_write() - +is_complete() bool - +unique_ptr socket_ - +unique_ptr request_ - +unique_ptr response_ - +const Server& server_ + +Client(unique_ptr, Server&, ServerConfig&) + +~Client()std::move(clientSocket), *this, getConfig(listener) + +request() void + +getResponse() string + -unique_ptr client_socket_ + -Server& server + -ServerConfig& server_config } - class HTTP_Request { - +parse_data(const std::string&) - +is_complete() bool - -method_ string - -uri_ string - -headers_ map + class ConfigManager { + +init(string) + +getInstance() ConfigManager& + +getServerConfigs() vector + -bool _initialized + -vector serverConfigs } - class HTTP_Response { - +build_from_request(const HTTP_Request&) - +to_string() string - -status_ int - -body_ string - -headers_ map + class ServerConfig { + +ServerConfig(string) + +getHost() string + +getPort() int + +getRoot() string + +getCgiPass() string + +getCgiExt() string + +getErrorPages() map + +getIndexFiles() vector + +getLocation(string) LocationConfig& + +getLocationPaths() vector + +setServerFD(int) + +getServerFD() int + -string host + -int port + -int server_fd + -string root + -string cgi_pass + -string cgi_ext + -map error_page + -vector index_files + -map locations } + class LocationConfig { + +LocationConfig(string) + -string path + -bool autoIndex + -string indexFile + -map directives + } - Server "1" o-- "1..*" Socket: listens on - Server "1" o-- "0..*" Client: manages - Server "1" -- "1" Configuration: knows about - Client "1" *-- "1" Socket: owns - Client "1" *-- "1" HTTP_Request: owns - Client "1" *-- "1" HTTP_Response: owns - Client "1" -- "1" Server: reports to \ No newline at end of file + Server "1" o-- "1..*" Socket : listens on + Server "1" o-- "0..*" Client : manages + Server "1" -- "1" ConfigManager : uses + Client "1" *-- "1" Socket : owns + Client "1" -- "1" Server : references + Client "1" -- "1" ServerConfig : references + ServerConfig "1" o-- "*" LocationConfig : has \ No newline at end of file