Exemplo n.º 1
0
 def _f(cls: Type):
     # reg for conf
     _m = BasicConf._CONF_MAP
     _k = get_class_id(cls, use_mod=True)
     assert _k not in _m
     _m[_k] = conf_type
     # reg for node
     _m2 = BasicConf._NODE_MAP
     _k2 = get_class_id(conf_type, use_mod=True)
     if _k2 not in _m2:  # note: reg the first one!!
         _m2[_k2] = cls
     # --
     return cls
Exemplo n.º 2
0
 def register_inst(self,
                   inst: DataInstance,
                   sname_prefix: str = None):  # register
     inst_id = inst.id
     if sname_prefix is None:
         sname_prefix = get_class_id(inst.__class__)
     new_id = self._indexer.register(inst_id, inst, sname_prefix)
     if inst_id is None:  # also set the new id
         inst.set_id(new_id)
Exemplo n.º 3
0
 def get_sub_map(cls) -> Dict[str, SubInfo]:
     _map = DataInstance._InstSubMaps
     k = get_class_id(cls, use_mod=True)
     if k not in _map:
         r = {}
         for cl in reversed(cls.__mro__):  # collect in reverse order
             if issubclass(cl, DataInstance) and hasattr(
                     cl, "_get_sub_map"):
                 r.update(cl._get_sub_map())
         _map[k] = r
     return _map[k]
Exemplo n.º 4
0
 def get_node_type(cls: Type, df):
     _k = get_class_id(cls, use_mod=True)
     return BasicConf._NODE_MAP.get(_k, df)
Exemplo n.º 5
0
 def get_conf_type(cls: Type, df):
     _k = get_class_id(cls, use_mod=True)
     return BasicConf._CONF_MAP.get(_k, df)