[docs]classObjectCommon:""" Object common class. """objs={}def__init__(self,config:ObjectConfig):self._config=configdefset_up_scene(self,scene:Scene):raiseNotImplementedError
[docs]@classmethoddefregister(cls,name:str):""" Register an object class with the given name(decorator). Args: name(str): name of the object """defdecorator(object_class):cls.objs[name]=object_class@wraps(object_class)defwrapped_function(*args,**kwargs):returnobject_class(*args,**kwargs)returnwrapped_functionreturndecorator
[docs]defcreate_object(config:ObjectConfig):""" Create an object. Args: config (ObjectConfig): configuration of the objects """assertconfig.typeinObjectCommon.objs,'unknown objects type {}'.format(config.type)obj:ObjectCommon=ObjectCommon.objs[config.type](config)returnobj