sofa icon indicating copy to clipboard operation
sofa copied to clipboard

[Sofa.Core] Implements a template deduction system in the object factory

Open damienmarchal opened this issue 1 year ago • 16 comments

Currently canCreate is used for several things, one of the most common use is to implement template type deduction.

On this PR we implement a mechanism that will allow to separate the type deduction to actual possibilities of creation of the component.


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

damienmarchal avatar Jun 09 '23 13:06 damienmarchal

So, if I understand correctly, you implemented 2 methods to deduce the template: 1) a static method in the component, 2) an additional line when registering in the object factory.

Yes, despite it is possible to have only the system with the static method I find the explict method more clear despite it does not allow to cover the same set of feature. We may remove it if needed.

damienmarchal avatar Jun 14 '23 09:06 damienmarchal

[ci-build][with-scene-tests]

damienmarchal avatar Jun 15 '23 07:06 damienmarchal

@alxbilger do you want me to remove the approach based on explicit registration so that there is only one single way of doing that ?

damienmarchal avatar Jun 16 '23 11:06 damienmarchal

Do you consider that this PR supersedes https://github.com/sofa-framework/sofa/pull/3309 ?

alxbilger avatar Jun 16 '23 13:06 alxbilger

You mean in term of what priority for merging ?

damienmarchal avatar Jun 16 '23 13:06 damienmarchal

I mean they both solve the same problem using different approaches, right?

alxbilger avatar Jun 16 '23 13:06 alxbilger

Not exactly, the first is about refactoring canCreate and create while the other is about providing a system for template deduction. It seems connected because canCreate is widely used to implement template deduction (but it is not its sole purpose). If template deduction is merged this will remove a lot of canCreate... but some may still. So some ideas in #3309 may still have values independently of #3938.

damienmarchal avatar Jun 16 '23 13:06 damienmarchal

[ci-build][with-all-tests]

hugtalbot avatar Jun 28 '23 08:06 hugtalbot

@hugtalbot do we move forward on that one ?

damienmarchal avatar Jun 29 '23 09:06 damienmarchal

@bakpaul as you set it to wip can you elaborate what should be done.

damienmarchal avatar Jul 26 '23 09:07 damienmarchal

@damienmarchal yes, we should schedule a discussion between you, alex, us (Hugo and/or me) and anyone interested, but outside the sofa dev meeting to come to a solution.

bakpaul avatar Jul 26 '23 10:07 bakpaul

Thank for the answer...can you explain a solution to which problem ?

damienmarchal avatar Jul 26 '23 10:07 damienmarchal

To the related discussions (#3938, #3987 & #3990). This is a big subject and it has been concluded that it would require more direct discussions to come to a agreement.

bakpaul avatar Jul 26 '23 10:07 bakpaul

I set it back to review... otherwise we forgot to discuss about it at code review.

damienmarchal avatar Sep 06 '23 13:09 damienmarchal

We had a meeting planed to discuss this along with @bakpaul @alxbilger but your did not show up @damienmarchal I think we should discuss it as planed separately from the SOFA dev meeting:

  • #2712
  • #3938
  • #3987
  • #3990

hugtalbot avatar Sep 06 '23 14:09 hugtalbot

I may also add two related old pr to the list, they are on the refactoring of create and canCreate methods :

  • #3309
  • #3311

bakpaul avatar Sep 06 '23 14:09 bakpaul