When designing classes in object-oriented programming languages, one has to distinguish between intrinsic properties which are inherent to the modelled entity, and data which is associated with the entity. For example, a triangle is intrinsically defined by three disjoint points, while associated data can be color or texture information in graphical applications, or material properties for two-dimensional scientific simulations.
While associated data depends on the respective application, intrinsic properties do not. Therefore, when designing reusable classes, associated data must not be part of the class itself. Reconsidering the example of a triangle, a class member for color information would immediately result in a potentially significant overhead for scientific simulations and thus reduce the reuseability of the class. However, the color information for the triangle still has to be accessible for graphical applications. This is where ViennaData comes into play, because it provides a convenient means to store and access associated data for small, reusable classes with intrinsic data members only.
As an example, suppose there exists a minimalistic class for triangles called Triangle, which provides access to its vertices. For objects of this triangle class, color information modelled by a class RGBColor should be stored within some application. The following lines accomplish that for a triangle object tri using ViennaData:
Data is associated with objects by keys of user-defined type in ViennaData. In the example above, the color information is stored using a key "color" of type std::string. However, the user is free to use any key of any type that fulfill the LessThan-Comparable concept. Thus, any associated data object data of a generic type DataType can be stored and accessed for an object of any type using a key key of type KeyType
ViennaData is available under the MIT License.