Brian Silverman | 8867871 | 2018-08-04 23:56:48 -0700 | [diff] [blame^] | 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 . |
| 5 | Use, modification and distribution is subject to the Boost Software |
| 6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | http://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 | |
| 34 | These are not part of the library itself, but rather |
| 35 | techiques on how to use the library to address specific situations. |
| 36 | |
| 37 | <h2><a name="functionobject"></a>Serializing a Function Object</h2> |
| 38 | An example on how to serialize a function object. I believe this |
| 39 | could be done by serializing a pointer to the object in question. Since |
| 40 | the Serialization library resurrects a pointer of the correct type |
| 41 | this should be easily implementable. |
| 42 | <p> |
| 43 | If a group of function objects were all derived from the |
| 44 | same polymorphic base class - perhaps via multiple inheritance, |
| 45 | then the function object effectively becomes a "variable" which |
| 46 | encapsulates code. |
| 47 | <p> |
| 48 | This case study would show how to do this. |
| 49 | |
| 50 | <h2><a name="archiveadaptor"></a>Archive Adaptors</h2> |
| 51 | |
| 52 | Often users want to add their own special functionality to an |
| 53 | existing archive. Examples of this are performance enhancements |
| 54 | for specific types, adjustment of output syntax for xml archives, |
| 55 | and logging/debug output as archives are written and/or read. |
| 56 | If this functionality is implemented as an "adaptor" template |
| 57 | which takes the base class as a template argument, such functionality could be |
| 58 | appended to any archive for which that functionality makes sense. |
| 59 | For example, an adaptor for generating an xml schema could be |
| 60 | appended to both wide and narrow character versions of xml archives. |
| 61 | <p> |
| 62 | This case study would show how to make a useful archive adaptor. |
| 63 | |
| 64 | <h2><a name="archivehelper"></a>Archive Helpers</h2> |
| 65 | Some types are not serializable as they stand. That is - they |
| 66 | do not fulfill the requirements of the "Serializable Concept". |
| 67 | The iconic example of this is boost::shared_ptr. Sometimes |
| 68 | these types could be made serializable by adding code inside |
| 69 | the library. Of course, doing that would create a lifetime |
| 70 | of unpaid employment for the library author. Rather than |
| 71 | adding a bunch of special code to the library itself, this |
| 72 | code can packaged as a "helper" or "mix-in" class. Then |
| 73 | a new archive is derived from both the "base" archive class |
| 74 | AND the "helper" class. This is how boost::shared_ptr |
| 75 | has been implemented. |
| 76 | <p> |
| 77 | It would also be possible to make a "generic runtime helper" |
| 78 | which would effectively extend the API of the library. Previously |
| 79 | the library included such a helper class. It was removed |
| 80 | in favor of the current implementation. But this functionality |
| 81 | should be added back in with another adaptor which would |
| 82 | become 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. |
| 87 | Distributed under the Boost Software License, Version 1.0. (See |
| 88 | accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 89 | </i></p> |
| 90 | </body> |
| 91 | </html> |