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

How to returns the name of the upper object? #1467

Closed
3038922 opened this issue Jan 30, 2019 · 2 comments
Closed

How to returns the name of the upper object? #1467

3038922 opened this issue Jan 30, 2019 · 2 comments

Comments

@3038922
Copy link

3038922 commented Jan 30, 2019

{
    "chassis": {
        "motor": {
            "left": {
                "prot": 1,
                "isRevase": false,
                "gear": 1
            },
            "right": {
                "prot": 2,
                "isRevase": true,
                "gear": 1
            },
        },
}
init()
{
 json data;
Motor left(data["chassis"]["motor"]["left"]);
Motor rigjt (data["chassis"]["motor"]["right"]);
}
class Motor
{
   Moror(json pragma):port(pragma["port"]),isRevase(pragma["isRevase"]),gear(pragma["gear"])
{
 name =???//i want get the motor's upper object ->" left" or "right"
}
std::string name;
};
@gregmarr
Copy link
Contributor

There is no way to do this from within the library. You will need to pass that data into the Motor constructor yourself.

@3038922
Copy link
Author

3038922 commented Jan 30, 2019

There is no way to do this from within the library. You will need to pass that data into the Motor constructor yourself.

thank you

@3038922 3038922 closed this as completed Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants