Submitted by ddiego on Fri, 2009-01-23 18:32. News and Announcements
A while ago someone in the forums asked about attributes in the VCF. Well we now have them. They are not as integrated as C#'s attributes are, but they do allow for any kind of custom arbitrary meta-data to be attached to RTTI information about a class or a class's properties. An attrbiute is defined as a name value pair, where the name is a string and the value is a VariantData object, probably representing a string most of the time. You can add them programmatically or via the RTTI macros. An example would be:
_class_rtti_(Brighten, "VCF::IKFilter", "Brighten") _attribute_(IKFilter::CategoryAttr, "Image Processing") _attribute_(IKFilter::DisplayNameAttr, "Brighten") _property_( double, "brightness", getBrightness, setBrightness, "" ); _property_attr_("brightness", IKFilter::MinAttr, 0.0 ); _property_attr_("brightness", IKFilter::MaxAttr, 1.0 ); _property_attr_("brightness", IKFilter::DefaultAttr, 0.5 ); _property_attr_("brightness", IKFilter::InputAttr, true ); _class_rtti_end_So in this case we have a class called Brighten, with an attribute called "category". We can query the ClassRegistry for any classes that have an attribute named "category", or if we have a Class instance we can query the Class for it's attributes. With property attributes we now have a way to provide things like min, max, and default values.