mailbox.h 617 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // mailbox.h
  3. // engine
  4. //
  5. // Created by Sam Jaffe on 3/16/23.
  6. //
  7. #pragma once
  8. #include <string>
  9. #include <serializer/stringizer.h>
  10. namespace engine {
  11. /**
  12. * @brief A generic mailbox class that contains a system to message
  13. */
  14. class Mailbox {
  15. public:
  16. virtual ~Mailbox() = default;
  17. virtual void notify(std::string const & str) = 0;
  18. template <typename... Args> void notifyf(Args &&... args);
  19. private:
  20. };
  21. template <typename... Args> void Mailbox::notifyf(Args &&... args) {
  22. std::string str;
  23. using ::serializer::to_string;
  24. (str.append(to_string(std::forward<Args>(args))), ...);
  25. notify(str);
  26. }
  27. }