When speaking about attribute lists I mean a generic list which stores additional information for a class.
The simplest case:
A class has a std::map<std::string, std::string>
. The first string names the attribute (like "Color"
), the second string describes the value (like "Yellow"
).
In this example another class which uses these attributes needs to check if a certain attribute-name is existing in the map and then parse the value.
However this isn't the best concept when talking about performance.
How would you implement such an attribute list?
Are there any design patterns or libraries which just do something like that?
I'm especially interested in a C++-way of doing this, but if there are language-independant solutions, please post them too.
An attribute list could be used in cases where a class needs to have dynamic attributes and the user does not want to inherit for each attribute.
If that helps, you could check my other question relating to that topic:
Attributelists or inheritance jungle?
EDIT:
Of course I forgot some information (thanks to the comments):
The attributes could be applied to objects. There could be different attributes for objects of the same class. The attributes an object has can change (the value can change, there could be attributes added/removed)
Hope this clearifies it a bit.