lundi 2 octobre 2017

C++ - Avoiding Static in Headers; Best Practices?

I'm currently designing an Internal SDK; Looking at my Header i'm questioning my choice of "design" here.

// Objects (API)
namespace Objects {
    static Object yxz;
    static std::vector<Object> xx;
    static std::vector<Object> xy;

    static std::vector<Object> zx;
    static std::vector<Object> zy;
    static std::vector<Object> zz;

    static std::vector<Object> yx;
    static std::vector<Object> yy;

    static void Find() {

    }
}

// Interfaces
class Interfaces {
private:
    static SDK::dd* ddd;

public:
    static dd* ddd();
};

// Functions
namespace Functions {
    static cc ccc;
    static qq qqq;

    static void Find() {

    }
}

What can i do to avoid adding static everywhere? The header get's included atleast three times troughout the entire program. Should i use a singleton, extern...?

I'm basicly looking for a good design pattern for headers acting as a sdk to be included in modules written later.

Aucun commentaire:

Enregistrer un commentaire