1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/client/FunctionList.h
Michał W. Urbańczyk b83b80a71e * upgrading creatures
* splitted map loading on several functions
* buttons can call multiple functions when pressed
* minor
2008-08-15 12:11:42 +00:00

36 lines
881 B
C++

#pragma once
#include <boost/function.hpp>
template<typename Signature, typename Allocator = std::allocator<void> >
class CFunctionList
{
public:
std::vector<boost::function<Signature,Allocator> > funcs;
CFunctionList(int){};
CFunctionList(){};
CFunctionList(const boost::function<Signature,Allocator> &first)
{
funcs.push_back(first);
}
CFunctionList & operator+=(const boost::function<Signature,Allocator> &first)
{
funcs.push_back(first);
return *this;
}
const boost::function<Signature,Allocator> & operator=(const boost::function<Signature,Allocator> &first)
{
funcs.push_back(first);
return first;
}
operator bool() const
{
return funcs.size();
}
void operator()() const
{
std::vector<boost::function<Signature,Allocator> > funcs2 = funcs; //backup
for(int i=0;i<funcs2.size(); i++)
funcs2[i]();
}
};