laserkestrel / starmap

Other
0 stars 0 forks source link

Message system #6

Open laserkestrel opened 8 months ago

laserkestrel commented 8 months ago

To encapsulate the communication and star exploration system within C++ classes, you can create several classes to represent the various components of the system. Here's an example of how you can structure the classes:

Message Class: This class represents the messages used for communication between probes. It should include information about the explored star, the timestamp, and any other relevant data.

class Message {
public:
    Message(Star star, double timestamp); // Constructor
private:
    Star exploredStar;
    double timestamp;
    // Other message-specific properties
};

CommunicationManager Class: This class manages the communication system, including message propagation and timing.

class CommunicationManager {
public:
    void propagateMessage(Message message, double propagationSpeed);
    // Other communication-related methods
private:
    // Internal data structures and methods for message propagation
};

You can then use these classes to create instances of probes, stars, and the communication manager in your simulation. The Probe class handles star exploration, message broadcasting, and message handling. The Star class represents the stars to be explored, and the Message class encapsulates the information exchanged between probes. The CommunicationManager class manages the propagation of messages with a given speed.

This object-oriented approach helps organize and encapsulate the various components of your simulation, making it easier to manage and maintain your code as it becomes more complex.

laserkestrel commented 8 months ago

Message Queue for Probes: For the message queue of each probe, consider using a deque (double-ended queue) or a circular buffer. Deques provide fast insertion and removal at both ends, which is useful for managing incoming and outgoing messages efficiently.

std::deque<Message> messageQueue;