pub struct CapeValueInFromProvider {
interface: ICapeValue,
interface_ptr: *mut ICapeValue,
}Expand description
CapeValueInFromProvider
When calling a CAPE-OPEN method that takes a CapeValue as input,
the caller provides an object that implements CapeValueProviderIn,
for example CapeValueImpl.
The CapeValueInFromProvider returns an C::ICapeValue 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::CapePersistWriter.
When implementing a function that gets called, and takes a CapeValue
as input, it received a &CapeValueIn typed argument, which is
constructed from the reference to an C::ICapeValue interface pointer.
Typically a function call receives the C::ICapeValue interface
from the caller, and from this, the CapeValueIn 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
CapeValueProviderIn trait, allocate the pointer, point to it, and
construct the CapeValueIn object from a reference to that pointer.
The CapeValueInFromProvider class does all this.
§Example
use cobia::*;
let value = CapeValueImpl::from_real(3.14);
fn ValueFromCapeValueIn(value:&CapeValueIn) -> f64 {
assert!(value.get_type().unwrap()==cobia::CapeValueType::Real);
value.get_real().unwrap()
}
let value=ValueFromCapeValueIn(&CapeValueInFromProvider::from(&value).as_cape_value_in()); //this is how value is passed as &CapeValueIn argument
assert_eq!(value,3.14);Fields§
§interface: ICapeValue§interface_ptr: *mut ICapeValue