Third Party Library unshareable type definition, creating objects.

Heya!

I have a problem where I dont know the optimal approach.

I have a compiled library from matlab to a .lib file and headers. Basically a solved simulation where we can control inputs and step the simulation forward.
These are not compatible with UE4, as in I cant publically include the module they are included in. So I go through module 1 which includes the second one.
Not sure if this is the best approach but it works, not the issue.

I also need to have multiple components. Each component needs to run its own simulation. The library stores a lot states internally. I can initiate new models with a simple call like:

RT_MODEL_model_T *sim_model = model(&inputs, &outputs);

The problem is how to best allocate the model and input+output structs for each component. From interface.h I can’t reach the type definitions defined in model.h

I got it working by creating the ‘Interface’ as a UObject, which has void* sim_model as one of its variable. And then the input+output structs are shared between all interface-objects, and overwritten for each use.

Interface.h:

UCLASS()
class Plugin_API UM1_Interface: public UObject
{
    GENERATED_BODY()

public:
    UM1_Interface(const FObjectInitializer& ObjectInitializer);

private:
    void* sim_model;
};

Interface.cpp:

ExtU_model_T inputs;
ExtY_model_T outputs;

void UVTM_Interface::Initialize()
{
	sim_model= vtm_model(&inputs, &outputs);
    model_initialize((RT_MODEL_model_T*)sim_model,&inputs,&outputs);
}

FVector UVTM_Interface::StepSim()
{
    model_step((RT_MODEL_vtm_model_T*)sim_model, &inputs, &outputs);
    return  outputs.pos;
}

Any suggestions for a better approach?


f