Wrapping - Class
================

This example illustrates how C++ classes can be wrapped with Cython and SWIG so that they can be leveraged in Python.
The class designed is a hypothetical data processor that can be configured when initiated/created, loads data (loadData method) , processes the data (run method) and returns the result (extractData method). The processor is highly verbose to illustrate the different steps.
The implementation of the C++ class is in the folder "tools" with the usual header file analyzer.h specifying the 

Cython path - Wrapping
----------------------
To wrap the C++ class in Cython, we create the Cython file analyzer_cython.pyx taking the signature of the C++ class and creating a corresponding Cython/Python class that wraps each function of the C+1 class
We can omit irrelevant parts of the class, e.g. the method of the C++ class called notSoImportantMethod.

Cython path - Compiling
-----------------------
We compile the Cython code wrapping the C++ class via the setup script setup_cython.py invoking it with

$ python setup_cython.py build_ext --inplace

The resulting shared object analyzer_cython.*.so (* depends on the operating system and python version)

Cython path - Run
-----------------
The script run_cython.py shows how the created shared object can be imported and used in code. Run it with 

$ python run_cython.py


SWIG path - Wrapping
--------------------
SWIG automatically wraps the C++ code. The wrapping is configured via the interface file analyzer.i and is run via

$ swig -c++ -python analyzer.i

Since this is done automatically all parts of the class are wrapped, including also functions that are not relevant.

SWIG path - Compiling
---------------------
We compile the files created by SWIG via a setup script called setup_swig.py

$ python setup_swig.py build_ext --inplace

The resulting shared object _analyzer_swig.*.so (* depends on the operating system and python version) is not directly imported by Python but via a python file analyzer.py. (NB: Be mindful about potential name classes, thus it is good practice to have an underscore in front of the name for the module created in SWIG)

SWIG path - Run
-----------------
The script run_swig.py shows how the created shared object can be imported and used in code. Run it with 

$ python run_swig.py


C++ version
-----------
The file run_cpp.c is a script that does the same as run_swig.py and run_cython.py, but directly in C++.
To compile it run

$ g++ run_cpp.c tools/analyzer.cpp -I. -o run_cpp

and to run it

$ ./run_cpp

