Batch

class Batch : public Remote::Message::OutgoingMessage, public std::enable_shared_from_this<Batch>

model to modify and transmit Remote::Command and Remote::Report objects in a Batch

Public Functions

~Batch() override

clearing the map of DataPoints

void addPoint(std::shared_ptr<Object::DataPoint> point)

Adds a DataPoint to the Batch while ensuring compatibility and preventing duplicates.

This method checks if the provided DataPoint meets specific criteria for type and station compatibility before adding it to the Batch. It also ensures that the DataPoint is not already present in the Batch.

Parameters:

point – A shared pointer to the DataPoint object to be added. Only monitoring points are allowed, and the type and station must be consistent with those already in the Batch.

Throws:

std::invalid_argument – if the point is not a monitoring point, if it lacks a station reference, if it is already in the Batch, or if its type or station is incompatible with the Batch.

bool hasPoints() const

Test if DataPoints exists at this NetworkStation.

Returns:

information on availability of child DataPoint objects

std::uint_fast8_t getNumberOfObjects() const

Get the number of information objects inside this message.

Returns:

count

Object::DataPointVector getPoints() const

Get a list of all DataPoints.

Returns:

vector with object pointer

virtual bool isSequence() const override

Checks if the keys of DataPoints in the Batch are sequential.

Determines if the keys of the stored DataPoints form a continuous, ordered sequence without gaps, skipping expired entries.

Returns:

True if the keys are sequential or if the collection is empty, otherwise false.

std::string toString() const

Converts the Batch object to a string representation.

Generates a string that provides detailed information about the Batch object, including its common address, type, cause of transmission, number of objects, and various status flags such as test, negative, and sequence. Also includes the memory location of the object.

Returns:

A string representation of the Batch object.

Public Static Functions

static inline std::shared_ptr<Batch> create(const CS101_CauseOfTransmission cause, const std::optional<Object::DataPointVector> &points = std::nullopt)

Creates a new Batch object with a specified cause of transmission and optional data points.

This method dynamically allocates memory for a Batch object using its private constructor. It ensures proper initialization of the Batch instance with the provided parameters.

Parameters:
  • cause – The cause of transmission associated with the new Batch.

  • points – An optional collection of DataPoints to be added to the Batch during creation. If provided, the points are processed and verified for compatibility with the Batch. Defaults to std::nullopt, indicating no initial points.

Throws:

std::invalid_argument – if a point in points is not a monitoring point, if it lacks a station reference, if it is already in the Batch, or if its type or station is incompatible with the Batch.

Returns:

A shared pointer to the newly created Batch object.