Registry 用法
Interface implementations stored at a registry are used by accessing the component class with the given maxon::Id from the registry. Then it is possible to create a reference class instance to use the implementation.
Registries are based on the maxon::Registry class. A given element stored in a registry is identified with a maxon::Id .
// get the class with the given Id from the registry "ColorClasses" const maxon::Id redID { "net.maxonexample.class.colors.red" }; const maxon::Class<ColorRef> * const componentClass = ColorClasses::Find(redID);
// create reference object const ColorRef color = componentClass->Create() iferr_return ;
// use reference object
One can also simply loop through all elements with maxon::Registry::GetEntries() :
// This example loops through all component classes known to the given registry. for ( const auto & it : ColorClasses::GetEntries()) { // get class const maxon::Class<ColorRef> & componentClass = it;// create reference object const ColorRef color = componentClass.Create() iferr_return ;
// use reference object const maxon::Id & eid = it.GetId(); const maxon::String colorName = color.GetName(); const maxon::Color32 colorRGB = color.GetRGB(); DiagnosticOutput ( "ID: @" , eid); DiagnosticOutput ( "Color Name: @" , colorName); DiagnosticOutput ( "Color RGB: @" , colorRGB); }