org.ptolemy.fmi
Class FMICallbackFunctions.ByValue

java.lang.Object
  extended by com.sun.jna.Structure
      extended by org.ptolemy.fmi.FMICallbackFunctions
          extended by 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 = getFunction("_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
 
Nested classes/interfaces inherited from class com.sun.jna.Structure
com.sun.jna.Structure.ByReference
 
Field Summary
 
Fields inherited from class org.ptolemy.fmi.FMICallbackFunctions
allocateMemory, freeMemory, logger, stepFinished
 
Fields inherited from class com.sun.jna.Structure
ALIGN_DEFAULT, ALIGN_GNUC, ALIGN_MSVC, ALIGN_NONE, CALCULATE_SIZE
 
Constructor Summary
FMICallbackFunctions.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, getStructAlignment, hashCode, newInstance, read, readField, setAlignType, setAutoRead, setAutoSynch, setAutoWrite, setFieldOrder, setTypeMapper, size, sortFields, toArray, toArray, toString, toString, useMemory, useMemory, write, writeField, writeField
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FMICallbackFunctions.ByValue

public FMICallbackFunctions.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: fmiCallbackAllocateMemory
freeMemory - The method called to free allocated memory (C type: fmiCallbackFreeMemory)
stepFinished - The method called when the step is finished. (C type: FmiStepFinished)