Trait CapeSmartPointer

Source
pub trait CapeSmartPointer {
    type Interface;

    // Required methods
    fn as_interface_pointer(&self) -> *mut Self::Interface;
    fn as_cape_interface_pointer(&self) -> *mut ICapeInterface;
    fn get_interface_id() -> &'static CapeUUID;
    fn from_object<T: CapeSmartPointer>(
        smart_pointer: &T,
    ) -> Result<Self, COBIAError>
       where Self: Sized;
    fn from_interface_pointer(interface: *mut Self::Interface) -> Self;
    fn attach(interface: *mut Self::Interface) -> Self;
    fn detach(self) -> *mut Self::Interface;
    fn from_cape_interface_pointer(
        interface: *mut ICapeInterface,
    ) -> Result<Self, COBIAError>
       where Self: Sized;
    fn last_error(&self) -> Option<CapeError>;
}
Expand description

COBIA Smart Pointer

External objects implement interfaces that all derive from ICapeInterface.

Objects that provide wrappers for such interfaces also typically maintain the reference count for the underlying object.

An object can implement multiple interfaces, and one interface wrapper can be converted to that for another wrapper provided that the object implements the corresponding interface

Required Associated Types§

Required Methods§

Source

fn as_interface_pointer(&self) -> *mut Self::Interface

Get the interface pointer

This function provides the interface wrapped by the object.

Source

fn as_cape_interface_pointer(&self) -> *mut ICapeInterface

Get the ICapeInterface

All CAPE-OPEN interfaces are laid out such that the first fields correspond to the field of ICapeInterface and therefore all interfaces can safely be cast to ICapeInterface.

This function provides the ICapeInterface representation of the interface wrapped by the object.

Source

fn get_interface_id() -> &'static CapeUUID

Get the interface ID

All interfaces are identified by a unique ID, which is passed to the queryInterface member function of ICapeInterface to obtain a pointer to that interface.

This function exposes the interface ID for the interface that is wrapped.

Source

fn from_object<T: CapeSmartPointer>( smart_pointer: &T, ) -> Result<Self, COBIAError>
where Self: Sized,

Get an interface wrapper instance from another object

This function provides an interface wrapper from any object that implements ICapeInterface, provided that the underlying object implements the interface.

This function performs a queryInterface on the object that is passed as argument, with the interface ID returned by as_cape_interface_pointer()

Source

fn from_interface_pointer(interface: *mut Self::Interface) -> Self

Get an interface wrapper instance from an interface pointer of the wrapped type

This function provides an interface wrapper directly from the interface pointer.

#Safety

The interface pointer must be valid and must point to an object that implements the interface.

#Panics

Panics if the interface pointer is null.

Source

fn attach(interface: *mut Self::Interface) -> Self

Get an interface wrapper instance from an interface pointer of the wrapped type, without adding a reference

This function provides an interface wrapper directly from the interface pointer. Typical use it to attach a return value from an external function, which must be released by the receiver, to the smart pointer.

#Safety

The interface pointer must be valid and must point to an object that implements the interface.

#Panics

Panics if the interface pointer is null.

Source

fn detach(self) -> *mut Self::Interface

Return an interface pointer and release ownership, without decreasing a reference

This function releases ownership of the object by returning the contained pointer. The caller is responsible for releasing the object. Typical use is to return the pointer from a function that is exposed externally.

Source

fn from_cape_interface_pointer( interface: *mut ICapeInterface, ) -> Result<Self, COBIAError>
where Self: Sized,

Get an interface wrapper instance from any interface pointer

This function provides an interface wrapper directly from any CAPE-OPEN interface pointer by performing a queryInterface.

If the object does not implement the interface, the function returns an error. If the interface pointer is null, the function returns an error.

Any CAPE-OPEN interface can be cast to ICapeInterface. This is a reinterpret-cast and therefore an unsafe operation.

#Safety

If non-null, the interface pointer must be valid and must point to an object that implements the interface.

Source

fn last_error(&self) -> Option<CapeError>

