Class FMICallbackFunctions.ByValue
- java.lang.Object
-
- com.sun.jna.Structure
-
- org.ptolemy.fmi.FMICallbackFunctions
-
- org.ptolemy.fmi.FMICallbackFunctions.ByValue
-
- All Implemented Interfaces:
com.sun.jna.Structure.ByValue
- Enclosing class:
- FMICallbackFunctions
public static class FMICallbackFunctions.ByValue extends FMICallbackFunctions implements com.sun.jna.Structure.ByValue
A class that contains references to the callback functions.This class is used to register callbacks and pass the callbacks to the fmiInstantiateSlave() or fmiInstantiateModel() method. For example FMUCoSimulation.java contains the following code:
FMICallbackFunctions.ByValue callbacks = new FMICallbackFunctions.ByValue( new FMULibrary.FMULogger(), new FMULibrary.FMUAllocateMemory(), new FMULibrary.FMUFreeMemory(), new FMULibrary.FMUStepFinished()); Function instantiateSlave = fmiModelDescription.getFmiFunction("fmiInstantiateSlave"); Pointer fmiComponent = (Pointer) instantiateSlave.invoke(Pointer.class, new Object[] { _modelIdentifier, fmiModelDescription.guid, fmuLocation, mimeType, timeout, visible, interactive, callbacks, loggingOn });
The Structure.ByValue interface is a marker interface that indicates that the value value of a Structure is to be used by function invocations instead of the address of the Structure. This is necessary because the default is that Structure arguments and return values are usually accessed by reference. For details, see http://twall.github.com/jna/3.4.0/javadoc/com/sun/jna/Structure.ByValue.html.
For details about how Callbacks work in JNA, see http://twall.github.com/jna/3.4.0/javadoc/overview-summary.html#callbacks.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ptolemy.fmi.FMICallbackFunctions
FMICallbackFunctions.ByValue
-
-
Field Summary
-
Fields inherited from class org.ptolemy.fmi.FMICallbackFunctions
allocateMemory, freeMemory, logger, stepFinished
-
-
Constructor Summary
Constructors Constructor Description ByValue(FMILibrary.FMICallbackLogger logger, FMILibrary.FMICallbackAllocateMemory allocateMemory, FMILibrary.FMICallbackFreeMemory freeMemory, FMILibrary.FMIStepFinished stepFinished)
Access the structure by reference.
-
Method Summary
-
Methods inherited from class org.ptolemy.fmi.FMICallbackFunctions
getFieldOrder, initFieldOrder
-
Methods inherited from class com.sun.jna.Structure
allocateMemory, allocateMemory, autoAllocate, autoRead, autoRead, autoWrite, autoWrite, cacheTypeInfo, clear, ensureAllocated, equals, fieldOffset, getAutoRead, getAutoWrite, getFieldList, getFields, getNativeAlignment, getNativeSize, getNativeSize, getPointer, getStringEncoding, getStructAlignment, hashCode, newInstance, newInstance, read, readField, readField, setAlignType, setAutoRead, setAutoSynch, setAutoWrite, setFieldOrder, setStringEncoding, size, sortFields, toArray, toArray, toString, toString, useMemory, useMemory, write, writeField, writeField, writeField
-
-
-
-
Constructor Detail
-
ByValue
public ByValue(FMILibrary.FMICallbackLogger logger, FMILibrary.FMICallbackAllocateMemory allocateMemory, FMILibrary.FMICallbackFreeMemory freeMemory, FMILibrary.FMIStepFinished stepFinished)
Access the structure by reference.See http://twall.github.com/jna/3.4.0/javadoc/overview-summary.html#structures: "To pass a structure by value, first define the structure, then define an empty class from that which implements Structure.ByValue. Use the ByValue class as the argument or return type."
- Parameters:
logger
- The method called to log a status message (C type: fmiCallbackLogger).allocateMemory
- The method called to allocate cleared memory (C type: fmiCallbackAllocateMemoryfreeMemory
- The method called to free allocated memory (C type: fmiCallbackFreeMemory)stepFinished
- The method called when the step is finished. (C type: FmiStepFinished)
-
-