MetaInfo is used to easily store information of any type, that does not fit into the the other classes. It implements type-name-value triplets. The main datastructure is an associative container that stores DataValue instances as values associated to string keys. Internally, the string keys are converted to integer keys for performance resaons i.e. a map<UInt,DataValue> is used.
The MetaInfoRegistry associates the string keys used in MetaValue with the integer values that are used for internal storage. The MetaInfoRegistry is a singleton.
If you want a class to have a MetaInfo member, simply derive it from MetaInfoInterface. This class provides a MetaInfo member and the interface to access it.
The classes involved in meta information storage
The following example (Tutorial_MetaInfo.C) shows how to use Metadata. We can simply set values for the string keys, and setMetaValue registers these names automatically. In order to access the values, we can either use the registered name or the index of the name. The getMetaValue method returns a DataValue, which has to be casted to the right type. If you do not know the type, you can use the DataValue::valueType() method.
Int main() { MetaInfoInterface info; //insert meta data info.setMetaValue("color",String("#ff0000")); info.setMetaValue("id",112131415); //access id by index UInt id_index = info.metaRegistry().getIndex("id"); cout << "id : " << (UInt)(info.getMetaValue(id_index)) << endl; //access color by name cout << "color: " << (String)(info.getMetaValue("color")) << endl; return 0; } //end of main
Map meta information
Spectrum meta information
Generated Tue Apr 1 15:36:40 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |