Skip to content

Commit

Permalink
Miscellaneous cleanup of Events API (#297)
Browse files Browse the repository at this point in the history
* Remove `const` primitve values
* Remove const from SetX functions

Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Feb 16, 2022
1 parent 7bb95dc commit ce7cb4a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions events/include/ignition/common/Event.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace ignition

/// \brief Set whether this event has been signaled.
/// \param[in] _sig True if the event has been signaled.
public: void SetSignaled(const bool _sig);
public: void SetSignaled(bool _sig);

/// \brief True if the event has been signaled.
private: bool signaled;
Expand All @@ -65,7 +65,7 @@ namespace ignition
/// \brief Constructor.
/// \param[in] _e Event pointer to connect with.
/// \param[in] _i Unique id.
public: Connection(Event *_e, const int _i);
public: Connection(Event *_e, int _i);

/// \brief Destructor.
public: ~Connection();
Expand Down Expand Up @@ -156,7 +156,7 @@ namespace ignition
private: class EventConnection
{
/// \brief Constructor
public: EventConnection(const bool _on, const std::function<T> &_cb,
public: EventConnection(bool _on, const std::function<T> &_cb,
const ConnectionPtr &_publicConn)
: callback(_cb), publicConnection(_publicConn)
{
Expand Down
10 changes: 5 additions & 5 deletions events/include/ignition/common/KeyEvent.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ namespace ignition

/// \brief Set the event type
/// \param[in] _type Event type
public: void SetType(const EventType _type);
public: void SetType(EventType _type);

/// \brief Get the key number
/// \return The key number
public: int Key() const;

/// \brief Set the key
/// \param[in] _key The key number
public: void SetKey(const int _key);
public: void SetKey(int _key);

/// \brief Get the formatted string of the key pressed (could be
/// uppercase).
Expand All @@ -82,23 +82,23 @@ namespace ignition

/// \brief Set whether the control key was held during this key event
/// \param[in] _control Status of the control key
public: void SetControl(const bool _control);
public: void SetControl(bool _control);

/// \brief Get whether the shift key was held during this key event
/// \return True if the shift key was pressed
public: bool Shift() const;

/// \brief Set whether the shift key was held during this key event
/// \param[in] _shift Status of the shift key
public: void SetShift(const bool _shift);
public: void SetShift(bool _shift);

/// \brief Get whether the alt key was held during this key event
/// \return True if the alt key was pressed
public: bool Alt() const;

/// \brief Set whether the alt key was held during this key event
/// \param[in] _alt Status of the alt key
public: void SetAlt(const bool _alt);
public: void SetAlt(bool _alt);

/// \brief Assignment operator
/// \param[in] _other Other key event
Expand Down
24 changes: 12 additions & 12 deletions events/include/ignition/common/MouseEvent.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace ignition
/// \brief Set mouse pointer position on the screen.
/// \param[in] _x Mouse pointer X position on the screen.
/// \param[in] _y Mouse pointer Y position on the screen.
public: void SetPos(const int _x, const int _y);
public: void SetPos(int _x, int _y);

/// \brief Get the previous position.
/// \return The previous mouse position.
Expand All @@ -103,7 +103,7 @@ namespace ignition
/// \brief Set the previous position.
/// \param[in] _x Previous mouse pointer X position on the screen.
/// \param[in] _y Previous mouse pointer Y position on the screen.
public: void SetPrevPos(const int _x, const int _y);
public: void SetPrevPos(int _x, int _y);

/// \brief Get the position of button press.
/// \return Screen position of a button press.
Expand All @@ -116,7 +116,7 @@ namespace ignition
/// \brief Set the position of button press.
/// \param[in] _x Mouse pointer X position on the screen.
/// \param[in] _y Mouse pointer Y position on the screen.
public: void SetPressPos(const int _x, const int _y);
public: void SetPressPos(int _x, int _y);

/// \brief Get the scroll position.
/// \return The scroll position.
Expand All @@ -129,15 +129,15 @@ namespace ignition
/// \brief Set the scroll position.
/// \param[in] _x Scroll X position.
/// \param[in] _y Scroll Y position.
public: void SetScroll(const int _x, const int _y);
public: void SetScroll(int _x, int _y);

/// \brief Get the scaling factor.
/// \return The move scaling factor.
public: float MoveScale() const;

/// \brief Set the scaling factor.
/// \param[in] _scale The move scaling factor.
public: void SetMoveScale(const float _scale);
public: void SetMoveScale(float _scale);

/// \brief Get the flag for mouse drag motion
/// \return True if dragging, usually indicating a mouse move with
Expand All @@ -146,23 +146,23 @@ namespace ignition

/// \brief Set the flag for mouse drag motion
/// \param[in] _dragging The dragging flag.
public: void SetDragging(const bool _dragging);
public: void SetDragging(bool _dragging);

/// \brief Get the event type.
/// \return The EventType.
public: EventType Type() const;

/// \brief Set the event type.
/// \param[in] _type The EventType.
public: void SetType(const EventType _type) const;
public: void SetType(MouseEvent::EventType _type);

/// \brief Get the button which caused this event.
/// \return The button which caused this event.
public: MouseEvent::MouseButton Button() const;

/// \brief Set the button which caused the event.
/// \param[in] _button The button which caused this event.
public: void SetButton(const MouseEvent::MouseButton _button) const;
public: void SetButton(MouseEvent::MouseButton _button);

/// \brief Get the state of the buttons when the event was generated.
/// \return The state of the buttons, which can be a bitwise
Expand All @@ -172,31 +172,31 @@ namespace ignition
/// \brief Set the state of the buttons when the event was generated.
/// \param[in] _buttons The state of the buttons, which can be a bitwise
/// combination of MouseEvent::MouseButton.
public: void SetButtons(const unsigned int &_buttons);
public: void SetButtons(unsigned int _buttons);

/// \brief Get the shift key press flag.
/// \return True if the shift key is pressed.
public: bool Shift() const;

/// \brief Set the shift key press flag.
/// \param[in] _shift The shift key press flag.
public: void SetShift(const bool _shift) const;
public: void SetShift(bool _shift);

/// \brief Get the alt key press flag.
/// \return True if the alt key is pressed.
public: bool Alt() const;

/// \brief Set the alt key press flag.
/// \param[in] _alt The alt key flag.
public: void SetAlt(const bool _alt);
public: void SetAlt(bool _alt);

/// \brief Get the control key press flag.
/// \return True if the control key is pressed.
public: bool Control() const;

/// \brief Set the control key press flag.
/// \param[in] _control The control key flag.
public: void SetControl(const bool _control) const;
public: void SetControl(bool _control);

/// \brief Assignment operator
/// \param[in] _other Other mouse event
Expand Down
4 changes: 2 additions & 2 deletions events/src/Event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ bool Event::Signaled() const
}

//////////////////////////////////////////////////
void Event::SetSignaled(const bool _sig)
void Event::SetSignaled(bool _sig)
{
this->signaled = _sig;
}

//////////////////////////////////////////////////
Connection::Connection(Event *_e, const int _i)
Connection::Connection(Event *_e, int _i)
: event(_e), id(_i)
{
this->creationTime = IGN_SYSTEM_TIME();
Expand Down
12 changes: 6 additions & 6 deletions events/src/KeyEvent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ignition::common::KeyEventPrivate
public: KeyEvent::EventType type = KeyEvent::NO_EVENT;

/// \brief The raw value of the key pressed.
public: int key = 0;
public: int key = 0;

/// \brief Formatted string of the key pressed (could be uppercase).
public: std::string text = "";
Expand Down Expand Up @@ -72,7 +72,7 @@ KeyEvent::EventType KeyEvent::Type() const
}

/////////////////////////////////////////////////
void KeyEvent::SetType(const KeyEvent::EventType _type)
void KeyEvent::SetType(KeyEvent::EventType _type)
{
this->dataPtr->type = _type;
}
Expand All @@ -84,7 +84,7 @@ int KeyEvent::Key() const
}

/////////////////////////////////////////////////
void KeyEvent::SetKey(const int _key)
void KeyEvent::SetKey(int _key)
{
this->dataPtr->key = _key;
}
Expand All @@ -108,7 +108,7 @@ bool KeyEvent::Control() const
}

/////////////////////////////////////////////////
void KeyEvent::SetControl(const bool _control)
void KeyEvent::SetControl(bool _control)
{
this->dataPtr->control = _control;
}
Expand All @@ -120,7 +120,7 @@ bool KeyEvent::Shift() const
}

/////////////////////////////////////////////////
void KeyEvent::SetShift(const bool _shift)
void KeyEvent::SetShift(bool _shift)
{
this->dataPtr->shift = _shift;
}
Expand All @@ -132,7 +132,7 @@ bool KeyEvent::Alt() const
}

/////////////////////////////////////////////////
void KeyEvent::SetAlt(const bool _alt)
void KeyEvent::SetAlt(bool _alt)
{
this->dataPtr->alt = _alt;
}
Expand Down
24 changes: 12 additions & 12 deletions events/src/MouseEvent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void MouseEvent::SetPos(const ignition::math::Vector2i &_pos)
}

/////////////////////////////////////////////////
void MouseEvent::SetPos(const int _x, const int _y)
void MouseEvent::SetPos(int _x, int _y)
{
this->dataPtr->pos.Set(_x, _y);
}
Expand All @@ -118,7 +118,7 @@ void MouseEvent::SetPrevPos(const ignition::math::Vector2i &_pos)
}

/////////////////////////////////////////////////
void MouseEvent::SetPrevPos(const int _x, const int _y)
void MouseEvent::SetPrevPos(int _x, int _y)
{
this->dataPtr->prevPos.Set(_x, _y);
}
Expand All @@ -136,7 +136,7 @@ void MouseEvent::SetPressPos(const ignition::math::Vector2i &_pos)
}

