cobia/cape_object.rs
1use crate::*;
2use cape_smart_pointer::CapeSmartPointer;
3
4const ICAPEINTERFACE_UUID:CapeUUID=CapeUUID::from_slice(&[0x53u8,0xa7u8,0x4eu8,0xe9u8,0xadu8,0xfau8,0x49u8,0x16u8,0xbeu8,0x95u8,0x04u8,0xe9u8,0x28u8,0x3cu8,0xc2u8,0x2eu8]);
5
6/// Generic Cape Object smart pointer
7///
8/// This is a generic smart pointer to any CAPE-OPEN object,
9/// that points to the basic ICapeInterface interface.
10///
11/// This smart pointer is used when it is not clear what the
12/// type of the object is, but it is known that it is a CAPE-OPEN.
13///
14/// #Example
15///
16/// ```no_run
17/// use cobia;
18/// use cobia::prelude::*;
19/// cobia::cape_open_initialize().unwrap();
20/// let pmc_enumerator = cobia::CapePMCEnumerator::new().unwrap();
21/// let ppm_info_result=pmc_enumerator.get_pmc_by_prog_id("COCO_TEA.PropertyPackManager");
22/// match ppm_info_result {
23/// Ok(ppm_info) => {
24/// let ppm_result=ppm_info.create_instance( //ppm_result is a CapeObject
25/// cobia::CapePMCCreationFlags::AllowRestrictedThreading); //we only use the object in this thread
26/// match ppm_result {
27/// Ok(ppm) => {
28/// //show name
29/// let iden_result=cobia::cape_open_1_2::CapeIdentification::from_object(&ppm); //this is how to obtain a particular interface from a CapeObject
30/// match iden_result {
31/// Ok(iden) => {
32/// let mut name = cobia::CapeStringImpl::new();
33/// iden.get_component_name(&mut name).unwrap();
34/// println!("PPM name: {}",name);
35/// }
36/// Err(_) => {
37/// eprintln!("Object does not implement CAPEOPEN_1_2::ICapeIdentification");
38/// }
39/// }
40/// }
41/// Err(err) => {
42/// eprintln!("Cannot find TEA property package manager (not installed?): {err}");
43/// }
44/// };
45/// }
46/// Err(err) => {
47/// eprintln!("Cannot find TEA property package manager (not installed?): {err}");
48/// }
49/// };
50/// cobia::cape_open_cleanup();
51/// ```
52
53#[cape_smart_pointer(ICAPEINTERFACE_UUID)]
54pub struct CapeObject {
55 pub(crate) interface: *mut C::ICapeInterface,
56}
57