pub struct CapeArrayEnumerationInFromProvider<Element: Copy + Clone> {
interface: ICapeArrayEnumeration,
interface_ptr: *mut ICapeArrayEnumeration,
element_type: PhantomData<Element>,
}Expand description
CapeArrayEnumerationInFromProvider
When calling a CAPE-OPEN method that takes a CapeArrayEnumeration as input,
the caller provides an object that implements CapeArrayEnumerationProviderIn,
for example CapeArrayEnumerationVec.
The CapeArrayEnumerationInFromProvider returns an C::ICapeArrayEnumeration interface, which
has a small life span, enough to make sure that the pointer to this
interface is valid. This is done inside wrapper classes such as
capeopen_1_2::CapeArrayRealParameter.
When implementing a function that gets called, and takes a CapeArrayEnumeration
as input, it received a &CapeArrayEnumerationIn typed argument, which is
constructed from the reference to an C::ICapeArrayEnumeration interface pointer.
Typically a function call receives the C::ICapeArrayEnumeration interface
from the caller, and from this, the CapeArrayEnumerationIn is constructed by
the cape_object_implementation macro.
In the rare case that one wants to call an internal CAPE-OPEN function
directly, one needs to provide the class that implements the
CapeArrayEnumerationProviderIn trait, allocate the pointer, point to it, and
construct the CapeArrayEnumerationIn object from a reference to that pointer.
The CapeArrayEnumerationInFromProvider class does all this.
§Example
use cobia::*;
let array = cobia::CapeArrayEnumerationVec::from_slice(&[CapePMCServiceType::Inproc64,CapePMCServiceType::COM64]);
fn ArrayFromCapeArrayEnumerationIn(array:&CapeArrayEnumerationIn<CapePMCServiceType>) -> Vec<CapePMCServiceType> {
array.as_vec()
}
let value=ArrayFromCapeArrayEnumerationIn(&CapeArrayEnumerationInFromProvider::from(&array).as_cape_array_enumeration_in()); //this is how array is passed as &CapeArrayEnumerationIn argument
assert_eq!(value,vec![CapePMCServiceType::Inproc64,CapePMCServiceType::COM64]);Fields§
§interface: ICapeArrayEnumeration§interface_ptr: *mut ICapeArrayEnumeration§element_type: PhantomData<Element>