Struct CapePMCEnumerator

Source
pub struct CapePMCEnumerator {
    pub(crate) interface: *mut ICapePMCEnumerator,
}
Expand description

Enumerator for all registered PMCs.

This is used to get the details of each PMC by name or UUID, or to get all registered PMCs.

Fields§

§interface: *mut ICapePMCEnumerator

Implementations§

Source§

impl CapePMCEnumerator

Source

pub fn new() -> Result<CapePMCEnumerator, COBIAError>

Create a new PMC enumerator.

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let pmc_enumerator = cobia::CapePMCEnumerator::new().unwrap();
//...
cobia::cape_open_cleanup();
Source

pub fn get_pmc_by_uuid( &self, uuid: &CapeUUID, ) -> Result<CapePMCRegistrationDetails, COBIAError>

Get a PMC by its UUID.

Typically a PME will enumerate PMCs to allow the user to pick one. Then the PME stores the UUID of the PMC that the user picked, so that in future sessions, it can be re-created.

Upon saving a flowsheet, the UUID of the PMC is stored in the flowsheet, along with the UUID of the PME, and perhaps additional information that is needed to re-create the PMC (such as the package name in case of a Property Package created from a CAPE-OPEN 1.2 Property Package Manager).

Then, when restoring the flowsheet, the PMC is created from its UUID, and subsequently depersisted.

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let pmc_enumerator = cobia::CapePMCEnumerator::new().unwrap();
let mut first_pmc : Option<cobia::CapePMCRegistrationDetails> = None;
for pmc in pmc_enumerator.all_pmcs().unwrap() {
  first_pmc = Some(pmc);
  break;
}
if let Some(pmc) = first_pmc {
    let uuid = pmc.get_uuid().unwrap();
    let pmc = pmc_enumerator.get_pmc_by_uuid(&uuid).unwrap();
    assert_eq!(pmc.get_uuid().unwrap(),uuid);
}
cobia::cape_open_cleanup();
Source

pub fn get_pmc_by_prog_id( &self, prog_id: &str, ) -> Result<CapePMCRegistrationDetails, COBIAError>

Source

pub fn pmcs( &self, cat_ids: &[CapeUUID], ) -> Result<CobiaCollection<CapePMCRegistrationDetails>, COBIAError>

Get all registered PMCs of specific type(s).

Get a collection of all registered PMCs, of a given type or multiple given types.

In a typical scenario the PME is interested in instantiating, and therefore selecting,a specific type of PMC, such as a Property Package, Unit Operation, … This function provides a collection with all PMCs of the given type(s).

On Windows, COM based PMCs are included in the collection.

§Examples
use cobia;
use cobia::prelude::*;
use cobia::cape_open;
cobia::cape_open_initialize().unwrap();
let pmc_enumerator = cobia::CapePMCEnumerator::new().unwrap();
//let's create some thermo! Enumerate all Property Package Managers and stand-alone Property Packages
let pmc_types=[cape_open::CATEGORYID_PROPERTYPACKAGEMANAGER,cape_open::CATEGORYID_STANDALONEPROPERTYPACKAGE];
let pmcs = pmc_enumerator.pmcs(&pmc_types).unwrap();
for pmc in pmcs {
    println!("Found Thermo-PMC: {} ({})",pmc.get_name().unwrap(),pmc.get_description().unwrap());
}
cobia::cape_open_cleanup();
Source

pub fn all_pmcs( &self, ) -> Result<CobiaCollection<CapePMCRegistrationDetails>, COBIAError>

Get all registered PMCs of any type.

Get a collection of all registered PMCs, of any PMC type.

This function is not typically used, as in a typical scenario the PME is interested in instantiating, and therefore selecting, a specific type of PMC, such as a Property Package, Unit Operation, …

On Windows, COM based PMCs are included in the collection.

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let pmc_enumerator = cobia::CapePMCEnumerator::new().unwrap();
let pmcs = pmc_enumerator.all_pmcs().unwrap();
for pmc in pmcs {
    println!("Found PMC: {} ({})",pmc.get_name().unwrap(),pmc.get_description().unwrap());
}
cobia::cape_open_cleanup();

Trait Implementations§

Source§

impl Clone for CapePMCEnumerator

Add pointer reference

ICapePMCEnumerator derives from ICobiaBase, which contains addReference() and release(). The Clone trait calls addReference.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for CapePMCEnumerator

Release pointer

ICapePMCEnumerator derives from ICobiaBase, which contains addReference() and release(). The Drop trait calls release.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.