The ComponentFactoryBase class is an abstract class that is used to AddInstance of a component, remove an instance of the same, get an instance from the components' list and clear out all the instances from the list.
The ComponentFactory class inherits from the ComponentFactoryBase and is templatized to contains any 'Type' of instances which are of limited 'size'. It contains the array of instances and a vector of the active components along with the active components size and the nextHandle which is a unique identifier for a component in the list.
The GameObjectFactory class is a separate class factory which operates similar to how the ComponentFactory operates but for gameobjects specifically instead of components.
The AddInstance() function searches for an open space in the list of instances and if any instance is found to be inactive it adds the new component instance there along with a new handle identifier and appends the active new component instance to the end of the activeObjects vector list. If no space found in between, it is added at the end of the list. If the activeSize is equal to the limited size allocated for the array then the factory size capacity has been exceeded and we do not add more instances to it.
The RemoveInstance() function tried to find the component in the instances list and if it is found the data is cleared from the instances list at that position and is removed from the activeObjects vector.