Some simple taxi/Personal Rapid Transit simulations.
The simulations are written in C++; there are eclipse projects in
ext/si_taxi
These are exposed to Ruby using a wrapper that is automatically generated by SWIG.
Using SWIG constrains the design in a few ways:
-
must use one namespace (in this case si_taxi)
-
nested namespaces won’t work, so we just use prefixes (e.g. BWSim instead of the more conventional bell_wong::Sim).
-
-
nested classes don’t work, so we don’t use them.
-
forward declarations of the form
struct A; void foo(A *a);
must be used instead of
void foo(struct A *a);
-
avoid operator() and operator[], because they require extra swig code.
-
don’t inherit from classes that don’t wrap well (e.g. an extension of a boost matrix class doesn’t work; it can be used as a member, because we define a typemap.
-
don’t use exit or assert, because these will kill Ruby as well