IRSOL
C++ code implementing socket server for interacting with Baumer camera.
irsol::server::handlers::internal::AssignmentImgHandlerBase< AssignmentCameraImageAttribute > Class Template Reference

Base handler template for assigning a camera image region parameter. More...

#include <assignment_image_size.hpp>

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

Public Member Functions

 AssignmentImgHandlerBase (std::shared_ptr< Context > ctx)
 Constructs the handler.
 
- 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 (IRSOL_MAYBE_UNUSED std::shared_ptr< irsol::server::ClientSession > session, protocol::Assignment &&message) final override
 Processes an assignment message to set the camera image parameter.
 
- 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.
 

Static Private Attributes

static constexpr std::string_view name = AssignmentCameraImageAttribute::name
 

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

template<typename AssignmentCameraImageAttribute>
class irsol::server::handlers::internal::AssignmentImgHandlerBase< AssignmentCameraImageAttribute >

Base handler template for assigning a camera image region parameter.

Template Parameters
AssignmentCameraImageAttributeTag type specifying the parameter name.

Handles assignment messages to set a specific camera image region parameter.

Definition at line 64 of file assignment_image_size.hpp.

Constructor & Destructor Documentation

◆ AssignmentImgHandlerBase()

Constructs the handler.

Parameters
ctxHandler context.

Definition at line 73 of file assignment_image_size.hpp.

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

Processes an assignment message to set the camera image parameter.

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

Definition at line 82 of file assignment_image_size.hpp.

85 {
86 auto& cam = ctx->app.camera();
87 auto resValue = cam.setParam(std::string(name), irsol::utils::toInt(message.value));
88 std::vector<out_message_t> result;
89
90 // Update the message value with the resulting value after setting the camera parameter.
91 // In this way, the resulting value is included in the response message that we broadcast to all
92 // clients.
94 ctx->broadcastMessage(protocol::Success::from(message));
95 return {};
96 }
constexpr auto makeHandler(std::shared_ptr< Context > ctx, Args &&... args)
Constructs a handler instance of the given type.
Definition factory.hpp:28
std::variant< int, double, std::string > protocol_value_t
Variant type representing protocol values that can be one of several types.
Definition types.hpp:150
int toInt(const irsol::types::protocol_value_t &x)
Converts a protocol value to an integer.
Definition utils.hpp:39
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

Member Data Documentation

◆ name

constexpr std::string_view irsol::server::handlers::internal::AssignmentImgHandlerBase< AssignmentCameraImageAttribute >::name = AssignmentCameraImageAttribute::name
staticconstexprprivate

Definition at line 66 of file assignment_image_size.hpp.


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