Cade Royal CSCE 412 Project 3
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
Request Class Reference

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.
 
Requestoperator= (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.
 
Requestoperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Request() [1/3]

Request::Request ( const std::string &  ip,
const std::string &  randomStr,
int  randomInt,
std::mutex &  coutMutex 
)

Constructor to initialize a Request.

Constructs a Request object.

Parameters
ipThe IP address of the request origin.
randomStrA random string associated with the request.
randomIntA randomly generated integer.
coutMutexA 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.

Parameters
ipThe IP address for the request.
randomStrA random string associated with the request.
randomIntA random integer associated with the request.
coutMutexA reference to the mutex for managing console output safely.

◆ ~Request()

Request::~Request ( )

Destructor to clean up resources.

Destructor for the Request object.

Ensures proper cleanup of resources when a Request object is destroyed.

◆ Request() [2/3]

Request::Request ( const Request other)

Copy constructor to create a copy of a Request object.

Copy constructor for Request.

Parameters
otherThe Request object to copy.

This constructor initializes a new Request object as a copy of another Request object.

Parameters
otherThe Request object to copy.

◆ Request() [3/3]

Request::Request ( Request &&  other)
defaultnoexcept

Move constructor to transfer ownership of a Request object.

Parameters
otherThe Request object to move.

Member Function Documentation

◆ getSeconds()

int Request::getSeconds ( )

Get the processing time for the request in seconds.

Returns the random integer associated with the request.

Returns
The processing time as an integer.
The random integer.

◆ operator=() [1/2]

Request & Request::operator= ( const Request other)

Copy assignment operator to assign a Request object.

Copy assignment operator for Request.

Parameters
otherThe Request object to assign.
Returns
A reference to the assigned Request object.

Assigns the contents of another Request object to this Request object.

Parameters
otherThe Request object to copy.
Returns
A reference to this Request object.

◆ operator=() [2/2]

Request & Request::operator= ( Request &&  other)
defaultnoexcept

Move assignment operator to transfer ownership of a Request object.

Parameters
otherThe Request object to move.
Returns
A reference to the moved Request object.

◆ printDetails()

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.

◆ send()

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).

Friends And Related Symbol Documentation

◆ Queue

friend class Queue
friend

Grant access to private members for demonstration purposes.

Allows the Queue class to access the private members of Request.


The documentation for this class was generated from the following files: