Custom File Class#
RAT enables users to define their own custom files. They can be linked to RAT through Custom File class. Like other classes, the inputs are checked for the right order and type.
The custom file table has the following columns:
Name of the row in the Custom File table
Name of the custom file
Language of the custom file
Path of the custom file
If the 4 columns are supplied, a new row (cell array of strings) is made using the supplied inputs. Then, addCustomFile method is used to append the row to the object. This method takes care of the error checking and incrementing the count of the custom files. The contents of the class are displayed as a table.
Note
RAT supports custom files in C++ (compiled to dynamic library), MATLAB, and Python.
Reference#
- class API.projectClass.customFileClass(name, filename, language, path, functionName)#
customFileClass
manages the custom files for the project. It provides methods to add, update and remove custom files. Each custom file is stored as a row in a table and consists of a name, the filename of the custom file, the language of the file, the path where the file is located, and the name of the function in the file to call.Examples
If no arguments are provided, the object is created with an empty table.
>>> file = customFileClass();
Otherwise, the arguments are used to create the first custom file.
>>> file = customFileClass('custom file 1', 'customBilayer.m', 'matlab');
- Parameters:
name (
string or char array, default: ''
) – The name of this custom file object.filename (
string or char array, default: ''
) – The name of the file containing the custom function.language (
supportedLanguages, default: supportedLanguages.Matlab
) – What language the custom function is written in: ‘matlab’, ‘python’, or ‘cpp’ (via a dynamic library)path (
string or char array, default: ''
) – The path to the custom file.functionName (
string or char array, default: ''
) – The name of the custom function within the file.
- varTable#
A table object that contains the custom file entries.
- Type:
table
- addCustomFile(name, filename, language, path, functionName)#
Adds a new custom file to the file table. For MATLAB, the provided file must be in the matlab path when running.
Examples
To add a new custom file entry with name only.
>>> file.addCustomFile('custom file 1');
To add custom file with name, and filename.
>>> file.addCustomFile('custom file 1', 'customBilayer.m');
To add a Python custom files.
>>> file.addCustomFile('custom file 1', 'customBilayer.py', 'python', 'C:/stuff', 'custom_bilayer);
- Parameters:
name (
string or char array, default: auto-generated name
) – The name of this custom file object.filename (
string or char array, default: ''
) – The name of the file containing the custom function.language (
supportedLanguages, default: supportedLanguages.Matlab
) – What language the custom function is written in: ‘matlab’, ‘python’, or ‘cpp’ (via a dynamic library)path (
string or char array, default: ''
) – The path to the custom file.functionName (
string or char array, default: ''
) – The name of the custom function within the file.
- displayTable()#
Prints the custom file table to the console.
- removeCustomFile(row)#
Removes a given custom file from the table.
Examples
To remove the second custom file in the table (custom file in row 2).
>>> file.removeCustomFile(2);
To remove custom file with a specific name.
>>> file.removeCustomFile('custom file 1');
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the custom file to remove. If it is text, it is the name of the custom file to remove.
- setCustomFile(row, options)#
General purpose method for updating properties of an existing custom file.
Examples
To change the name and filename of the second custom file in the table (custom file in row 2).
>>> file.setCustomFile(2, name='custom file 1', filename='customFunction.m');
To change the properties of a custom file called ‘custom file 1’.
>>> file.setCustomFile('custom file 1', name='new custom file', filename='customFunction.py', language='python');
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the custom file to update. If it is text, it is the name of the custom file to update.options –
- Keyword/value pair to properties to update for the specific custom file.
name (char array or string, default: ‘’) the new name of the custom file.
filename (char array or string, default: ‘’) the new filename of the custom file.
language (supportedLanguages, default: supportedLanguages.empty()) the new language of the custom file.
path (char array or string, default: ‘’) the new path of the custom file.
functionName (char array or string, default: ‘) the new function name of the custom file.
- toStruct()#
Converts the customFileClass into a structure array.
- Returns:
fileStruct – A struct which contains the properties for all the custom files.
- Return type:
struct