/////////////////////////////////////////////////
void MouseEvent::SetPressPos(const int _x, const int _y)
void MouseEvent::SetPressPos(int _x, int _y)
{
this->dataPtr->pressPos.Set(_x, _y);
}
Expand All @@ -154,7 +154,7 @@ void MouseEvent::SetScroll(const ignition::math::Vector2i &_scroll)
}

/////////////////////////////////////////////////
void MouseEvent::SetScroll(const int _x, const int _y)
void MouseEvent::SetScroll(int _x, int _y)
{
this->dataPtr->scroll.Set(_x, _y);
}
Expand All @@ -166,7 +166,7 @@ float MouseEvent::MoveScale() const
}

/////////////////////////////////////////////////
void MouseEvent::SetMoveScale(const float _scale)
void MouseEvent::SetMoveScale(float _scale)
{
this->dataPtr->moveScale = _scale;
}
Expand All @@ -178,7 +178,7 @@ bool MouseEvent::Dragging() const
}

/////////////////////////////////////////////////
void MouseEvent::SetDragging(const bool _dragging)
void MouseEvent::SetDragging(bool _dragging)
{
this->dataPtr->dragging = _dragging;
}
Expand All @@ -190,7 +190,7 @@ MouseEvent::EventType MouseEvent::Type() const
}

/////////////////////////////////////////////////
void MouseEvent::SetType(const EventType _type) const
void MouseEvent::SetType(MouseEvent::EventType _type)
{
this->dataPtr->type = _type;
}
Expand All @@ -202,7 +202,7 @@ MouseEvent::MouseButton MouseEvent::Button() const
}

/////////////////////////////////////////////////
void MouseEvent::SetButton(const MouseEvent::MouseButton _button) const
void MouseEvent::SetButton(MouseEvent::MouseButton _button)
{
this->dataPtr->button = _button;
}
Expand All @@ -214,7 +214,7 @@ unsigned int MouseEvent::Buttons() const
}

/////////////////////////////////////////////////
void MouseEvent::SetButtons(const unsigned int &_buttons)
void MouseEvent::SetButtons(unsigned int _buttons)
{
this->dataPtr->buttons = _buttons;
}
Expand All @@ -226,7 +226,7 @@ bool MouseEvent::Shift() const
}

/////////////////////////////////////////////////
void MouseEvent::SetShift(const bool _shift) const
void MouseEvent::SetShift(bool _shift)
{
this->dataPtr->shift = _shift;
}
Expand All @@ -238,7 +238,7 @@ bool MouseEvent::Alt() const
}

/////////////////////////////////////////////////
void MouseEvent::SetAlt(const bool _alt)
void MouseEvent::SetAlt(bool _alt)
{
this->dataPtr->alt = _alt;
}
Expand All @@ -250,7 +250,7 @@ bool MouseEvent::Control() const
}

/////////////////////////////////////////////////
void MouseEvent::SetControl(const bool _control) const
void MouseEvent::SetControl(bool _control)
{
this->dataPtr->control = _control;
}
Expand Down

0 comments on commit ce7cb4a

Please sign in to comment.