C++ Blog

Java Style Dynamic Proxy in C++

Posted in c++0x by Umesh Sirsiwal on January 9, 2009

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?

Advertisements
Tagged with: , , ,

One Response

Subscribe to comments with RSS.

  1. C++ Proxy Template « C++ Blog said, on January 14, 2009 at 3:16 am

    […] 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 […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: