In one of my projects, I'm using the following pattern at several places: I have a class A
with a bunch of methods, and class B
which gets constructed with a pointer to some instance of A
, exporting only a subset of those methods for a user (which is not the owner of the A
instance).
class A
{
public:
void doStuff();
void doOtherStuff();
void doYetOtherStuff();
B getB()
{
return B(this);
}
};
class B
{
friend class A;
public:
void doStuff()
{
_a->doStuff();
}
void doOtherStuff()
{
_a->doOtherStuff();
}
private:
B(A* a) : _a(a) {}
A* _a;
};
An instance of A
could be created by my library, for example, and a created instance of B
(associated with an A
) could be passed to a plugin, which will still have access to the A
instance, albeit in a limited way.
I'm just confused regarding the design pattern name of B
: is it a façade, a bridge, an adapter or a proxy? Or something else?