Increasing usage for C++ new operators based on data model indexes?
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
I imagine that additional software design options can be relevant here.
I haven't seen any better solution ever in my life
The ownership information can be managed also by other means, can't it?
Yes but as I said it becomes unclear. How can you assure a slot connected to, for example,
dataChanged
is not accessing memory the owner already deleted?“Data copies” are returned for each possible role.
And this is the key point you don't understand. Qt uses a very cheap copy method (the implicit sharing) that is a basically a fancy
std::shared_ptr
. Copying by value astd::shared_ptr
does not copy the data pointed by it.
This covers any native and almost all Qt classes. Copying any of them by value has performance not significantly different from copying a pointer to those classes. Qt also give you the tools to apply that technology to your classes.
This means that all operations that you call “Data copies” are actually copying a pointer (ormemcpy
up to 64 bits for native types) and adding 1 to a reference counter. As discussed above smart pointers and reference counters are the direction modern C++ is moving to.You can still think the "good old way" was better and that's fine but that can't influence the design of other projects that decide to go the "modern way"
-
And this is the key point you don't understand.
I got special software development views around the handling of data copies.
… that can't influence the design of other projects that decide to go the "modern way"
I find that it can be more important to distinguish an other design aspect than “software modernisation” here.
I would occasionally like to get direct access to some memory locations also by the general programming interface of data models.The class “std::shared_ptr” supports the member functions “get” and “operator[]”.
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
Will software libraries evolve further around the suggestion “Add support for usage of placement new together with data model indexes”?
No they will not.
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
Why do you think in this direction?
Experience.
-
Does your software development experience include the usage of
QAbstractItemModel
?My knowledge is growing also in this software area.
… he's firmly in the top tier of developers contributing on this forum.
This is fine.
Our experiences are varying in several areas, don't they?
Understanding difficulties can happen then when someone (like me) dares to present special development ideas.
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
Understanding difficulties can happen then when someone (like me) dares to present special development ideas.
Sorry if it came out wrongly before, we are not against new development ideas at all, not on this forum and not in the Qt Project.
I think what is clear from the discussion above is that nobody here can think of an elegant, efficient, functional and safe way to introduce the concept you suggest in the
QAbstractItemModel
(or any of its subclasses) interface.
Having said that, you are correct by sayingOur experiences are varying in several areas, don't they?
So our point is, if you have an idea for an implementation then please go ahead and propose it to the community. I'd be very happy to participate in the review process of such an innovation as well as I might end up learning something new (punt not intended)
-
The project maintainers are seasoned (15-20 years experience) developers and are familiar with all aspects of standard C++ (especially its oldest parts like placement new).
It's safe to assume a total mastery of the placement new concept by people reviewing code, don't worry
-
It's safe to assume a total mastery of the placement new concept by people reviewing code, don't worry
This information is very promising.
- Unfortunately, I could not extract corresponding indications of understanding for my proposal so far.
- How would you like to clarify a possible mapping from data model indexes to pointers further?
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
How would you like to clarify a possible mapping from data model indexes to pointers further?
That's what we are asking you to propose.
We can't think of a way unfortunately -
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
Unfortunately, I could not extract corresponding indications of understanding for my proposal so far.
Because you have not proposed anything. Show an API and it will be judged. Show a usage example of that API and it will help us know if the API is convenient. Measure with benchmark and we'll know if it improves performance.
Without concrete foundations, any idea can be argued endlessly without result.
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
We can't think of a way unfortunately
Why do you stumble on limitations in your imaginations here?
I guess that will depend on this basic clarification:
Are you familiar with the usage of placement new? -
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
Why do you stumble on limitations in your imaginations here?
Honestly I just think I'm not smart enough to get into this. It wouldn't be the first time. On the other hand I'd be really happy to see how it could be implemented so I could learn something new
-
@elfring said in Increasing usage for C++ new operators based on data model indexes?:
Can this application programming interface be just “placement new” (which got the parameters “row” and “column” passed)?
See, I struggle already, what would the return type be? (
void*
is a bit useless...)