C
chameleon
I have 2 classes with exactly the same members (all static except
dtor/ctor).
Classes have different implementantion in only one static member
function and first class has one more member function.
How can I write this code with templates?
First of all: Thought to write code with templates is correct?
members of classes are static because refer to devices. There is no
reason to be non-static.
Thanks.
2 classes follow:
------------------
class ALDevices
{
static std::vector<std::string> lstDevices;
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
public:
ALDevices(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static void closeDevice(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static int getTotalDevices() { return lstDevices.size(); }
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
static ALCcontext *getActiveContext() { return context; } // DOEN'T
EXIST AT ALL IN SECOND CLASS
};
------------------
class ALCaptureDevices
{
static std::vector<std::string> lstDevices;
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
public:
ALCaptureDevices(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static void closeDevice(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static int getTotalDevices() { return lstDevices.size(); }
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
};
------------------
dtor/ctor).
Classes have different implementantion in only one static member
function and first class has one more member function.
How can I write this code with templates?
First of all: Thought to write code with templates is correct?
members of classes are static because refer to devices. There is no
reason to be non-static.
Thanks.
2 classes follow:
------------------
class ALDevices
{
static std::vector<std::string> lstDevices;
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
public:
ALDevices(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static void closeDevice(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static int getTotalDevices() { return lstDevices.size(); }
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
static ALCcontext *getActiveContext() { return context; } // DOEN'T
EXIST AT ALL IN SECOND CLASS
};
------------------
class ALCaptureDevices
{
static std::vector<std::string> lstDevices;
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
public:
ALCaptureDevices(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static void closeDevice(); // IMPLEMENTENT DIFFERENT IN 2 CLASSES
static int getTotalDevices() { return lstDevices.size(); }
// AND MOOOOOORE STATICs SHARED IN 2 CLASSES!
};
------------------