mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
classes for buttons group and functionlist with arg
This commit is contained in:
@ -27,11 +27,6 @@ public:
|
||||
funcs.push_back(first);
|
||||
return *this;
|
||||
}
|
||||
//CFunctionList<Signature> & operator=(const boost::function<Signature> &first)
|
||||
//{
|
||||
// funcs.push_back(first);
|
||||
// return first;
|
||||
//}
|
||||
void clear()
|
||||
{
|
||||
funcs.clear();
|
||||
@ -53,4 +48,47 @@ public:
|
||||
for(int i=0;i<funcs2.size(); i++)
|
||||
funcs2[i](a);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Signature>
|
||||
class CFunctionList2
|
||||
{
|
||||
public:
|
||||
std::vector<boost::function<Signature> > funcs;
|
||||
|
||||
CFunctionList2(int){};
|
||||
CFunctionList2(){};
|
||||
template <typename Functor>
|
||||
CFunctionList2(const Functor &f)
|
||||
{
|
||||
funcs.push_back(boost::function<Signature>(f));
|
||||
}
|
||||
CFunctionList2(const boost::function<Signature> &first)
|
||||
{
|
||||
funcs.push_back(first);
|
||||
}
|
||||
CFunctionList2(boost::function<Signature> &first)
|
||||
{
|
||||
funcs.push_back(first);
|
||||
}
|
||||
CFunctionList2 & operator+=(const boost::function<Signature> &first)
|
||||
{
|
||||
funcs.push_back(first);
|
||||
return *this;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
funcs.clear();
|
||||
}
|
||||
operator bool() const
|
||||
{
|
||||
return funcs.size();
|
||||
}
|
||||
template <typename Arg>
|
||||
void operator()(const Arg & a) const
|
||||
{
|
||||
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
|
||||
for(int i=0;i<funcs2.size(); i++)
|
||||
funcs2[i](a);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user