Classdesc
Classdesc is a system for adding reflection to C++, ie the
ability to query an object's structure at runtime. This is different
from run time type enquiry (RTTI), which merely returns a unique
signature for an object's type.
It consists of a preprocessor that parses class definitions, and
outputs definitions of an overloaded function (called an action,
or descriptor)
that is recursively called on the members. By defining the action on basic types such as int, floats, chars etc, the action can
be called on any arbitrary type.
The classdesc distribution comes with an action called pack
defined, which performs serialisation on objects (packing an object
into a binary representation, which may optionally be machine independent).
ClassdescMP builds on the serialisation capability of Classdesc to
provide an easy to use MPI programming environment for C++ users.
A Fortran version of Classdesc, called FClassdesc was started under a
project funded by the Australian Partnership for
Advanced Computing, but is not currently
under active development. A snapshot of this project that implements
serialisation is available from the file release area.
Obviously (at this stage) Classdesc is only useful for C++ programmers.
- Checkpoint/Restart. Make all relevant variables part of a single
model object, then use pack to convert this model object into a
binary stream that can be written to a file. Because the serialised
object can be machine independent, the resulting checkpoint file can
be moved between different computing architectures.
- Developing MPI applications. ClassdescMP takes away much of the
pain involved in programming MPI applications, particularly when you
need to pass around more complicated data structures than arrays of
basic types.
- Persistent object store for unstructured
applications. Considerable performance boosts can be achieved over
naive reliance on virtual memory when the number of objects exceeds
available physical memory.
- Interfacing with other programming languages. For example, one
can interface with TCL/TK to easily add GUI items to a model
simulation. The accessor functions to obtain or set data items within
the model are created automatically via classdesc. See
Ecolab
for an example
implementation. Of course,
Swig
may also be used for
this purpose.
- Client-server applications. By periodically shipping a
serialised copy of a model state over a network to a client program,
one can easily create a client analysis or visualisation program of a
running simulation that is running elsewhere. See
Ecolab
for an example
implementation.
Please use reference 7 below to cite Classdesc, and
5 to refer to ClassdescMP.
- Standish R.K. (2024) “Fat API bindings of
C++ objects into scripting
languages”,
Overload Journal, 32, No. 181 16-20. arXiv:2403.14940 .
- Standish R.K. (2019) “C++ Reflection for
Python Binding”, Overload Journal, No. 152, 15-18.
- Standish R.K. (2016) “Classdesc: A
Reflection System for
C++11”, Overload
Journal, No. 131, 18-23.
- Standish, R.K. and Madina, D. (2008)
“Classdesc and Graphcode: support for scientific
programming in C++”,
arXiv:cs.CE/0610120
- Standish, R.K. and Madina, D. (2003)
“ClassdescMP: Easy MPI programming in
C++”
in Computational Science, Sloot et al. (eds),
LNCS
2660, Springer, 896. arXiv:cs.DC/0401027
- Leow, R. and Standish, R.K. (2003) “Running
C++ models under the Swarm
Environment”, in Proceedings SwarmFest 2003. arXiv:cs.MA/0401025
- Madina, D. and Standish, R.K. (2001)
“A system for reflection in
C++”, in Proceedings AUUG 2001:
Always on and Everywhere, 207. ISBN 0957753225
arXiv:cs.PL/0401024