bytecodemanager.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "core/define.h"
  3. #if ENABLE_BYTECODE == 1
  4. #include "sol/sol.hpp"
  5. #include "base/error.h"
  6. #include "base/singleton.hpp"
  7. #include "util/thread.h"
  8. #include "util/queue.hpp"
  9. #include "util/map.hpp"
  10. #include "core/structs.h"
  11. /// <summary>
  12. /// 字节码管理器
  13. /// </summary>
  14. class bytecode_manager:public ylib::error_base,private ylib::ithread {
  15. public:
  16. bytecode_manager();
  17. ~bytecode_manager();
  18. /// <summary>
  19. /// 创建字节码
  20. /// </summary>
  21. /// <param name="name"></param>
  22. /// <param name="filepath"></param>
  23. /// <param name="auto_update"></param>
  24. /// <returns></returns>
  25. bool create(const std::string& name,const std::string& filepath,bool auto_update);
  26. /// <summary>
  27. /// 取字节码
  28. /// </summary>
  29. /// <param name="name"></param>
  30. /// <returns></returns>
  31. const std::string& get(const std::string& name);
  32. std::map<std::string, std::shared_ptr<bytecode>> map();
  33. private:
  34. // ServiceLUA文件
  35. ylib::map<std::string, std::shared_ptr<bytecode>> m_bytescodes;
  36. // 通过 ithread 继承
  37. bool run() override;
  38. };
  39. #endif