Coder Social home page Coder Social logo

(Non)-Copyable Containers about podio HOT 8 CLOSED

aidasoft avatar aidasoft commented on July 23, 2024
(Non)-Copyable Containers

from podio.

Comments (8)

joequant avatar joequant commented on July 23, 2024

It looks promising. I ran into the same root issues you did, but it looks like that it's because something expects proxy classes that need copy constructors. It looks like once I understand the code a bit more, I can do something that can work around the problem.

from podio.

andresailer avatar andresailer commented on July 23, 2024

For why the write command gives warnings, see the comment in the test definition:

add_test(NAME write COMMAND write)
# The following directories need to be added to the LD_LIBRARY_PATH:
# - CMAKE_CURRENT_BINARY_DIR: contains the root dictionary and pcm files for TestDataModel
# - CMAKE_BINARY_DIR/src: contains the root dictionary and pcm files for podio
set_property(TEST write PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/src:$ENV{LD_LIBRARY_PATH})

from podio.

joequant avatar joequant commented on July 23, 2024

Got it. I've gotten everything to work in the base case and things to fail in the non-copyable case. I'll spend a few days looking at the error messages to give some better diagnostics when things are broken.

from podio.

joequant avatar joequant commented on July 23, 2024

Took a quick look. What the problem seems to be is that ROOT contains generic templates to convert collection classes to and from STL vectors. Once you mark the copy constructor as non-existent that fails. Also, it really should fail, since if the object is really non-copyable then bad things will happen once you copy it.

Right now, I'm digging into the code to see if I can override the behavior and cause it to throw an exception if you try to do a copy. It looks possible, but it all involves giving out the right C++magic.

from podio.

joequant avatar joequant commented on July 23, 2024

Okay here is the problem.....

  instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< vector<ex42::ExampleWithNamespaceData> >()));

The system tries to create proxies for vectors of containers, and vectors inheritly require copy constructors to put items into the vector.

It's possible to have vectors without copies using emplace_back, but not sure how this is going to work.

Ideas?

from podio.

joequant avatar joequant commented on July 23, 2024

I think the easy thing to do is to disable the creation of vectors of collections, since it doesn't make sense to have a collection of collections. Does that work?

from podio.

tmadlener avatar tmadlener commented on July 23, 2024

Because I just ran into a related problem myself:

void doSomething(const WhateverCollection collection);

vs the probably intended

void doSomething(const WhateverCollection& collection);

Both compile fine, but the former fails with a rather cryptic error message during runtime:

malloc_consolidate(): invalid chunk size

So, I think having truly non-copyable collections would be extremely nice to catch such things early.

from podio.

tmadlener avatar tmadlener commented on July 23, 2024

I think the easy thing to do is to disable the creation of vectors of collections, since it doesn't make sense to have a collection of collections. Does that work?

I think that is a sensible suggestion. And if we remove that requirement we can actually remove the copy constructor and the copy assignment operator for collections. Currently we require that a vector<Collection> is streamable with root in the selection.xml that we generate. However, as far as I can tell, this is something we really do not need, since the only things we want to store in root files is vector<Data>, since each collection goes into its own branch in any case. It is possible to significantly cut down on the contents of the selection.xml, such that in the end only the

          <class name="{{classname}}Data"/>
          <class name="{{classname}}Collection"/>

are needed for all the generated classes. Interestingly the latter is necessary for a working python interface when building with gcc, but can be omitted when building with clang (and still have working python interface).

from podio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.