My Project
Loading...
Searching...
No Matches
System.hpp
1#pragma once
2
3#include <vector>
4#include <memory>
5#include <atomic>
6#include <thread>
7#include <chrono>
8#include "message/MessageProcessor.hpp"
9#include "control/IMessageHandler.hpp"
10#include "control/HandlerDispatcher.hpp"
11#include "algorithm/AlgorithmScanner.hpp"
12#include "algorithm/AlgorithmRunner.hpp"
13
14class System {
15private:
16 MessageProcessor messageProcessor;
17 HandlerDispatcher dispatcher;
18 AlgorithmScanner algorithmScanner;
19 AlgorithmRunner algorithmRunner;
20
21 std::vector<std::unique_ptr<IMessageHandler>> handlers;
22 std::atomic<bool> running;
23
24public:
25 System(int port);
26 ~System();
27
31 void start();
32
37 bool acceptConnection();
38
42 void stop();
43
48 void registerHandler(std::unique_ptr<IMessageHandler> handler);
49
56 bool sendMessage(const std::string& payload, MessageType type);
57
65 bool sendMessage(const std::string& messageId, const std::string& payload, MessageType type);
66
71 bool isRunning() const;
72
77 bool isClientConnected() const;
78
82 void printStats() const;
83
90 void handleCompleteMessage(const std::string& messageId, const std::string& payload, MessageType type);
91
92 // Component access methods
98
104};
Definition AlgorithmRunner.hpp:12
Definition AlgorithmScanner.hpp:11
Definition HandlerDispatcher.hpp:11
Definition MessageProcessor.hpp:18
Definition System.hpp:14
AlgorithmRunner & getAlgorithmRunner()
Gets the algorithm runner.
Definition System.cpp:116
void start()
Starts the system.
Definition System.cpp:13
void registerHandler(std::unique_ptr< IMessageHandler > handler)
Registers a message handler.
Definition System.cpp:52
AlgorithmScanner & getAlgorithmScanner()
Gets the algorithm scanner.
Definition System.cpp:112
void printStats() const
Gets system statistics.
Definition System.cpp:99
bool isClientConnected() const
Checks if client is connected.
Definition System.cpp:95
bool acceptConnection()
Try to accept a client connection.
Definition System.cpp:48
void stop()
Stops the system.
Definition System.cpp:27
bool isRunning() const
Checks if system is running.
Definition System.cpp:91
bool sendMessage(const std::string &payload, MessageType type)
Sends a message to the client.
Definition System.cpp:66
void handleCompleteMessage(const std::string &messageId, const std::string &payload, MessageType type)
Handles a complete message from MessageProcessor.
Definition System.cpp:108