Introduced registerFactory

registerFactory works like registerType(delegate). The difference
is,
the delegate returns a shared_ptr to the created object