next up previous contents index
Next: Excluding particular members from Up: Object Reflection Previous: supported #pragmas   Contents   Index


CLASSDESC_ACCESS

Because serialisation requires access to the private parts of a class definition, by default classdesc will emit actions for all members of class, whether private or public. Either all members of the class need to be declared public, or a friend declaration needs to be inserted so as to allow the action function to have access to the private members. The best way to do this is to put a CLASSDESC_ACCESS declaration in the class's definition, as in the following example:

class foo
{
   int x, y
   CLASSDESC_ACCESS(foo);
 public:
   int z;
}

template <class T>
class bar
{
   T x, y
   CLASSDESC_ACCESS(bar);
 public:
   T z;
}

The macro takes a single argument -- the typename of class in question. The program insert-friend parses it input, and outputs a copy with these declarations appropriately inserted. This may be used to automate the process, but is not 100% reliable.

The CLASSDESC_ACCESS_TEMPLATE is now deprecated, and is synonymous with CLASSDESC_ACCESS.

The header file classdesc_access.h defines versions of these macros for the pack/unpack actions -- use this file as a guide for writing your own macros if you implement other actions.

On the other hand, for descriptors like isa, and for exposure descriptors like TCL_obj in Eco Lab, it is not desirable to process private members. For these purposes, use -respect_private command line flag of classdesc.


next up previous contents index
Next: Excluding particular members from Up: Object Reflection Previous: supported #pragmas   Contents   Index
Russell Standish 2016-09-02