def __init__(self, name, instance_class, instr_type, results_type): if not issubclass(instance_class, Transition): raise TypeError Named.__init__(self, name) self.__instance_class = instance_class require_disjoint(instr_type, results_type) self.__instructions_type = SimpleType(instr_type) self.__results_type = SimpleType(results_type)
def __init__(self, name, instance_class, id_type, state_type, global_reader=None): """ Build a ResouceType. name is the name that can be used to look us up once we are registered. instance_class is the class that will be used to create Resources of this type. It must be a subclass of ResourceBase. id_type is the dictionary of AttrType from which we will build our identity type. state_type is like id_type for our state type. global_reader is a function that reads the current system state, if passed identity attributes. """ if not issubclass(instance_class, ResourceBase): raise TypeError Named.__init__(self, name) self.__instance_class = instance_class require_disjoint(id_type, state_type) self.__id_type = SimpleType(id_type) self.__state_type = SimpleType(state_type) self.__global_reader = global_reader