jeudi 9 février 2017

Best way to ensure single instance but not global in C++

I am developing a class to control a network adapter and I need to ensure that there's only a single instance of this class. Global access isn't necessary as this class is only used by clients that perform network operations, so I think that's not the case for the singleton pattern.

Currently I have a factory which has a static instance of this netAdapter but I'm not sure that's a good solution.

What's the best way to do this and avoid testability problems?

Aucun commentaire:

Enregistrer un commentaire