package io.github.spharris.ssc;

import jnr.ffi.Pointer;
import jnr.ffi.annotations.Out;
import jnr.ffi.byref.FloatByReference;
import jnr.ffi.byref.IntByReference;

/**
 * Raw interface to the Ssc library. Declares the basic functions defined in
 * sscapi.h
 * 
 * @author spharris
 */
public interface Ssc {
	public int ssc_version();
	public String ssc_build_info();
	
	/*
	 * Data object management functions
	 */
	public Pointer ssc_data_create();
	public void ssc_data_free(Pointer data);
	public void ssc_data_clear(Pointer data);
	public void ssc_data_unassign(Pointer data, String name);
	public int ssc_data_query(Pointer data, String name);
	public String ssc_data_first(Pointer data);
	public String ssc_data_next(Pointer data);
	
	/*
	 * Setters and getters for different data types
	 */
	public void ssc_data_set_number(Pointer data, String name, float value);
	public void ssc_data_set_string(Pointer data, String name, String value);
	public void ssc_data_set_array(Pointer data, String name, float[] values, int length);
	public void ssc_data_set_matrix(Pointer data, String name, float[] values, int rows, int cols);
	public void ssc_data_set_table(Pointer data, String name, Pointer table);
	
	public boolean ssc_data_get_number(Pointer data, String name, @Out FloatByReference value);
	public String ssc_data_get_string(Pointer data, String name);
	public Pointer ssc_data_get_array(Pointer data, String name, @Out IntByReference lenth);
	public Pointer ssc_data_get_matrix(Pointer data, String name, @Out IntByReference rows, @Out IntByReference cols);
	public Pointer ssc_data_get_table(Pointer data, String name);
	
	/*
	 * Module metadata functions
	 */
	public Pointer ssc_module_entry(int index);
	public String ssc_entry_name(Pointer entry);
	public String ssc_entry_description(Pointer entry);
	public int ssc_entry_version(Pointer entry);
	
	/*
	 * Module creation functions
	 */
	public Pointer ssc_module_create(String moduleName);
	public void ssc_module_free(Pointer module);

	/*
	 * Info functions
	 */
	public Pointer ssc_module_var_info(Pointer module, int index);
	public int ssc_info_var_type(Pointer info);
	public int ssc_info_data_type(Pointer info);
	public String ssc_info_name(Pointer info);
	public String ssc_info_label(Pointer info);
	public String ssc_info_units(Pointer info);
	public String ssc_info_meta(Pointer info);
	public String ssc_info_group(Pointer info);
	public String ssc_info_required(Pointer info);
	public String ssc_info_constraints(Pointer info);
	
	/*
	 * Module execution functions
	 */
	public void ssc_module_exec_set_print(int print);
	public boolean ssc_module_exec_simple(String name, Pointer data);
	public String ssc_module_exec_simple_nothread(String name, Pointer data);
	public boolean ssc_module_exec(Pointer module, Pointer data);
	public String ssc_module_log(Pointer module, int index, @Out IntByReference itemType, @Out FloatByReference time);
	
	/*
	 * Module execution with a handler. The user must create a handler to pass in during
	 * execution.
	 */
	public boolean ssc_module_exec_with_handler(Pointer module, Pointer data,
			ExecutionHandler handler, Pointer userData);
}

@@ -50,16 +50,47 @@
 ointer;%0A
+import jnr.ffi.annotations.In;%0A
 import j
@@ -598,32 +598,36 @@
 gn(Pointer data,
+ @In
  String name);%0A%09
@@ -657,32 +657,36 @@
 ry(Pointer data,
+ @In
  String name);%0A%09
@@ -871,32 +871,36 @@
 er(Pointer data,
+ @In
  String name, fl
@@ -949,32 +949,36 @@
 ng(Pointer data,
+ @In
  String name, St
@@ -974,16 +974,20 @@
 ng name,
+ @In
  String 
@@ -1031,32 +1031,36 @@
 ay(Pointer data,
+ @In
  String name, fl
@@ -1048,32 +1048,36 @@
 @In String name,
+ @In
  float%5B%5D values,
@@ -1128,32 +1128,36 @@
 ix(Pointer data,
+ @In
  String name, fl
@@ -1149,24 +1149,28 @@
 String name,
+ @In
  float%5B%5D val
@@ -1232,32 +1232,36 @@
 le(Pointer data,
+ @In
  String name, Po
@@ -1317,32 +1317,36 @@
 er(Pointer data,
+ @In
  String name, @O
@@ -1413,32 +1413,36 @@
 ng(Pointer data,
+ @In
  String name);%0A%09
@@ -1480,32 +1480,36 @@
 ay(Pointer data,
+ @In
  String name, @O
@@ -1575,32 +1575,36 @@
 ix(Pointer data,
+ @In
  String name, @O
@@ -1702,16 +1702,20 @@
 er data,
+ @In
  String 
@@ -2027,16 +2027,20 @@
 _create(
+@In 
 String m
@@ -2735,16 +2735,20 @@
 _simple(
+@In 
 String n
@@ -2814,16 +2814,20 @@
 othread(
+@In 
 String n

Annotate with @In where appropriate