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 ICapePMCEnumeratorImplementations§
Source§impl CapePMCEnumerator
impl CapePMCEnumerator
Sourcepub fn new() -> Result<CapePMCEnumerator, COBIAError>
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();Sourcepub fn get_pmc_by_uuid(
&self,
uuid: &CapeUUID,
) -> Result<CapePMCRegistrationDetails, COBIAError>
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();pub fn get_pmc_by_prog_id( &self, prog_id: &str, ) -> Result<CapePMCRegistrationDetails, COBIAError>
Sourcepub fn pmcs(
&self,
cat_ids: &[CapeUUID],
) -> Result<CobiaCollection<CapePMCRegistrationDetails>, COBIAError>
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();Sourcepub fn all_pmcs(
&self,
) -> Result<CobiaCollection<CapePMCRegistrationDetails>, COBIAError>
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
impl Clone for CapePMCEnumerator
Add pointer reference
ICapePMCEnumerator derives from ICobiaBase, which contains addReference() and release(). The Clone trait calls addReference.