2
0

msg.template.h 564 B

12345678910111213141516171819202122
  1. #ifndef AFUN_MSG_TEMPLATE_H
  2. #define AFUN_MSG_TEMPLATE_H
  3. #include "msg.h"
  4. namespace aFuncore {
  5. template<class T>
  6. T *MessageStream::getMessage(const std::string &type) const {
  7. Message *msg = this->_getMessage(type);
  8. T *ret = dynamic_cast<T*>(msg);
  9. return ret;
  10. }
  11. template <typename Callable, typename...T>
  12. inline void MessageStream::forEach(Callable func, T...arg) {
  13. for (Message *msg = stream; msg != nullptr; msg = msg->next) {
  14. func(msg, arg...);
  15. }
  16. }
  17. }
  18. #endif //AFUN_MSG_TEMPLATE_H