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

[Core] Dump ObjectFactory in json #4775

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

Conversation

alxbilger
Copy link
Contributor

@alxbilger alxbilger commented Jun 12, 2024

The prettyfied output of the unit test:

[
  {
    "className": "DefaultAnimationLoop",
    "creator": {
      "": {
        "class": {
          "className": "DefaultAnimationLoop",
          "namespaceName": "sofa::simulation",
          "shortName": "defaultAnimationLoop",
          "templateName": "",
          "typeName": "DefaultAnimationLoop"
        },
        "object": {
          "data": [
            {
              "group": "",
              "help": "object name",
              "name": "name"
            },
            {
              "group": "",
              "help": "if true, emits extra messages at runtime.",
              "name": "printLog"
            },
            {
              "group": "",
              "help": "list of the subsets the objet belongs to",
              "name": "tags"
            },
            {
              "group": "",
              "help": "this object bounding box",
              "name": "bbox"
            },
            {
              "group": "",
              "help": "The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).",
              "name": "componentState"
            },
            {
              "group": "",
              "help": "if true, handle the events, otherwise ignore the events",
              "name": "listening"
            },
            {
              "group": "",
              "help": "If true, compute the global bounding box of the scene at each time step. Used mostly for rendering.",
              "name": "computeBoundingBox"
            },
            {
              "group": "",
              "help": "If true, solves all the ODEs in parallel",
              "name": "parallelODESolving"
            }
          ],
          "link": [
            {
              "help": "Graph Node containing this object (or BaseContext::getDefault() if no graph is used)",
              "name": "context"
            },
            {
              "help": "Sub-objects used internally by this object",
              "name": "slaves"
            },
            {
              "help": "nullptr for regular objects, or master object for which this object is one sub-objects",
              "name": "master"
            },
            {
              "help": "Link to the scene's node that will be processed by the loop",
              "name": "targetNode"
            }
          ]
        },
        "target": ""
      }
    },
    "description": "foo\n"
  }
]

and the templated object:

[
  {
    "className": "DummyComponent",
    "creator": {
      "Vec3f": {
        "class": {
          "categories": [
            "_Miscellaneous"
          ],
          "className": "DummyComponent",
          "namespaceName": "sofa",
          "parents": [
            "BaseObject"
          ],
          "shortName": "dummyComponent",
          "templateName": "Vec3f",
          "typeName": "DummyComponent\u003CStdVectorTypes\u003CVec\u003C3,float\u003E,Vec\u003C3,float\u003E,float\u003E\u003E"
        },
        "object": {
          "data": [
            {
              "defaultValue": "unnamed",
              "group": "",
              "help": "object name",
              "name": "name",
              "type": "string"
            },
            {
              "defaultValue": "0",
              "group": "",
              "help": "if true, emits extra messages at runtime.",
              "name": "printLog",
              "type": "bool"
            },
            {
              "defaultValue": "",
              "group": "",
              "help": "list of the subsets the objet belongs to",
              "name": "tags",
              "type": "TagSet"
            },
            {
              "defaultValue": "",
              "group": "",
              "help": "this object bounding box",
              "name": "bbox",
              "type": "BoundingBox"
            },
            {
              "defaultValue": "Undefined",
              "group": "",
              "help": "The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).",
              "name": "componentState",
              "type": "ComponentState"
            },
            {
              "defaultValue": "0",
              "group": "",
              "help": "if true, handle the events, otherwise ignore the events",
              "name": "listening",
              "type": "bool"
            }
          ],
          "link": [
            {
              "help": "Graph Node containing this object (or BaseContext::getDefault() if no graph is used)",
              "name": "context"
            },
            {
              "help": "Sub-objects used internally by this object",
              "name": "slaves"
            },
            {
              "help": "nullptr for regular objects, or master object for which this object is one sub-objects",
              "name": "master"
            }
          ]
        },
        "target": ""
      }
    },
    "description": "foo\n"
  }
]

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).

@alxbilger alxbilger added the pr: status to review To notify reviewers to review this pull-request label Jun 12, 2024
@hugtalbot hugtalbot added the pr: new feature Implement a new feature label Jun 12, 2024
@damienmarchal
Copy link
Contributor

Additional info to have:

  • the data type using getValueTypeString()
  • if it is input or output (for DataEngines)

@alxbilger
Copy link
Contributor Author

  • if it is input or output (for DataEngines)

Isn't it defined by the group string? Input Data have the group "Inputs", and output "Outputs"

@damienmarchal
Copy link
Contributor

damienmarchal commented Jun 12, 2024

  • if it is input or output (for DataEngines)

Isn't it defined by the group string? Input Data have the group "Inputs", and output "Outputs"

I would say that being an input is because the Data has been added with DataEngine::addInput ... the fact it is in the group "Inputs" is just an UX choice.

@alxbilger
Copy link
Contributor Author

@damienmarchal How can I get the information that a Data is an input or not?

@hugtalbot
Copy link
Contributor

up @damienmarchal

@alxbilger
Copy link
Contributor Author

alxbilger commented Jun 19, 2024

TODO: add parent classes + eventually category + add a test with a template

@damienmarchal
Copy link
Contributor

The status indicating if it is input or output is not hard coded in the data structure.
During the STC it was decided that we should have it. Several category of inputs have been decided: input, output, input-and-output, unknow (see the STC reports for the precise naming). To me the easiest is to export everything with the "unknow" type (which indicate ... the "we don't know exactly" current state. As you pointed for DataEngine, you can then use the fact a data is part of the "Input" / "Output"... but it is only an heuristic. It is possible to have better heuristic... eg: detecting through the DDG superclass of a data field if this data is an input in an update callback.... but I think this is too complex... and purposeless given that the information should be added (soon) in BaseData.

@alxbilger
Copy link
Contributor Author

TODO: add type of Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature Implement a new feature pr: status to review To notify reviewers to review this pull-request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants