Struct MaterialPort

Source
pub struct MaterialPort {
    name: CapeStringImpl,
    description: CapeStringImpl,
    connected_object: Option<CapeThermoMaterial>,
    is_inlet: bool,
    shared_unit_data: Rc<RefCell<SharedUnitData>>,
    cobia_object_data: MaterialPortCobiaObjectData,
}
Expand description

The MaterialPort class implements a CAPE-OPEN 1.2 material port.

It connects to a valid CAPE-OPEN 1.2 compliant material object provided by the PME.

Fields§

§name: CapeStringImpl

The name of the port

§description: CapeStringImpl

The description of the port

§connected_object: Option<CapeThermoMaterial>

The connected material object, if any

§is_inlet: bool

Indicates whether this port is an inlet (true) or an outlet (false)

§shared_unit_data: Rc<RefCell<SharedUnitData>>

Shared data for the unit, containing unit-specific information

§cobia_object_data: MaterialPortCobiaObjectData

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

Implementations§

Source§

impl MaterialPort

Source

fn create_instance( _material_port_boxed_ptr: *mut *mut ICapeInterface, name: CapeStringImpl, description: CapeStringImpl, is_inlet: bool, shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> CapeResult

Source

pub(crate) fn create<T: CapeSmartPointer>( name: CapeStringImpl, description: CapeStringImpl, is_inlet: bool, 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>( name: CapeStringImpl, description: CapeStringImpl, is_inlet: bool, 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 MaterialPort

Source

pub(crate) fn get_connected_material(&self) -> Option<CapeThermoMaterial>

Get the connected material object, if any.

§Returns:
  • The connected material object, or None if the port is not connected to any material object.
Source

pub(crate) fn get_name(&self) -> &CapeStringImpl

Get the name of the port.

§Returns:
  • A reference to the name of the port as a CapeStringImpl.

Trait Implementations§

Source§

impl Display for MaterialPort

Source§

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

Format the MaterialPort 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 a std::fmt::Formatter where the formatted string will be written.
§Returns:
  • A std::fmt::Result indicating the success or failure of the formatting operation.
Source§

impl ICapeIdentification for MaterialPort

Source§

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

Get 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>

Get 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>

Set the name of the component.

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

Source§

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

Set the description of the component.

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

Source§

impl ICapeIdentificationImpl for MaterialPort

Source§

type T = MaterialPort

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 MaterialPort

Source§

type T = MaterialPort

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 MaterialPort

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.
Source§

impl ICapeUnitPort for MaterialPort

Source§

fn get_port_type(&mut self) -> Result<CapePortType, COBIAError>

Get the port type.

§Returns:
  • A Result containing the port type, which is always CapeMaterial for this implementation.
Source§

fn get_direction(&mut self) -> Result<CapePortDirection, COBIAError>

Get the direction of the port.

§Returns:
  • A Result containing the port direction, which is either CapeInlet or CapeOutlet.
Source§

fn get_connected_object(&mut self) -> Result<CapeObject, COBIAError>

Get the connected object of the port.

§Returns:
  • A Result containing the connected CapeObject, or an error if the port is not connected.
Source§

fn connect(&mut self, object_to_connect: CapeObject) -> Result<(), COBIAError>

Connect the port to a CapeObject.

This port will only accept connections to a valid CapeThermoMaterial object.

§Arguments:
  • object_to_connect - The CapeObject to connect to the port.
§Returns:
  • A Result indicating success or failure. If successful, the port is connected to the material object.
Source§

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

Disconnect the port from its connected object.

§Returns:
  • A Result indicating success or failure; always succeeds.
Source§

impl ICapeUnitPortImpl for MaterialPort

Source§

type T = MaterialPort

Source§

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

§

fn init_interface() -> _ICapeInterface

prepare CAPEOPEN_1_2_ICapeUnitPort interface and return as generic ICapeInterface pointer
§

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

§

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

§

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

§

extern "C" fn raw_get_connected_object( me: *mut c_void, connected_object: *mut *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_connect( me: *mut c_void, object_to_connect: *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_disconnect(me: *mut c_void) -> u32

§

const VTABLE: CAPEOPEN_1_2_ICapeUnitPort_VTable = _

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.