next up previous contents index
Next: Limitations to classdesc Up: Object Reflection Previous: Using Classdesc: Method 2,   Contents   Index

Synopsis of classdesc

Syntax:

classdesc [-workdir directory] [-include include-file] [-I directory] [-nodef] [-respect_private] [-typeName] [-onbase] descriptors...

classdesc takes as its input the preprocessed model definition file, that contains all class definitions available to the model. It outputs a functor definition that recursively calls itself for each of the members of that class. If -workdir is specified, the functor definitions are written to the specified directory for later compilation into a library. The (pre-expanded) source header file should also be included via the -include switch so that all necessary types are defined. If -workdir is not specified, the functor definitions are output as inline declarations on standard output.

Normally, classdesc reads its input from standard input, but some operating systems have trouble with this (eg Windows, but not Cygwin). An alternative is to specify the input file using the -i flag.

If -I switches are specified, the specified directory will be added to the search path for the action base include files.

If a type has been forward declared (eg class foo;), but not defined in classdesc's input source, a dummy definition is emitted of the form class foo {};. The purpose of this is to ensure that the action routines for types containing pointers to such declared types will compile. This behaviour can be turned off by specifying the -nodef option to classdesc.

By default, classdesc will generate descriptors that access private and protected members. If a class has private or protected members, a CLASSDESC_ACCESS declaration needs to be given to allow access to the private members. Alternatively, it may be undesirable to expose the internals of an object, for example if the object is being exposed to a different programming environment. In such a case, the -respect_private can be used to suppress the accessing of private or protected members.

By default, enums are treated as integers. Sometimes it is desirable to treat them symbolically, and this is managed by the -typeName option.

-onbase turns on the ability to distinguish between an action called on a base class and one called on a member. If your descriptor does not require this distinction, simply provide a method that calls to the original descriptor:

template <class T>
void pack_onbase(pack_t& x,const string& d,T& a)
{::pack(x,d,a);}
By default, -onbase is disabled as enabling it will break existing code. -onbase will become the default in Classdesc.4


next up previous contents index
Next: Limitations to classdesc Up: Object Reflection Previous: Using Classdesc: Method 2,   Contents   Index
Russell Standish 2016-09-02