|
Cade Royal CSCE 412 Project 3
|
A class to represent a network request. More...
#include <Request.h>
Public Member Functions | |
| Request (const std::string &ip, const std::string &randomStr, int randomInt, std::mutex &coutMutex) | |
| Constructor to initialize a Request. | |
| ~Request () | |
| Destructor to clean up resources. | |
| Request (const Request &other) | |
| Copy constructor to create a copy of a Request object. | |
| Request & | operator= (const Request &other) |
| Copy assignment operator to assign a Request object. | |
| Request (Request &&other) noexcept=default | |
| Move constructor to transfer ownership of a Request object. | |
| Request & | operator= (Request &&other) noexcept=default |
| Move assignment operator to transfer ownership of a Request object. | |
| void | send () const |
| Simulate sending the request. | |
| void | printDetails () const |
| Print the details of the request to the console. | |
| int | getSeconds () |
| Get the processing time for the request in seconds. | |
Friends | |
| class | Queue |
| Grant access to private members for demonstration purposes. | |
A class to represent a network request.
The Request class holds data such as the originating IP address, a random string, and a random integer. It provides methods to send the request, print details, and access the request's processing time in seconds.
| Request::Request | ( | const std::string & | ip, |
| const std::string & | randomStr, | ||
| int | randomInt, | ||
| std::mutex & | coutMutex | ||
| ) |
Constructor to initialize a Request.
Constructs a Request object.
| ip | The IP address of the request origin. |
| randomStr | A random string associated with the request. |
| randomInt | A randomly generated integer. |
| coutMutex | A mutex to protect console output. |
This constructor initializes a new Request object with an IP address, a random string, a random integer, and a mutex for thread-safe printing.
| ip | The IP address for the request. |
| randomStr | A random string associated with the request. |
| randomInt | A random integer associated with the request. |
| coutMutex | A reference to the mutex for managing console output safely. |
| Request::~Request | ( | ) |
| Request::Request | ( | const Request & | other | ) |
|
defaultnoexcept |
| int Request::getSeconds | ( | ) |
Get the processing time for the request in seconds.
Returns the random integer associated with the request.
Copy assignment operator to assign a Request object.
Copy assignment operator for Request.
| other | The Request object to assign. |
Assigns the contents of another Request object to this Request object.
| other | The Request object to copy. |
| void Request::printDetails | ( | ) | const |
Print the details of the request to the console.
Prints the details of the request.
This function outputs the IP address, random string, and random integer to the console.
Outputs the IP address, random string, random integer, and associated data to the console in a thread-safe manner.
| void Request::send | ( | ) | const |
Simulate sending the request.
Sends the request.
This method simulates the sending of the request.
This function sends the request. It currently simulates the sending of the request by printing the request details to the console (though commented out).
|
friend |