RIT VEXU Core API
Loading...
Searching...
No Matches
Initializer Class Reference

#include <initializer.h>

Public Member Functions

 Initializer (std::function< void()> initialize)
 Initializer (std::vector< Initialization > initializations, std::function< Selector::selector_t > selector, std::function< void()> pre_init=nullptr, std::function< void()> post_init=nullptr)
void initialize ()
const std::vector< Initialization > & initializations () const
const std::size_t initialization_count () const
const std::string selected_name () const
unsigned int selected_meta () const
unsigned int selected_index () const
bool uninitialized () const

Detailed Description

Initializer is a utility that allows one program to call different robot initializations depending on a selection function, effectively reducing the amount of program slots that need to be redownloaded when making modifications to the entire code.

Constructor & Destructor Documentation

◆ Initializer() [1/2]

Initializer::Initializer ( std::function< void()> initialize)

Shorthand for constructing an Initializer that bypasses selection and simply calls the provided callback function during initialization. Ideally, this constructor will never be used, but is included to allow quick, simple changes to programs without forcing extra changes or unnecessary syntax.

Parameters
initializeThe callback function used to initialize the robot

◆ Initializer() [2/2]

Initializer::Initializer ( std::vector< Initialization > initializations,
std::function< Selector::selector_t > selector,
std::function< void()> pre_init = nullptr,
std::function< void()> post_init = nullptr )

The primary constructor for Initializer

Parameters
initializationsA vector of Initializations
selectorA function used to select the Initialization. If a nullptr is passed for this, the initialize() function will call the first Initialization.
pre_initA function for common code that runs before the selection-dependent initialization. This should only be used to setup anything needed by the initializer selector function.
post_initA function for common code that runs after the selection-dependent initialization

The constructor for Initializer

Parameters
initializationsA vector of Initializations
selectorA function used to select the Initialization. If a nullptr is passed for this, the initialize() function will call the first Initialization.
pre_initA function for common code that runs before the selection-dependent initialization. This should only be used to setup anything needed by the initializer selector function.
post_initA function for common code that runs after the selection-dependent initialization

Member Function Documentation

◆ initialization_count()

const std::size_t Initializer::initialization_count ( ) const

Returns the number of Initializations that can be selected

Returns
The length of the internal collect of Initializations

◆ initializations()

const std::vector< Initialization > & Initializer::initializations ( ) const

Returns the vector storing the Initializations

Returns
A constant reference to the internal vector that stores Initializations

◆ initialize()

void Initializer::initialize ( )

Initializes the robot

◆ selected_index()

unsigned int Initializer::selected_index ( ) const

Returns the index of the selected Initialization

Returns
If an Initialization has been selected using the initialize() function, this returns that Initialization's index. Otherwise, this returns Selector::NO_SELECTION_INDEX.

Returns the index of the selected Initialization

Returns
If an Initialization has been selected using the initialize() function, this returns that Initialization's index. Otherwise, this returns 0xFFFFFFFF.

◆ selected_meta()

unsigned int Initializer::selected_meta ( ) const

Returns the meta of the selected Initialization

Returns
If an Initialization has been selected using the initialize() function, this returns that Initialization's meta. Otherwise, this returns SIZE_MAX.

Returns the meta of the selected Initialization

Returns
If an Initialization has been selected using the initialize() function, this returns that Initialization's meta. Otherwise, this returns 0xFFFFFFFF.

◆ selected_name()

const std::string Initializer::selected_name ( ) const

Returns the name of the selected Initialization

Returns
If an Initialization has been selected using the initialize() function, this returns that Initialization's name. Otherwise, this returns an empty string.

◆ uninitialized()

bool Initializer::uninitialized ( ) const

Returns whether or not the robot is currently uninitialized

Returns
Returns true if the robot has not been initialized, and false if it already has.

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