pub struct CapeArrayRealInFromProvider {
interface: ICapeArrayReal,
interface_ptr: *mut ICapeArrayReal,
}Expand description
CapeArrayRealInFromProvider
When calling a CAPE-OPEN method that takes a CapeArrayReal as input,
the caller provides an object that implements CapeArrayRealProviderIn,
for example CapeArrayRealVec.
The CapeArrayRealInFromProvider returns an C::ICapeArrayReal 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::CapeThermoMaterial.
When implementing a function that gets called, and takes a CapeArrayReal
as input, it received a &CapeArrayRealIn typed argument, which is
constructed from the reference to an C::ICapeArrayReal interface pointer.
Typically a function call receives the C::ICapeArrayReal interface
from the caller, and from this, the CapeArrayRealIn 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
CapeArrayRealProviderIn trait, allocate the pointer, point to it, and
construct the CapeArrayRealIn object from a reference to that pointer.
The CapeArrayRealInFromProvider class does all this.
§Example
use cobia::*;
let array = CapeArrayRealVec::from_slice(&[1.0,2.0,3.0]);
fn ArrayFromCapeArrayRealIn(array:&CapeArrayRealIn) -> Vec<f64> {
array.as_vec()
}
let value=ArrayFromCapeArrayRealIn(&CapeArrayRealInFromProvider::from(&array).as_cape_array_real_in()); //this is how array is passed as &CapeArrayRealIn argument
assert_eq!(value,vec![1.0,2.0,3.0]);Fields§
§interface: ICapeArrayReal§interface_ptr: *mut ICapeArrayReal