Feature: 'A Templated C++ Attribute Library for Object Persistence and Export'
In this in-depth technical piece, coding veteran McNickle explains how experience on the Deer Hunter series led him to create a library for managing and
![](https://eu-images.contentstack.com/v3/assets/blt740a130ae3c5d529/bltba62518415cda0e2/652fe6ddbc479f8697ef691f/default-cubic.png?width=1280&auto=webp&quality=95&format=jpg&disable=upscale)
In this in-depth technical piece, coding veteran McNickle explains how experience on the Deer Hunter series led him to create a library for managing and exporting important variables. During Deer Hunter 2003's development, McNickle found himself having to explain a reoccurring bug and the process needed to correct it whenever a new programmer would come across it: "Essentially, any time a new variable was added to the base actor class or one of its derived classes, the programmer had to manually add support in the archiving routines to persist this data. The problem was further complicated because it was not desirable to serialize all variables during a saved game, and the logic determining which variables should be serialized when was poorly understood. Questions such as 'Should the variable be saved during a saved game?', 'Should it be serialized to the network stream?' and 'Is the variable state managed by the server, or is it client authoritative?' had to be answered. They were typically understood at the time the variable was added, but when being reviewed by another programmer, the answers to these questions had to be re-discovered." Frustrated with having to repeatedly fix the problem and seeking to develop an elegant, automated, and less error-prone solution, McNickle envisioned a system fulfilling a list of specific requirements:
It must have minimal impact on the existing code.
It must be simple to expand without changing the code of the management system. In other words, it has to be generic, and it has to support complex types.
It must have a small memory footprint. (Thankfully, we were only developing for the PC, so there was some wiggle room.)
It must provide a simple, easily discernable means for the programmer who implemented the variable to state how the system and the user should interact with it, if at all. Ideally, this means could be adjusted dynamically.
It must provide a way to query an object for all of its attributes that are to be exposed or serialized and, if possible, how and when it should be serialized.
It must provide a way to automate the serialization.
It must support altering the values of these known variables.
And finally, it must not require that the value of the variable be changed through any particular mechanism, or be notified of any such change, while always being aware of the exact value of a known attribute at any time.
You can now read the full feature including source code on McNickle's solution for " A Templated C++ Attribute Library for Object Persistence and Export." (no registration required, please feel free to link to this feature from other websites).
About the Author
You May Also Like