<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _register_factory(self, factory_name, factory, override):
 # type: (str, type, bool) -> None """ Registers a component factory :param factory_name: The name of the factory :param factory: The factory class object :param override: If true, previous factory is overridden, else an exception is risen if a previous factory with that name already exists :raise ValueError: The factory name already exists or is invalid :raise TypeError: Invalid factory type """

        if not factory_name or not is_string(factory_name):
            raise ValueError("A factory name must be a non-empty string")

        if not inspect.isclass(factory):
            raise TypeError(
                "Invalid factory class '{0}'".format(type(factory).__name__)
            )

        with self.__factories_lock:
            if factory_name in self.__factories:
                if override:
                    _logger.info("Overriding factory '%s'", factory_name)
                else:
                    raise ValueError(
                        "'{0}' factory already exist".format(factory_name)
                    )

            self.__factories[factory_name] = factory

            # Trigger an event
            self._fire_ipopo_event(
                constants.IPopoEvent.REGISTERED, factory_name
            )