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

Provide copying mechanism for frontend handles #171

Open
C0nsultant opened this issue May 14, 2018 · 1 comment
Open

Provide copying mechanism for frontend handles #171

C0nsultant opened this issue May 14, 2018 · 1 comment

Comments

@C0nsultant
Copy link
Member

C0nsultant commented May 14, 2018

As a continuation of #156, a mechanism to allow detatched copies of frontend objects (i.e. Attributables) should be provided. While it is possible to create two objects with the same parameters explicitly, it is cumbersome e.g. when assigning multiple iterations in a series with the same openPMD data and differing record data.

(Shamelessly stealing numpy's lingo with .copy() to have familiar syntax and semantics.)

Series s = Series("./out.h5", AccessType::CREATE);

Iteration i1 = s.iterations[1];

/* merely creates a view into i1
 * every modification to i1 is reflected in i2 (and vice versa) */
s.iterations[2] = i1;

/* have an independent copy of the iteration that is not merely a view
 * any modification to i1 will not be reflected in i2 (and vice versa) */
s.iterations[3] = i1.copy();
@C0nsultant
Copy link
Member Author

C0nsultant commented Jul 24, 2018

Going off of #290 (comment), I doubt we can make Attributable::copy() happen.
The user should not be able to create dangling objects at all, especially not this easily.
This problem could be avoided by copying values into an existing (non-dangling) object inside a openPMD::Series structure, e.g. with Iteration::copyTo(Iteration&).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants