30 #ifndef UTIL_VERSIONACTIONMAPPER_H
31 #define UTIL_VERSIONACTIONMAPPER_H
33 #include <QDataStream>
40 template<
typename ActionType,
typename VerType = qu
int8>
44 typedef std::function<bool (QDataStream&)>
Functor_t;
46 typedef QMap<ActionType, Functor_t> Action2Functor_t;
47 typedef QMap<VerType, Action2Functor_t> Version2Functors_t;
48 Version2Functors_t Functors_;
73 Functors_ [version] [action] = functor;
86 if (!Functors_.contains (version))
88 qWarning () << Q_FUNC_INFO
96 if (in.status () != QDataStream::Ok)
98 qWarning () << Q_FUNC_INFO
106 ActionType act =
static_cast<ActionType
> (action);
107 if (!Functors_ [version].contains (act))
109 qWarning () << Q_FUNC_INFO
117 return Functors_ [version] [act] (in);
bool operator()(QDataStream &ds)
void AddFunctor(VerType version, ActionType action, Functor_t functor)
bool Process(QDataStream &in)
bool Process(const QByteArray &ba)
std::function< bool(QDataStream &)> Functor_t