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

[All] Refactor create/cancreate in ObjectFactory #5195

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

damienmarchal
Copy link
Contributor

This topic has been addressed in a lot of previous postpone PR.

In this one I propose an approach which has a compatibility layer to be not breaking.

The important code is in ObjectFactory.h
All the rest is just there to point where are the "yet to fix" components.


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 damienmarchal added pr: status wip Development in the pull-request is still in progress pr: status to review To notify reviewers to review this pull-request and removed pr: status wip Development in the pull-request is still in progress labels Jan 8, 2025
@alxbilger
Copy link
Contributor

@damienmarchal in case you missed them, there are some compilation errors

@@ -260,13 +290,51 @@ class ObjectCreator : public ObjectFactory::Creator
public:
bool canCreate(objectmodel::BaseContext* context, objectmodel::BaseObjectDescription* arg) override
{
RealObject* instance = nullptr;
return RealObject::canCreate(instance, context, arg);
if constexpr( HasCanCreateMethod<RealObject>::value )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can now use a concept. I would look like:

if constexpr (requires { RealObject::canCreate; })

@damienmarchal
Copy link
Contributor Author

Thank @alxbilger for pointing the compilation error.

@hugtalbot hugtalbot added the refactoring Refactor code label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: status to review To notify reviewers to review this pull-request refactoring Refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants