IRSOL
C++ code implementing socket server for interacting with Baumer camera.
irsol::server::handlers::AssignmentInputSequenceLengthHandler Class Reference

Handler for assignment of the input sequence length parameter isl. More...

#include <assignment_input_sequence_length.hpp>

Inheritance diagram for irsol::server::handlers::AssignmentInputSequenceLengthHandler:
irsol::server::handlers::internal::HandlerBase< T, >

Public Member Functions

 AssignmentInputSequenceLengthHandler (std::shared_ptr< Context > ctx)
 Constructs the AssignmentInputSequenceLengthHandler.
 
- Public Member Functions inherited from irsol::server::handlers::internal::HandlerBase< T, >
virtual std::vector< out_message_toperator() (const irsol::types::client_id_t &clientId, T &&message)
 Invokes the handler for a given client and message.
 

Protected Member Functions

std::vector< out_message_tprocess (std::shared_ptr< irsol::server::ClientSession > session, protocol::Assignment &&message) final override
 Processes an assignment message to set the input sequence length.
 
- Protected Member Functions inherited from irsol::server::handlers::internal::HandlerBase< T, >
 HandlerBase (std::shared_ptr< Context > ctx)
 Constructs the handler base.
 
virtual std::vector< out_message_tprocess (std::shared_ptr< irsol::server::ClientSession > session, T &&message)=0
 Processes the protocol message for the given session.
 

Additional Inherited Members

- Protected Attributes inherited from irsol::server::handlers::internal::HandlerBase< T, >
std::shared_ptr< Contextctx
 Handler context (provides access to app and utilities).
 

Detailed Description

Handler for assignment of the input sequence length parameter isl.

Processes assignment messages to set the number of frames to collect in a client session during the isl irsol::protocol::Command.

Definition at line 25 of file assignment_input_sequence_length.hpp.

Constructor & Destructor Documentation

◆ AssignmentInputSequenceLengthHandler()

irsol::server::handlers::AssignmentInputSequenceLengthHandler::AssignmentInputSequenceLengthHandler ( std::shared_ptr< Context ctx)

Constructs the AssignmentInputSequenceLengthHandler.

Parameters
ctxHandler context.

Definition at line 9 of file assignment_input_sequence_length.cpp.

12{}
std::shared_ptr< Context > ctx
Handler context (provides access to app and utilities).
Definition base.hpp:81
internal::HandlerBase< protocol::Assignment > AssignmentHandler
Handler type for assignment messages.
Definition base.hpp:88

Member Function Documentation

◆ process()

std::vector< out_message_t > irsol::server::handlers::AssignmentInputSequenceLengthHandler::process ( std::shared_ptr< irsol::server::ClientSession session,
protocol::Assignment &&  message 
)
finaloverrideprotected

Processes an assignment message to set the input sequence length.

Parameters
sessionThe client session.
messageThe assignment message.
Returns
Vector of outbound messages (success or error).

Definition at line 15 of file assignment_input_sequence_length.cpp.

18{
19 auto& frameListeningState = session->userData().frameListeningState;
20 if(frameListeningState.running()) {
22 session->id(), "Session is already listening to frames. Cannot set a inputSequenceLength.");
23 std::vector<out_message_t> result;
25 message, "Session is already listening to frames. Cannot set a inputSequenceLength."));
26 return result;
27 }
28 const int inputSequenceLength = irsol::utils::toInt(message.value);
29 if(inputSequenceLength <= 0) {
31 session->id(), "inputSequenceLength ({}) must be positive.", inputSequenceLength);
32 std::vector<out_message_t> result;
33 result.emplace_back(
34 irsol::protocol::Error::from(message, "InputSequenceLength must be positive."));
35 return result;
36 }
37 IRSOL_NAMED_LOG_INFO(session->id(), "Setting 'inputSequenceLength' to {}", inputSequenceLength);
38
39 frameListeningState.gisParams.inputSequenceLength = static_cast<uint64_t>(inputSequenceLength);
40 std::vector<out_message_t> result;
42 return result;
43}
#define IRSOL_NAMED_LOG_INFO(name,...)
Logs an info-level message using a named logger.
Definition logging.hpp:176
#define IRSOL_NAMED_LOG_WARN(name,...)
Logs a warning-level message using a named logger.
Definition logging.hpp:178
constexpr auto makeHandler(std::shared_ptr< Context > ctx, Args &&... args)
Constructs a handler instance of the given type.
Definition factory.hpp:28
int toInt(const irsol::types::protocol_value_t &x)
Converts a protocol value to an integer.
Definition utils.hpp:39
static Error from(const T &msg, const std::string &description)
Creates an error from a specific incoming message type.
Definition error.hpp:63
static Success from(const Assignment &msg, std::optional< irsol::types::protocol_value_t > overrideValue=std::nullopt)
Creates a success message from an Assignment.
Definition success.hpp:75
auto result

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