Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of singletons #3770

Open
alxbilger opened this issue Apr 6, 2023 · 2 comments
Open

Get rid of singletons #3770

alxbilger opened this issue Apr 6, 2023 · 2 comments
Labels
STC#15 Tasks for STC#15 coding sprint

Comments

@alxbilger
Copy link
Contributor

I propose to avoid relying on some singletons. The first I have in mind is sofa::simulation::getSimulation and setSimulation. It prevents to run two simulations in the same program (or only in a limited manner).

@alxbilger alxbilger added the STC#15 Tasks for STC#15 coding sprint label Apr 6, 2023
@fredroy
Copy link
Contributor

fredroy commented May 25, 2023

An other big singleton to refactor is ObjectFactory.
Especially bothering because its getInstance() is called in the RegisterObject function, which is called when the library is loaded.
One solution would be to move those RegisterObject() into the plugin initialisation (where it has been given a pointer to the ObjectFactory). The drawbacks are:

  • cumbersome
  • the init's plugin file would need all the headers of the components it need to register.

@fredroy
Copy link
Contributor

fredroy commented May 25, 2023

Other significant singletons:

  • message mechanism (dispatchers/handlers),
  • idFactory from timers
  • Factories (contact, intersectors)
  • scheduling (TaskScheduler, registry)
  • scene loaders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STC#15 Tasks for STC#15 coding sprint
Projects
None yet
Development

No branches or pull requests

2 participants