Updating State
std::pair<ReturnCode, bool> SmartCapture::Client::update_state<T>(const string & field_name, T object) noexcept;This templated method allows for updating the state of a field in the client, flexible for multiple types. In implementation, it supports all the values of FieldType.
If the field name hasn’t been declared before, either from a loaded trigger or previous call to this method, the client creates a new field internally and sets the type.
NoteThe verb “declared” when it comes to fields refers to the completion of one of two things. Either, a trigger was loaded where that field is used, or this update_state was called at least once. Until one of those is true, an attempt to get_state will return an ErrorCode.
Returns
std::pair<ReturnCode, bool>: SmartCapture::ReturnCode error code, bool successfully updated or not.
NoteThere can be situations where a non-zero error code is encountered while the update was still successful.
Parameters
string field_name: field name to update
T object: template type argument to update as the new state for the field
- 304: InvalidType
const std::pair<ErrorCode, T>& SmartCapture::Client::get_state<FieldType T>(const string & field_name) noexcept;This templated method allows for getting the current state of a field in the client, flexible for multiple types. If the field name hasn’t been declared or if the field has been declared but doesn’t have a current value (e.g. after being cleared, see below) returns a non-zero return code.
Fields
string field_name: string field name to update
Returns
std::pair<ReturnCode, T>&: SmartCapture::ReturnCode error code, the current state value as templated type.
- 305: FieldNotFound
- 306: FieldNotSet
std::pair<ReturnCode, bool> SmartCapture::Client::clear_state(const string & field_name) noexcept;This method allows for the clearing of a single state variable.
Fields
string field_name: string field name to clear
Returns
std::pair<ReturnCode, bool>: SmartCapture::ReturnCode error code, successfully cleared or not
- 305: FieldNotFound
- 306: FieldNotSet
std::pair<ReturnCode, bool> SmartCapture::Client::clear_all_states()
This method clears all state variables.
Returns
std::pair<ReturnCode, bool>: SmartCapture::ReturnCode return code, successfully cleared or not
Updated 10 months ago