Struct ParameterCollection

Source
pub(crate) struct ParameterCollection {
    name: CapeStringImpl,
    description: CapeStringImpl,
    parameters: Vec<CapeParameter>,
    shared_unit_data: Rc<RefCell<SharedUnitData>>,
    parameter_name_map: CapeOpenMap<usize>,
    cobia_object_data: ParameterCollectionCobiaObjectData,
}
Expand description

A collection of parameters for the distillation shortcut unit.

This collection implements the ICapeIdentification and ICapeCollection<ICapeParameter> interfaces and provides methods to manage parameters associated with the unit.

Fields§

§name: CapeStringImpl

The name of the parameter collection.

§description: CapeStringImpl

The description of the parameter collection.

§parameters: Vec<CapeParameter>

The parameters in the collection.

§shared_unit_data: Rc<RefCell<SharedUnitData>>

Shared data for the unit, allowing access to common properties.

§parameter_name_map: CapeOpenMap<usize>

A map to quickly access parameters by their names.

§cobia_object_data: ParameterCollectionCobiaObjectData

Cobia object data for this object, which contains generated code to provide the native COBIA interfaces

Implementations§

Source§

impl ParameterCollection

Source

fn create_instance( _parameter_collection_boxed_ptr: *mut *mut ICapeInterface, shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> CapeResult

Source

pub(crate) fn create<T: CapeSmartPointer>( shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> 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.

Source

pub(crate) fn try_create<T: CapeSmartPointer>( shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> 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.

Source

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.

Source

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.

Source§

impl ParameterCollection

Source

fn new(shared_unit_data: Rc<RefCell<SharedUnitData>>) -> Self

Creates a new ParameterCollection for the distillation shortcut unit.

§Arguments
  • shared_unit_data - A reference to shared data for the unit, which contains common properties.
§Returns

A new instance of ParameterCollection initialized with the provided shared data.

Source

pub(crate) fn add_parameter<T: CapeSmartPointer>(&mut self, parameter: T)

Adds a parameter to the collection.

The parameter’s name is cached for quick look-ups by name.

§Arguments
  • parameter - A smart pointer to the parameter to be added.
Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut CapeParameter>

Obtain an iterator to iterate over the parameters in the collection.

§Returns

An iterator that yields references to the parameters in the collection.

Trait Implementations§

Source§

impl Display for ParameterCollection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the parameter collection for display.

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 the formatter where the output will be written.
§Returns

A result indicating whether the formatting was successful or not.

Source§

impl ICapeCollection<CapeParameter> for ParameterCollection

Source§

fn item_by_index( &mut self, index: CapeInteger, ) -> Result<CapeParameter, COBIAError>

Retrieves a parameter by its index.

§Arguments
  • index - The index of the parameter to retrieve.
§Returns

A result containing the parameter if found, or an error if the index is out of bounds.

Source§

fn item_by_name( &mut self, name: &CapeStringIn<'_>, ) -> Result<CapeParameter, COBIAError>

Retrieves a parameter by its name.

§Arguments
  • name - A reference to the name of the parameter to retrieve.
§Returns

A result containing the parameter if found, or an error if the name does not exist in the collection.

Source§

fn get_count(&mut self) -> Result<CapeInteger, COBIAError>

Gets the number of parameters in the collection.

§Returns

A result containing the number of parameters as a CapeInteger.

Source§

impl ICapeCollectionImpl<CapeParameter> for ParameterCollection

Source§

type T = ParameterCollection

Source§

fn as_interface_pointer(&mut self) -> *mut ICapeInterface

§

fn init_interface() -> _ICapeInterface

prepare CAPEOPEN_1_2_ICapeCollection interface and return as generic ICapeInterface pointer
§

fn init<Timpl>(u: &mut Timpl)
where Timpl: ICapeCollectionImpl<CollectionItem> + ICapeInterfaceImpl,

§

extern "C" fn raw_item_by_index( me: *mut c_void, index: i32, item: *mut *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_item_by_name( me: *mut c_void, name: *mut _ICapeString, item: *mut *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_get_count( me: *mut c_void, item_count: *mut i32, ) -> u32

§

const VTABLE: CAPEOPEN_1_2_ICapeCollection_VTable = _

Source§

impl ICapeIdentification for ParameterCollection

Source§

fn get_component_name( &mut self, name: &mut CapeStringOut<'_>, ) -> Result<(), COBIAError>

Gets the name of the component.

§Arguments
  • name - A mutable reference to a CapeStringOut where the name will be set.
§Returns

A result indicating success or failure. If successful, the name is set in name.

Source§

fn get_component_description( &mut self, description: &mut CapeStringOut<'_>, ) -> Result<(), COBIAError>

Gets the description of the component.

§Arguments
  • description - A mutable reference to a CapeStringOut where the description will be set.
§Returns

A result indicating success or failure. If successful, the description is set in description.

Source§

fn set_component_name( &mut self, _name: &CapeStringIn<'_>, ) -> Result<(), COBIAError>

Sets the name of the component.

This method is not allowed for this parameter collection implementation and will return an error.

Source§

fn set_component_description( &mut self, _desc: &CapeStringIn<'_>, ) -> Result<(), COBIAError>

Sets the description of the component.

This method is not allowed for this parameter collection implementation and will return an error.

Source§

impl ICapeIdentificationImpl for ParameterCollection

Source§

type T = ParameterCollection

Source§

fn as_interface_pointer(&mut self) -> *mut ICapeInterface

§

fn init_interface() -> _ICapeInterface

prepare CAPEOPEN_1_2_ICapeIdentification interface and return as generic ICapeInterface pointer
§

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 ICapeInterfaceImpl for ParameterCollection

Source§

type T = ParameterCollection

Source§

fn get_object_data(&mut self) -> &mut CapeObjectData

Returns a mutable reference to the internal CapeObjectData structure.
Source§

fn get_self(&mut self) -> *mut ParameterCollection

Returns a pointer to the implementing object.
§

const CAPEINTERFACE_VTABLE: ICapeInterface_VTable = _

the V-table for the ICapeInterface implementation.
§

fn init(&mut self) -> *mut _ICapeInterface

Initializes the object, setting up the interface pointer and adding it to the interface map.
§

fn create_object_data<Timpl>() -> CapeObjectData
where Timpl: ICapeInterfaceImpl,

Utility function for internal object setup
§

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, )

Utility function to add an interface to the interface map. Read more
§

fn set_last_error(&mut self, error: COBIAError, scope: &str) -> u32

Utility function to set the last error and scope. Read more
§

fn clear_last_error(&mut self)

Utility function to clear the last error and scope.
§

fn as_icapeinterface(&mut self) -> *mut _ICapeInterface

Returns a unique pointer to the ICapeInterface implementation of the object.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.