Serialization - Proposed Case Studies

###

# Serialization

## Proposed Case Studies

Serializing a Function Object
Archive Adaptors
Archive Helpers

These are not part of the library itself, but rather techiques on how to use the library to address specific situations.

## Serializing a Function Object

An example on how to serialize a function object. I believe this could be done by serializing pointer to the object in question. Since the Serialization library resurrects pointer of the correct type this should be easily implementable.

If a group of function objects were all derived from the same polymorphic base class - perhaps via multiple inheritance, the the function object effectively becomes a "variable" which encapsulates code.

This case study would show how to do this.

## Archive Adaptors

Often users want to add their own special functionality to an existing archive. Examples of this are performance enhancements for specific types, Adjustment of output syntax for xml archives, and logging/debug output as archives are written and/or read. If this functionalty is implemented as an "adaptor" template which takes the base class as a template argument, such functionality appended to any archive for which that funtionality makes sense. For example, an adaptor for generating an xml schema could be appended to both wide narrow character versions of xml archives.

This case study would show how to make a useful archive adaptor.

## Archive Helpers

Some types are not serializable as they stand. That is - they do not fullfill the requirements of the "Serializable Concept". The iconic example of this is boost::shared_ptr. Sometimes these types could be made serializable by adding code inside the library. Of course, doing that would create a lifetime of unpaid employment for the library author. Rather than adding a bunch of special code to the library itself, this code can packaged as a "helper" or "mix-in" class. Then a new archive is derived from both the "base" archive class AND the "helper" class. This is how boost::shared_ptr has been implemented.

It would also be possible to make a "generic runtime helper" which would effectively extend the API of the library. Previously the library included such a helper class. It was removed in favor of the current implementation. But this functionality should be added back in with another adaptor which would become part of the library.

Revised 1 November, 2008

© Copyright Robert Ramey 2002-2008. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)