H
heltena
Hi,
I have this "interface" (abstract class):
class Callback
{
public:
virtual void function1() = 0;
virtual void function2(string value) = 0;
};
a class that implement Callback interface and this other class:
class Manager
{
public:
....
void call_function1();
void call_function2(string value);
private:
list<Callback *> m_callbacks; // it contains correct pointers
};
implementation:
void Manager::call_function1()
{
list<Callback *>::iterator it = m_callbacks.begin(), end =
m_callbacks.end();
while (it != end)
{
(*it)->function1();
it++;
}
}
void Manager::call_function2(string value)
{
list<Callback *>::iterator it = m_callbacks.begin(), end =
m_callbacks.end();
while (it != end)
{
(*it)->function2(value);
it++;
}
}
and the question:
I have a lot of functions (more that two) in the callback interface,
can I use macros or templates to make more easy the new functions
implementation?
Thanks,
I have this "interface" (abstract class):
class Callback
{
public:
virtual void function1() = 0;
virtual void function2(string value) = 0;
};
a class that implement Callback interface and this other class:
class Manager
{
public:
....
void call_function1();
void call_function2(string value);
private:
list<Callback *> m_callbacks; // it contains correct pointers
};
implementation:
void Manager::call_function1()
{
list<Callback *>::iterator it = m_callbacks.begin(), end =
m_callbacks.end();
while (it != end)
{
(*it)->function1();
it++;
}
}
void Manager::call_function2(string value)
{
list<Callback *>::iterator it = m_callbacks.begin(), end =
m_callbacks.end();
while (it != end)
{
(*it)->function2(value);
it++;
}
}
and the question:
I have a lot of functions (more that two) in the callback interface,
can I use macros or templates to make more easy the new functions
implementation?
Thanks,