| 1 |
{% macro cpp_file() %} |
| 2 |
#include<stdlib.h> |
| 3 |
#include "objects.h" |
| 4 |
#include<ctime> |
| 5 |
#include<random> |
| 6 |
|
| 7 |
{% for codeobj in code_objects | sort(attribute='name') %} |
| 8 |
#include "code_objects/{{codeobj.name}}.h" |
| 9 |
{% endfor %} |
| 10 |
|
| 11 |
{% for name in user_headers | sort %} |
| 12 |
#include {{name}} |
| 13 |
{% endfor %} |
| 14 |
|
| 15 |
void brian_start() |
| 16 |
{ |
| 17 |
_init_arrays(); |
| 18 |
_load_arrays(); |
| 19 |
// Initialize clocks (link timestep and dt to the respective arrays) |
| 20 |
{% for clock in clocks | sort(attribute='name') %} |
| 21 |
brian::{{clock.name}}.timestep = brian::{{array_specs[clock.variables['timestep']]}}; |
| 22 |
brian::{{clock.name}}.t = brian::{{array_specs[clock.variables['t']]}}; |
| 23 |
{% if clock.__class__.__name__ == "EventClock" %} {# FIXME: A bit ugly... #} |
| 24 |
brian::{{clock.name}}.times = brian::{{array_specs[clock.variables['times']]}}; |
| 25 |
brian::{{clock.name}}.n_times = {{clock.variables['times'].size}}; |
| 26 |
{% else %} |
| 27 |
brian::{{clock.name}}.dt = brian::{{array_specs[clock.variables['dt']]}}; |
| 28 |
{% endif %} |
| 29 |
{% endfor %} |
| 30 |
} |
| 31 |
|
| 32 |
void brian_end() |
| 33 |
{ |
| 34 |
_write_arrays(); |
| 35 |
_dealloc_arrays(); |
| 36 |
} |
| 37 |
|
| 38 |
{% for name, lines in run_funcs.items() | sort(attribute='name') %} |
| 39 |
void {{name}}() |
| 40 |
{ |
| 41 |
using namespace brian; |
| 42 |
|
| 43 |
{{lines|autoindent}} |
| 44 |
} |
| 45 |
|
| 46 |
{% endfor %} |
| 47 |
|
| 48 |
{% endmacro %} |
| 49 |
|
| 50 |
///////////////////////////////////////////////////////////////////////////////////////////////////// |
| 51 |
|
| 52 |
{% macro h_file() %} |
| 53 |
|
| 54 |
void brian_start(); |
| 55 |
void brian_end(); |
| 56 |
|
| 57 |
{% for name, lines in run_funcs.items() | sort(attribute='name') %} |
| 58 |
void {{name}}(); |
| 59 |
{% endfor %} |
| 60 |
|
| 61 |
{% endmacro %} |