Get the last error

The last error is available after a function call that returns a COBIAERR_CAPEOPENERROR. This function calls getLastError on ICapeInterface to obtain the last error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl CapeSmartPointer for CapeArrayBooleanParameter

Source§

impl CapeSmartPointer for CapeArrayBooleanParameterSpecification

Source§

impl CapeSmartPointer for CapeArrayIntegerParameter

Source§

impl CapeSmartPointer for CapeArrayIntegerParameterSpecification

Source§

impl CapeSmartPointer for CapeArrayParameter

Source§

impl CapeSmartPointer for CapeArrayParameterSpecification

Source§

impl CapeSmartPointer for CapeArrayRealParameter

Source§

impl CapeSmartPointer for CapeArrayRealParameterSpecification

Source§

impl CapeSmartPointer for CapeArrayStringParameter

Source§

impl CapeSmartPointer for CapeArrayStringParameterSpecification

Source§

impl CapeSmartPointer for CapeBooleanParameter

Source§

impl CapeSmartPointer for CapeBooleanParameterSpecification

Source§

impl CapeSmartPointer for CapeCOSEUtilities

Source§

impl CapeSmartPointer for CapeCustomDataSource

Source§

impl CapeSmartPointer for CapeDiagnostic

Source§

impl CapeSmartPointer for CapeFlowsheetMonitoring

Source§

impl CapeSmartPointer for CapeFlowsheetMonitoringComponent

Source§

impl CapeSmartPointer for CapeFlowsheetMonitoringEventSink

Source§

impl CapeSmartPointer for CapeIdentification

Source§

impl CapeSmartPointer for CapeIntegerParameter

Source§

impl CapeSmartPointer for CapeIntegerParameterSpecification

Source§

impl CapeSmartPointer for CapeMaterialManager

Source§

impl CapeSmartPointer for CapeParameter

Source§

impl CapeSmartPointer for CapeParameterSpecification

Source§

impl CapeSmartPointer for CapePersist

Source§

impl CapeSmartPointer for CapePersistReader

Source§

impl CapeSmartPointer for CapePersistWriter

Source§

impl CapeSmartPointer for CapeRealParameter

Source§

impl CapeSmartPointer for CapeRealParameterSpecification

Source§

impl CapeSmartPointer for CapeReport

Source§

impl CapeSmartPointer for CapeSimulationContext

Source§

impl CapeSmartPointer for CapeStream

Source§

impl CapeSmartPointer for CapeStringParameter

Source§

impl CapeSmartPointer for CapeStringParameterSpecification

Source§

impl CapeSmartPointer for CapeThermoCompounds

Source§

impl CapeSmartPointer for CapeThermoEquilibriumRoutine

Source§

impl CapeSmartPointer for CapeThermoMaterial

Source§

impl CapeSmartPointer for CapeThermoMaterialContext

Source§

impl CapeSmartPointer for CapeThermoMaterialCustomData

Source§

impl CapeSmartPointer for CapeThermoPetroleumFractions

Source§

impl CapeSmartPointer for CapeThermoPhases

Source§

impl CapeSmartPointer for CapeThermoPropertyPackageManager

Source§

impl CapeSmartPointer for CapeThermoPropertyRoutine

Source§

impl CapeSmartPointer for CapeThermoUniversalConstant

Source§

impl CapeSmartPointer for CapeUnit

Source§

impl CapeSmartPointer for CapeUnitPort

Source§

impl CapeSmartPointer for CapeUtilities

Source§

impl CapeSmartPointer for CapeLibraryDetails

Source§

impl CapeSmartPointer for CapeObject

Source§

impl CapeSmartPointer for CapePMCRegistrationDetails

Source§

impl CapeSmartPointer for CobiaIdentification

Source§

impl<CollectionItem: CapeSmartPointer> CapeSmartPointer for CapeCollection<CollectionItem>

Source§

impl<Element: CapeSmartPointer> CapeSmartPointer for CobiaCollectionBase<Element>