getByFramework method
Get assignments by framework
Implementation
Future<List<ModelInfo>> getByFramework(int framework) async {
try {
final lib = PlatformLoader.loadCommons();
final getByFn = lib.lookupFunction<
Int32 Function(Int32, Pointer<Pointer<Pointer<RacModelInfoStruct>>>, Pointer<IntPtr>),
int Function(int, Pointer<Pointer<Pointer<RacModelInfoStruct>>>,
Pointer<IntPtr>)>('rac_model_assignment_get_by_framework');
final outModelsPtr = calloc<Pointer<Pointer<RacModelInfoStruct>>>();
final outCountPtr = calloc<IntPtr>();
try {
final result = getByFn(framework, outModelsPtr, outCountPtr);
if (result != RacResultCode.success) return [];
final count = outCountPtr.value;
if (count == 0) return [];
final models = <ModelInfo>[];
final modelsArray = outModelsPtr.value;
for (var i = 0; i < count; i++) {
final modelPtr = modelsArray[i];
if (modelPtr != nullptr) {
models.add(_structToModelInfo(modelPtr));
}
}
return models;
} finally {
calloc.free(outModelsPtr);
calloc.free(outCountPtr);
}
} catch (e) {
_logger.debug('rac_model_assignment_get_by_framework error: $e');
return [];
}
}