1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- 4(C) Copyright 2002-4 Robert Ramey - http://www.rrsd.com . 5Use, modification and distribution is subject to the Boost Software 6License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7http://www.boost.org/LICENSE_1_0.txt) 8--> 9<head> 10<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 11<link rel="stylesheet" type="text/css" href="../../../boost.css"> 12<link rel="stylesheet" type="text/css" href="style.css"> 13<title>Serialization - Proposed Case Studies</title> 14</head> 15<body link="#0000ff" vlink="#800080"> 16<table border="0" cellpadding="7" cellspacing="0" width="100%" summary="header"> 17 <tr> 18 <td valign="top" width="300"> 19 <h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../boost.png" border="0"></a></h3> 20 </td> 21 <td valign="top"> 22 <h1 align="center">Serialization</h1> 23 <h2 align="center">Proposed Case Studies</h2> 24 </td> 25 </tr> 26</table> 27<hr> 28<dl class="index"> 29 <dt><a href="#functionobject">Serializing a Function Object</a></dt> 30 <dt><a href="#archiveadaptor">Archive Adaptors</a></dt> 31 <dt><a href="#archivehelper">Archive Helpers</a></dt> 32</dl> 33 34These are not part of the library itself, but rather 35techiques on how to use the library to address specific situations. 36 37<h2><a name="functionobject"></a>Serializing a Function Object</h2> 38An example on how to serialize a function object. I believe this 39could be done by serializing a pointer to the object in question. Since 40the Serialization library resurrects a pointer of the correct type 41this should be easily implementable. 42<p> 43If a group of function objects were all derived from the 44same polymorphic base class - perhaps via multiple inheritance, 45then the function object effectively becomes a "variable" which 46encapsulates code. 47<p> 48This case study would show how to do this. 49 50<h2><a name="archiveadaptor"></a>Archive Adaptors</h2> 51 52Often users want to add their own special functionality to an 53existing archive. Examples of this are performance enhancements 54for specific types, adjustment of output syntax for xml archives, 55and logging/debug output as archives are written and/or read. 56If this functionality is implemented as an "adaptor" template 57which takes the base class as a template argument, such functionality could be 58appended to any archive for which that functionality makes sense. 59For example, an adaptor for generating an xml schema could be 60appended to both wide and narrow character versions of xml archives. 61<p> 62This case study would show how to make a useful archive adaptor. 63 64<h2><a name="archivehelper"></a>Archive Helpers</h2> 65Some types are not serializable as they stand. That is - they 66do not fulfill the requirements of the "Serializable Concept". 67The iconic example of this is boost::shared_ptr. Sometimes 68these types could be made serializable by adding code inside 69the library. Of course, doing that would create a lifetime 70of unpaid employment for the library author. Rather than 71adding a bunch of special code to the library itself, this 72code can packaged as a "helper" or "mix-in" class. Then 73a new archive is derived from both the "base" archive class 74AND the "helper" class. This is how boost::shared_ptr 75has been implemented. 76<p> 77It would also be possible to make a "generic runtime helper" 78which would effectively extend the API of the library. Previously 79the library included such a helper class. It was removed 80in favor of the current implementation. But this functionality 81should be added back in with another adaptor which would 82become part of the library. 83 84<hr> 85<p>Revised 1 November, 2008 86<p><i>© Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2008. 87Distributed under the Boost Software License, Version 1.0. (See 88accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 89</i></p> 90</body> 91</html> 92