pub struct IntegerParameter {
pub(crate) name: CapeStringImpl,
description: CapeStringImpl,
is_input: bool,
shared_unit_data: Rc<RefCell<SharedUnitData>>,
pub(crate) value: i32,
default_value: i32,
minimum_value: i32,
maximum_value: i32,
cobia_object_data: IntegerParameterCobiaObjectData,
}Expand description
The IntegerParameter class implements a CAPE-OPEN 1.2 integer parameter.
Parameters must implement the ICapeIdentification and ICapeParameter interfaces. In addition, integer parameters must implement the ICapeIntegerParameter interface.
This implementation can be used for both input and output parameters. Input parameters can be set by the user, while output parameters are set by the unit operation.
Although CAPE-OPEN defines a value for an integer that is not specified (the equivalent of NaN for real values), this value is not widely supported, and unspecified values are not allowed in this implementation.
Any invalid values (outside the bounds of the parameter) will raise an error when set. Therefore, any parameter is valid.
Fields§
§name: CapeStringImplThe name of the parameter
description: CapeStringImplThe description of the parameter
is_input: boolIndicates whether this parameter is an input (true) or an output (false)
Shared data for the unit, containing unit-specific information
value: i32The current value of the parameter
default_value: i32Default value of the parameter
minimum_value: i32Minimum value of the parameter
maximum_value: i32Maximum value of the parameter
cobia_object_data: IntegerParameterCobiaObjectDataCobia object data for this object, which contains generated code to provide the native COBIA interfaces
Implementations§
Source§impl IntegerParameter
impl IntegerParameter
fn create_instance( _integer_parameter_boxed_ptr: *mut *mut ICapeInterface, name: CapeStringImpl, description: CapeStringImpl, is_input: bool, shared_unit_data: Rc<RefCell<SharedUnitData>>, default_value: i32, minimum_value: i32, maximum_value: i32, ) -> CapeResult
Sourcepub(crate) fn create<T: CapeSmartPointer>(
name: CapeStringImpl,
description: CapeStringImpl,
is_input: bool,
shared_unit_data: Rc<RefCell<SharedUnitData>>,
default_value: i32,
minimum_value: i32,
maximum_value: i32,
) -> T
pub(crate) fn create<T: CapeSmartPointer>( name: CapeStringImpl, description: CapeStringImpl, is_input: bool, shared_unit_data: Rc<RefCell<SharedUnitData>>, default_value: i32, minimum_value: i32, maximum_value: i32, ) -> T
Create a new instance of the object and return a smart pointer to it
This function panics if the created object does not implement the interface corresponding to the smart pointer to be returned. For a non-panic version, use the try_create() function.
Sourcepub(crate) fn try_create<T: CapeSmartPointer>(
name: CapeStringImpl,
description: CapeStringImpl,
is_input: bool,
shared_unit_data: Rc<RefCell<SharedUnitData>>,
default_value: i32,
minimum_value: i32,
maximum_value: i32,
) -> Result<T, COBIAError>
pub(crate) fn try_create<T: CapeSmartPointer>( name: CapeStringImpl, description: CapeStringImpl, is_input: bool, shared_unit_data: Rc<RefCell<SharedUnitData>>, default_value: i32, minimum_value: i32, maximum_value: i32, ) -> Result<T, COBIAError>
Create a new instance of the object and return a smart pointer to it
This function returns an error if the created object does not implement the interface corresponding to the smart pointer to be returned.
Sourcepub(crate) unsafe fn borrow<T: CapeSmartPointer>(smart_pointer: &T) -> &Self
pub(crate) unsafe fn borrow<T: CapeSmartPointer>(smart_pointer: &T) -> &Self
Get a reference to the object
Note that as the reference is created from a smart pointer, the reference is valid only as long as the smart pointer is valid. The reference is not checked for multiple borrows
§Safety
The user must ensure that the smart pointer contains a valid object, and that the object is of the type that is being borrowed. It is not possible for the compiler to check this, as the borrow is done through the native object pointer in the interface.
Sourcepub(crate) unsafe fn borrow_mut<T: CapeSmartPointer>(
smart_pointer: &mut T,
) -> &mut Self
pub(crate) unsafe fn borrow_mut<T: CapeSmartPointer>( smart_pointer: &mut T, ) -> &mut Self
Get a mutable reference to the object
Note that as the reference is created from a smart pointer, the reference is valid only as long as the smart pointer is valid. The reference is not checked for multiple borrows
§Safety
This function is unsafe because it allows mutable access to the object. Also the user must ensure that the smart pointer contains a valid object, and that the object is of the type that is being borrowed. It is not possible for the compiler to check this, as the borrow is done through the native object pointer in the interface.
Trait Implementations§
Source§impl Display for IntegerParameter
impl Display for IntegerParameter
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format the IntegerParameter as a string for display purposes.
The std::fmt::Display interface is used when generating the source name of the object that raises an error.
§Arguments:
f- A mutable reference to astd::fmt::Formatterwhere the formatted string will be written.
§Returns:
- A
std::fmt::Resultindicating the success or failure of the formatting operation.
Source§impl ICapeIdentification for IntegerParameter
impl ICapeIdentification for IntegerParameter
Source§fn get_component_name(
&mut self,
name: &mut CapeStringOut<'_>,
) -> Result<(), COBIAError>
fn get_component_name( &mut self, name: &mut CapeStringOut<'_>, ) -> Result<(), COBIAError>
Source§fn get_component_description(
&mut self,
description: &mut CapeStringOut<'_>,
) -> Result<(), COBIAError>
fn get_component_description( &mut self, description: &mut CapeStringOut<'_>, ) -> Result<(), COBIAError>
Source§fn set_component_name(
&mut self,
_name: &CapeStringIn<'_>,
) -> Result<(), COBIAError>
fn set_component_name( &mut self, _name: &CapeStringIn<'_>, ) -> Result<(), COBIAError>
Set the name of the component.
This method is not allowed for this parameter implementation and will return an error.
Source§fn set_component_description(
&mut self,
_desc: &CapeStringIn<'_>,
) -> Result<(), COBIAError>
fn set_component_description( &mut self, _desc: &CapeStringIn<'_>, ) -> Result<(), COBIAError>
Set the description of the component.
This method is not allowed for this parameter implementation and will return an error.
Source§impl ICapeIdentificationImpl for IntegerParameter
impl ICapeIdentificationImpl for IntegerParameter
type T = IntegerParameter
fn as_interface_pointer(&mut self) -> *mut ICapeInterface
§fn init_interface() -> _ICapeInterface
fn init_interface() -> _ICapeInterface
fn init<Timpl>(u: &mut Timpl)where
Timpl: ICapeIdentificationImpl + ICapeInterfaceImpl,
extern "C" fn raw_get_component_name( me: *mut c_void, name: *mut _ICapeString, ) -> u32
extern "C" fn raw_set_component_name( me: *mut c_void, name: *mut _ICapeString, ) -> u32
extern "C" fn raw_get_component_description( me: *mut c_void, desc: *mut _ICapeString, ) -> u32
extern "C" fn raw_set_component_description( me: *mut c_void, desc: *mut _ICapeString, ) -> u32
const VTABLE: CAPEOPEN_1_2_ICapeIdentification_VTable = _
Source§impl ICapeIntegerParameter for IntegerParameter
impl ICapeIntegerParameter for IntegerParameter
Source§fn get_value(&mut self) -> Result<CapeInteger, COBIAError>
fn get_value(&mut self) -> Result<CapeInteger, COBIAError>
Get the value of the parameter.
This method retrieves the current value of the parameter.
§Returns:
- A
Resultcontaining the current value of the parameter asCapeInteger.
Source§fn set_value(&mut self, value: CapeInteger) -> Result<(), COBIAError>
fn set_value(&mut self, value: CapeInteger) -> Result<(), COBIAError>
Set the value of the parameter.
This implementation accepts a blank value for the parameters, but it does not allow an invalid value to be set.
Only input parameters can be set.
If the value is set, it marks the unit as dirty and not validated.
§Arguments:
value- The value to set for the parameter, which should be aCapeInteger.
§Returns:
- A
Resultindicating success or failure.
Source§fn get_default_value(&mut self) -> Result<CapeInteger, COBIAError>
fn get_default_value(&mut self) -> Result<CapeInteger, COBIAError>
Get the default value of the parameter.
This method retrieves the default value of the parameter.
§Returns:
- A
Resultcontaining the default value of the parameter asCapeInteger, or an error.
Source§fn get_lower_bound(&mut self) -> Result<CapeInteger, COBIAError>
fn get_lower_bound(&mut self) -> Result<CapeInteger, COBIAError>
Get the lower bound of the parameter.
This method retrieves the lower bound of the parameter.
§Returns:
- A
Resultcontaining the lower bound of the parameter asCapeInteger, or an error.
Source§fn get_upper_bound(&mut self) -> Result<CapeInteger, COBIAError>
fn get_upper_bound(&mut self) -> Result<CapeInteger, COBIAError>
Get the upper bound of the parameter.
This method retrieves the upper bound of the parameter.
§Returns:
- A
Resultcontaining the upper bound of the parameter asCapeInteger, or an error.
Source§fn validate(
&mut self,
value: CapeInteger,
message: &mut CapeStringOut<'_>,
) -> Result<CapeBoolean, COBIAError>
fn validate( &mut self, value: CapeInteger, message: &mut CapeStringOut<'_>, ) -> Result<CapeBoolean, COBIAError>
Validate whether a given value is valid for this parameter.
This method checks if the provided value is within the bounds of the parameter and meets the dimensionality requirements.
Output parameters are not validated, as they are set by the unit operation and not by the user.
§Arguments:
value- The value to validate, which should be aCapeInteger.message- A mutable reference to aCapeStringOutwhere any validation error messages will be set.
§Returns:
- A
Resultcontaining aCapeBooleanindicating whether the value is valid or not. If the value is not valid, it sets an error message inmessage.
Source§impl ICapeIntegerParameterImpl for IntegerParameter
impl ICapeIntegerParameterImpl for IntegerParameter
type T = IntegerParameter
fn as_interface_pointer(&mut self) -> *mut ICapeInterface
§fn init_interface() -> _ICapeInterface
fn init_interface() -> _ICapeInterface
fn init<Timpl>(u: &mut Timpl)where
Timpl: ICapeIntegerParameterImpl + ICapeInterfaceImpl,
extern "C" fn raw_get_value(me: *mut c_void, value: *mut i32) -> u32
extern "C" fn raw_set_value(me: *mut c_void, value: i32) -> u32
extern "C" fn raw_get_default_value( me: *mut c_void, default_value: *mut i32, ) -> u32
extern "C" fn raw_get_lower_bound( me: *mut c_void, l_bound: *mut i32, ) -> u32
extern "C" fn raw_get_upper_bound( me: *mut c_void, u_bound: *mut i32, ) -> u32
extern "C" fn raw_validate( me: *mut c_void, value: i32, message: *mut _ICapeString, is_ok: *mut u32, ) -> u32
const VTABLE: CAPEOPEN_1_2_ICapeIntegerParameter_VTable = _
Source§impl ICapeInterfaceImpl for IntegerParameter
impl ICapeInterfaceImpl for IntegerParameter
type T = IntegerParameter
Source§fn get_object_data(&mut self) -> &mut CapeObjectData
fn get_object_data(&mut self) -> &mut CapeObjectData
CapeObjectData structure.Source§fn get_self(&mut self) -> *mut IntegerParameter
fn get_self(&mut self) -> *mut IntegerParameter
§const CAPEINTERFACE_VTABLE: ICapeInterface_VTable = _
const CAPEINTERFACE_VTABLE: ICapeInterface_VTable = _
§fn init(&mut self) -> *mut _ICapeInterface
fn init(&mut self) -> *mut _ICapeInterface
§fn create_object_data<Timpl>() -> CapeObjectDatawhere
Timpl: ICapeInterfaceImpl,
fn create_object_data<Timpl>() -> CapeObjectDatawhere
Timpl: ICapeInterfaceImpl,
extern "C" fn raw_add_reference(me: *mut c_void)
extern "C" fn raw_release(me: *mut c_void)
extern "C" fn raw_query_interface( me: *mut c_void, uuid: *const _CapeUUID, interface: *mut *mut _ICapeInterface, ) -> u32
extern "C" fn raw_get_last_error( me: *mut c_void, error: *mut *mut _ICapeError, ) -> u32
§fn add_interface(
&mut self,
uuid: *const _CapeUUID,
interface: *mut _ICapeInterface,
)
fn add_interface( &mut self, uuid: *const _CapeUUID, interface: *mut _ICapeInterface, )
§fn set_last_error(&mut self, error: COBIAError, scope: &str) -> u32
fn set_last_error(&mut self, error: COBIAError, scope: &str) -> u32
§fn clear_last_error(&mut self)
fn clear_last_error(&mut self)
§fn as_icapeinterface(&mut self) -> *mut _ICapeInterface
fn as_icapeinterface(&mut self) -> *mut _ICapeInterface
Source§impl ICapeParameter for IntegerParameter
impl ICapeParameter for IntegerParameter
Source§fn get_val_status(&mut self) -> Result<CapeValidationStatus, COBIAError>
fn get_val_status(&mut self) -> Result<CapeValidationStatus, COBIAError>
Get the validation status of the parameter.
As this parameter does not accept any values that are not valid, the parameter is always valid.
§Returns:
- A
Resultcontaining the validation status, which is alwaysCapeValidfor this implementation.
Source§fn get_mode(&mut self) -> Result<CapeParamMode, COBIAError>
fn get_mode(&mut self) -> Result<CapeParamMode, COBIAError>
Get the mode of the parameter.
§Returns:
- A
Resultcontaining the mode of the parameter, which is eitherCapeInputorCapeOutputbased on theis_inputfield.
Source§fn get_type(&mut self) -> Result<CapeParamType, COBIAError>
fn get_type(&mut self) -> Result<CapeParamType, COBIAError>
Get the type of the parameter.
§Returns:
- A
Resultcontaining the type of the parameter, which is alwaysCapeParameterIntegerfor this implementation.
Source§fn validate(
&mut self,
_message: &mut CapeStringOut<'_>,
) -> Result<CapeBoolean, COBIAError>
fn validate( &mut self, _message: &mut CapeStringOut<'_>, ) -> Result<CapeBoolean, COBIAError>
Validate the parameter.
As this parameter does not accept any values that are not valid, the parameter is always valid.
§Arguments:
message- A mutable reference to aCapeStringOutwhere any validation error messages will be set.
§Returns:
- A
Resultcontaining aCapeBooleanindicating whether the parameter is valid or not.
Source§fn reset(&mut self) -> Result<(), COBIAError>
fn reset(&mut self) -> Result<(), COBIAError>
Reset the parameter to its default value.
This method sets the value of the parameter back to its default value and marks the unit as dirty.
It also resets the validation status to CapeNotValidated.
§Returns:
- A
Resultindicating success or failure. If successful, the value is reset to the default value.