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: CapeStringImplThe name of the port
description: CapeStringImplThe description of the port
connected_object: Option<CapeThermoMaterial>The connected material object, if any
is_inlet: boolIndicates whether this port is an inlet (true) or an outlet (false)
Shared data for the unit, containing unit-specific information
cobia_object_data: MaterialPortCobiaObjectDataCobia object data for this object, which contains generated code to provide the native COBIA interfaces
Implementations§
Source§impl MaterialPort
impl MaterialPort
fn create_instance( _material_port_boxed_ptr: *mut *mut ICapeInterface, name: CapeStringImpl, description: CapeStringImpl, is_inlet: bool, shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> CapeResult
Sourcepub(crate) fn create<T: CapeSmartPointer>(
name: CapeStringImpl,
description: CapeStringImpl,
is_inlet: bool,
shared_unit_data: Rc<RefCell<SharedUnitData>>,
) -> T
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.
Sourcepub(crate) fn try_create<T: CapeSmartPointer>(
name: CapeStringImpl,
description: CapeStringImpl,
is_inlet: bool,
shared_unit_data: Rc<RefCell<SharedUnitData>>,
) -> Result<T, COBIAError>
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.
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.
Source§impl MaterialPort
impl MaterialPort
Sourcepub(crate) fn get_connected_material(&self) -> Option<CapeThermoMaterial>
pub(crate) fn get_connected_material(&self) -> Option<CapeThermoMaterial>
Get the connected material object, if any.
§Returns:
- The connected material object, or
Noneif the port is not connected to any material object.
Trait Implementations§
Source§impl Display for MaterialPort
impl Display for MaterialPort
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
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 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 MaterialPort
impl ICapeIdentification for MaterialPort
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 port 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 port implementation and will return an error.
Source§impl ICapeIdentificationImpl for MaterialPort
impl ICapeIdentificationImpl for MaterialPort
type T = MaterialPort
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 ICapeInterfaceImpl for MaterialPort
impl ICapeInterfaceImpl for MaterialPort
type T = MaterialPort
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 MaterialPort
fn get_self(&mut self) -> *mut MaterialPort
§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 ICapeUnitPort for MaterialPort
impl ICapeUnitPort for MaterialPort
Source§fn get_port_type(&mut self) -> Result<CapePortType, COBIAError>
fn get_port_type(&mut self) -> Result<CapePortType, COBIAError>
Get the port type.
§Returns:
- A
Resultcontaining the port type, which is alwaysCapeMaterialfor this implementation.
Source§fn get_direction(&mut self) -> Result<CapePortDirection, COBIAError>
fn get_direction(&mut self) -> Result<CapePortDirection, COBIAError>
Get the direction of the port.
§Returns:
- A
Resultcontaining the port direction, which is eitherCapeInletorCapeOutlet.
Source§fn get_connected_object(&mut self) -> Result<CapeObject, COBIAError>
fn get_connected_object(&mut self) -> Result<CapeObject, COBIAError>
Get the connected object of the port.
§Returns:
- A
Resultcontaining the connectedCapeObject, or an error if the port is not connected.