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
Inheritance in components #19
Comments
Could you please provide more information on your use case? Let's start with:
|
Production code. What's missing, however, is the diamond. It technically looks like this. struct InterfaceParent {};
struct ImplParent : virtual InterfaceParent {};
fruit::Component<InterfaceParent> getParent() {
return fruit::createComponent()
.install(...)
.install(...)
.install(...)
.bind<InterfaceParent, ImplParent>();
}
struct InterfaceChild : virtual InterfaceParent {};
struct ImplChild : InterfaceChild, ImplParent {};
fruit::Component<InterfaceChild> getChild() {
return fruit::createComponent()
.useInstallsFrom(getParent()) // ??? is it possible to do something like this?
.bind<InterfaceChild, ImplChild>();
}
No, the parent is standalone, and can itself be injected. In this case, it's ImplParent that's used.
Only used there. It's supposedly an implementation detail.
I've never done UML, sorry. To summarize a bit on the issue, I'll take a real-world use case. Let's say I have a "BaseModel" interface. It has a "BaseModelImpl". (Which it binds to. The impl is obviously an implementation detail). That's for the library part. Now, I want to extend it in my application, and I'd like to have a Since we don't want to redefine every single method that |
Since the user of such a library (who writes TimestampableModelImpl) needs to have access to the definition of BaseModelImpl (not just to have access to a BaseModel object that happens to be a BaseModelImpl) BaseModelImpl must be exposed in the library's public interface, you can't just hide that definition in a cpp file as you'd normally do with *Impl classes when using Fruit. You could do sth like:
Does this structure achieve what you want? |
Ugh, sorry. I thought we followed up on this. We went with your suggestion in the end, and it's worked well. You can close this issue. |
Ok, happy to know that it worked for you. Closing this then. |
Hi,
At times we have sub-classes of our components. Is it possible to "pull" the installs from another component? Example:
The text was updated successfully, but these errors were encountered: