3 Development of C++ codes34.2.1 Changes
CHEAT SHEET |
ITM | IMAS |
---|
#include "UALClasses.h" | #include "UALClasses.h" |
ItmNs::Itm::<cpo> cpo; | IdsNs::IDS::<ids> ids; |
Function syntaxvoid name ( <in/out arguments list> [,code_parameters] [,diagnostic_info] )
- code_parameters - optional - user defined input parameters
- diagnostic_info - arbitrary output diagnostic information
3.2 Arguments list
in/out arguments list mandatorya list of input and output function arguments including:CPP intrisic data types, eg:
IDSes, eg:Argument of type: antennas & antItmNs::Itm::equilibriumArray & eq3.3 Code parameters
OptionalUser defined input parameters<cpo>Array cpoArray; <= Array! | IdsNs::IDS::<ids> ids; <= Single obj ! |
Code Block |
---|
|
typedef struct {
char **parameters;
char **default_param;
char **schema;
} codeparam_t; |
A structure codeparam_t describes:- parameters - Actual value of the code parameters (instance of coparam/parameters in XML format).
- default_param - Default value of the code parameters (instance of coparam/parameters in XML format).
- schema - Code parameters schema.
An example: ItmNs::codeparam_t & codeparam3.4 Diagnostic info
arbitrary output diagnostic informationcodeparam | IdsNs::codeparam_t & codeparam |
eval-pkg-config | pkg-config |
eval-pkg-config --cflags --libs ual-cpp-gnu | pkg-config --cflags --libs imas-cpp |
| |
4.2.2 Examples
Examples of interface between wrapper and user code |
---|
Code Block |
---|
language | cpp |
---|
title | ITM |
---|
linenumbers | true |
---|
| /**** Simple types ***/
void simple(double &x, double &y)
/**** Single slice ***/
void slice( ItmNs::Itm::equilibrium &eq)
/**** Array of slices ***/
void slice_array( ItmNs::Itm::equilibriumArray &eq)
/**** Code XML parameters ***/
void code_params(...., ItmNs::codeparam_t& param)
/**** Arbitrary diagnostic info ***/
void diag_info |
|
output / optional
Code Block |
---|
|
void nameoutput_flagdiagnostic_info)output_flag
- indicates if user subroutine was successfully executed
output_flag = 0
- SUCCESS, no action is taken
output_flag
> 0
- WARNING, a warning message is displayed, workflow continuue execution
output_flag
< 0
- ERROR, actor throws an exception, workflow stops
diagnostic_info
- an arbitrary string
Warning |
---|
Required header Do not forget to add #include "UALClasses.h" while playing with IDSes! |
3.5 Examples
Example 4. Simple in/out argument types | | /**** Simple types ***/
void simple |
|
void simplecppactornoids Code Block |
---|
language | cpp |
---|
title | Example 5. A IDS array as a function argument |
---|
|
void simplecppactor(ItmNs::Itm
/**** Single slice ***/
void slice(IdsNs::IDS::equilibrium &eq |
|
, double &x, double &y)
Code Block |
---|
language | cpp |
---|
title | Example 6. Usage of init function and code input parameters |
---|
|
void mycppfunctionbis_init();
void mycppfunction(ItmNs::Itm::summary& sum, ItmNs::Itm::equilibrium& eq, int& x, ItmNs::Itm::coreimpur& cor, double& y, ItmNs)
/**** Array of slices ***/
void slice_array( IdsNs::IDS:equilibrium &eq)
/**** Code XML parameters ***/
void code_params(...., IdsNs::codeparam_t& |
|
codeparam) Info |
---|
Initialization If user function needs any pre-initialization, an additional function <name>_init could be defined. |
...
param)
/**** Arbitrary diagnostic info ***/
void diag_info(...., int* outFlag, char** diagInfo) |
|
4.2.3 Delivery of the user code
The user code should be delivered as a static library.
Please find examples of the simple "makefilesMakefile" below:
...
language | bash |
---|
title | Example 6. Building of Fortran code |
---|
...
Code Block |
---|
title | Example 7. Building of C++ code |
---|
|
CXX=g++
CXXFLAGS= -g -fPIC
CXXINCLUDES= ${shell eval-pkg-config --cflags ualimas-cpp-gnu}
all: libsimplecppactor.a
libsimplecppactor.a: simplecppactor.o
ar -rvs $@ $^
simplecppactor.o: simplecppactor.cpp
$(CXX) $(CXXFLAGS) $(CXXINCLUDES) -c -o $@ $^
clean:
rm *.a *.o |