Adapter or Bridge will do the trick. Exactly how you do it depends on what you're trying to adapt or bridge. If you're trying to just expose a few methods and they've got the right interface already then bridge works pretty well. If you want to expose some methods and their signatures are not quite the right shape then use an Adapter.
As Eric said proxy will work as well - although that's usually regarded as a way of exporting an interface over some "hostile" or non-native way of calling it. It's like a bridge but across an external communication mechanism.
Anyway:
- bridge introduces another interface with just the methods in you want to export from the object. You then derive your implementation from the interface and pass a reference to that interface to the consuming object
- adapter introduces a concrete class with the interface you want to consume. You implement that interface using the class to be adapted. You can introduce an interface class to really isolate the adapted class from the consuming class - whether you do that or not is really a matter of taste and how much knowledge of the implementation you're willing to leak across the consumer/adapter boundary
With bridge you'll have to change the class you're bridging to. With adapter you won't. Generally I'd say what you want is an adapter BUT a bridge will help introduce a new concept into your code which will make it easier to factor.
Er, sorry, that's really stream of consciousness isn't it? Please shout if I can (or rather if you'd like me to) clarify anything.
Cheers,
Ash
PS: Most of my experience of this sort of thing has been with C++ so my comments might not be appropriate in general OO terms.
PPS: In response to the comment below, here's what I mean about how to use a bridge. Say I've got a class, A, that uses part of the interface of object of class B:
class B
{
public:
void b_a();
void b_b();
void b_c();
};
class A
{
public:
void a_a( B &b )
{
b.b_a();
b.b_c();
}
};
so you can see that A doesn't use B::b_b(). Effectively it doesn't need some part of the interface of B.
So to restrict what bits of B A uses we can define a new interface (the bridge solution):
class I
{
public:
virtual void b_a() = 0;
virtual void b_c() = 0;
};
derive B from I:
class B : public I
{
public:
void b_a();
void b_b();
void b_c();
};
and convert A to use I, not B:
class A
{
public:
void a_a( I &i )
{
i.b_a();
i.b_c();
}
};
So everytime you call the A::a_a you can still pass it a B, but A can't use B::b_b() as it's not part of the interface.
Using an adapter is similar, I can add that if there's any milage.