views:

116

answers:

2

Hi! I'm curious how to write an abstraction layer. By abstraction layer, I mean a wrapper above one or more 3rd party libraries.

Or do I have to solve it like this?

#include<an3rdpartyl>
#include<another3rdpartyl>

class layer
{
private:
    an3rdpartyl* object1;
    another3rdpartyl* object2;
public:
    //...
    int loadModel(char* file)
    {
        return object2->LoadMeshFromFile(file);
    }
    //...
};
+1  A: 

You might want to look up the Decorator pattern.

JRL
How is Decorator relevant to his question? Decorator is for adding behavior at *runtime*.
Emile Cormier
+1  A: 

Take a look at the Facade, Adapter, and Bridge patterns. Or even better, just pick up the "Gang of Four" Design Patterns book and learn about software design in a whole new light.

Emile Cormier