Jan 9, 2009 by Umesh
Java Style Dynamic Proxy in C++
This post defines C++ template based implementation for C++ proxy.
I recently came across Java’s proxy object. That is some cool technology. Using this one can wrap one object in another object in a completely typesafe way. From user’s point of view, the proxy object looks something like:
ProxiedObjectInterface obj = (ProxiedObjectInterface)ProxyCreator.newInstance( proxiedObject );
More details on proxy object are available here.
Since the interface exposed is of the proxied type, all calls to obj are typsef and can be checked by compiler. In java ProxyCreator class does not need to know anything about proxied object. This makes it very powerful.
I have been wondering if there is any easy way to create a similar facility in C++. I cannot think of one right away. I know we can do some cool things with template meta-programming. What will that be?
[...] Proxy Template Posted in templates by Umesh Sirsiwal on January 14th, 2009 Earlier we had discussed Java Proxy class and had looked for ways to develop similar facility with C++. It turns out there [...]