-
Notifications
You must be signed in to change notification settings - Fork 4
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
Virtual serialization: Eliminate need to name parent class in macro arguments #138
Comments
Here's my idea. Say we have some arbitrary classes registered: A, B, C, D and we don't know what relationship they are in. We call is_base_of<A, D> = true Thus, is_base_of<B, C> = true I think the idea of dynamic_cast might also work. |
Also, this might be insane but can we do something with sizeof? |
I like the is_base_of line of thought, and we'd be able to topologically sort on the relationships if we could do it. Problem is, that's template stuff, and so we'd need a compile time list of the classes involved. Can't get that with separate compilation. I don't think there's anything to be done with sizeof |
For reference, here's the private message I sent earlier: I just had a thought on a really cheesy but seemingly workable way to handle arbitrary single-rooted multiple inheritance (I.e. semi-lattice of types). Have a registry associated with the root. Each class inserts a function into the registry that takes a |
My initial suggestion is O(c) in the number of classes in a lattice, for each serialization operation. It would be nice if we instead could memoize by having that function return true/false, and remembering which ones return true. It would cut that down to O(#ancestors), which is optimal. I don't think we can do that just once at the registry level, though, because we need actual instances in hand on which to call |
Thinking about this some more, my "some topological sorting" isn't really an answer to the serializer ordering problem. It should not be too hard to run the root before any of the others, but everything else seems much harder. |
One thought is that we could add a member |
There's another challenge I just noticed: if each class doesn't explicitly know its |
Follow-on/companion to #132.
The text was updated successfully, but these errors were encountered: