Replies: 1 comment 8 replies
-
Hi @jeanga, Thanks for the thoughtful write‑up. If I'm reading it right, you want Recommended approach: make Make // Forward declare a template that depends on the facade F (can be TypeFacade)
template <class F>
struct Array;
template <class F>
using AsArrayOverload = pro::proxy_view<Array<F>>() const;
struct TypeFacade : pro::facade_builder
/* ... other skills/conventions ... */
::add_convention<MemAsArray, pro::facade_aware_overload_t<AsArrayOverload>>
/* ... */
::build {};
template <class F>
struct Array : pro::facade_builder
::add_convention<MemCount, size_t() const>
::add_convention<MemArrayOf, const pro::weak_proxy<F>& () const>
::build {}; In this setup, Alternative: keep Array concrete and introduce a dependent type If you prefer Minimal utility (I have this in my personal metaprogramming library): template <class T, class... D>
struct dependent_trait : std::type_identity<T> {};
template <class T, class... D>
using dependent_t = typename dependent_trait<T, D...>::type; Keep template <class F>
using AsArrayOverload = pro::proxy_view<dependent_t<Array, F>>() const; This keeps Note that the alternative requires moving the BTW, since Hope this helps unblock your design. If there's anything missing or you want to dig deeper, happy to discuss more! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have successfully migrated most of my project's interfaces (thank you so much! proxy rocks!).
With one last area to migrate, I am stumbling on the difficulty that proxy won't allow circular dependencies in facade definition.
While it's trivial to describe and implement with pure virtual interfaces and forward declarations, with proxy, this appears more challenging. I have managed to have "something" but I'm not sure it's the right way to proceed with proxy (i.e. should I stick to pure virtual interfaces in that context if this is orthogonal to proxy's philosophy).
Here is a simplified version of what I am trying to achieve:
Here is the facade definitions I tried:
A core type façade with no dependency!
The array facade is:
So far so good 😄
The problem arises when I need to explore the ArrayOf type for specific information.
In that context, I need to "upgrade" my CoreTypeFacade to the full type facade:
I had to split Type facade definitions (in CoreTypeFacade & TypeFacade) because I could not define SubTypeFacade with the TypeFacade as it has a circular definition.
(no "forward" declaring of proxies for very good reason).
For performance reasons, I can't lookup the dictionary with type names or "type ids".
When it starts to be complicated, on the implementation side, to be able to "upgrade" CoreTypeWeak into a full TypeFacade proxy I had to "hack" the following :
All concrete type implementing TypeFacade inherit TypeAware:
Which allows to implement free functions to "upgrade" CoreTypeWeak into a TypeView:
It works fine and I achieve decent performance (esp. this design avoids RTTI lookups for each "upgrade", only one at type creation which is ok). What I'm really not sure is that proxy may have better patterns for me to implement this type system in a different facade /proxy design.
If you are interested, a "sample" I crafted to explore my options :
type_proxy.zip
Of course, a perfectly valid conclusion to this could also be: stick to pure virtual interfaces and dynamic_pointer_cast... (somewhat disapointing but valid 😁)
Thanks for reading up to here !
Beta Was this translation helpful? Give feedback.
All reactions