OOFEM 3.0
Loading...
Searching...
No Matches
GCodeCommand Class Reference

The GCodeCommand class represents a single G-code command. More...

#include <GCodeCommand.h>

Public Member Functions

 GCodeCommand ()=default
 Default constructor for the GCodeCommand class.
 GCodeCommand (const std::string &cmd)
 Constructor for the GCodeCommand class.
void addParameter (char letter, const std::string &value)
 Method to add a parameter to the G-code command.
void setCode (const std::string code)
 Set the G-code command.
std::string getCode () const
 Get the G-code command.
std::map< char, std::string > getParameters () const
 Get the parameters associated with the G-code command.
std::optional< std::string > param_string (char paramLetter) const
 Get the value of a parameter as a string.
std::optional< int > param_int (char paramLetter) const
 Get the value of a parameter as an integer.
std::optional< double > param_double (char paramLetter) const
 Get the value of a parameter as a double.

Private Attributes

std::string code
std::map< char, std::string > parameters

Detailed Description

The GCodeCommand class represents a single G-code command.

Definition at line 15 of file GCodeCommand.h.

Constructor & Destructor Documentation

◆ GCodeCommand() [1/2]

GCodeCommand::GCodeCommand ( )
default

Default constructor for the GCodeCommand class.

◆ GCodeCommand() [2/2]

GCodeCommand::GCodeCommand ( const std::string & cmd)
inline

Constructor for the GCodeCommand class.

Parameters
cmdThe G-code command.

Definition at line 27 of file GCodeCommand.h.

References code.

Member Function Documentation

◆ addParameter()

void GCodeCommand::addParameter ( char letter,
const std::string & value )
inline

Method to add a parameter to the G-code command.

Parameters
letterThe parameter letter.
valueThe parameter value.

Definition at line 34 of file GCodeCommand.h.

References parameters.

Referenced by GCodeParser::parseLine().

◆ getCode()

std::string GCodeCommand::getCode ( ) const
inline

Get the G-code command.

Returns
The G-code command.

Definition at line 49 of file GCodeCommand.h.

References code.

Referenced by Printer::processCommand().

◆ getParameters()

std::map< char, std::string > GCodeCommand::getParameters ( ) const
inline

Get the parameters associated with the G-code command.

Returns
The parameters as a map of parameter letter to parameter value.

Definition at line 55 of file GCodeCommand.h.

References parameters.

◆ param_double()

std::optional< double > GCodeCommand::param_double ( char paramLetter) const
inline

Get the value of a parameter as a double.

Parameters
paramLetterThe parameter letter.
Returns
The parameter value as a double, or std::nullopt if the parameter is not found or the conversion fails.

Definition at line 99 of file GCodeCommand.h.

References param_string().

Referenced by Printer::handleG1Command().

◆ param_int()

std::optional< int > GCodeCommand::param_int ( char paramLetter) const
inline

Get the value of a parameter as an integer.

Parameters
paramLetterThe parameter letter.
Returns
The parameter value as an integer, or std::nullopt if the parameter is not found or the conversion fails.

Definition at line 77 of file GCodeCommand.h.

References param_string().

◆ param_string()

std::optional< std::string > GCodeCommand::param_string ( char paramLetter) const
inline

Get the value of a parameter as a string.

Parameters
paramLetterThe parameter letter.
Returns
The parameter value as a string, or std::nullopt if the parameter is not found.

Definition at line 62 of file GCodeCommand.h.

References parameters.

Referenced by param_double(), and param_int().

◆ setCode()

void GCodeCommand::setCode ( const std::string code)
inline

Set the G-code command.

Parameters
codeThe G-code command.

Definition at line 43 of file GCodeCommand.h.

References code.

Referenced by GCodeParser::parseLine().

Member Data Documentation

◆ code

std::string GCodeCommand::code
private

Definition at line 117 of file GCodeCommand.h.

Referenced by GCodeCommand(), getCode(), and setCode().

◆ parameters

std::map<char, std::string> GCodeCommand::parameters
private

Definition at line 118 of file GCodeCommand.h.

Referenced by addParameter(), getParameters(), and param_string().


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011