varlist.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef AFUN_VARLIST_H
  2. #define AFUN_VARLIST_H
  3. #include <list>
  4. #include <unordered_map>
  5. #include <mutex>
  6. #include "aFuntool.h"
  7. #include "aFunCoreExport.h"
  8. #include "object-value.h"
  9. #include "inter.h"
  10. namespace aFuncore {
  11. class AFUN_CORE_EXPORT VarList {
  12. public:
  13. explicit inline VarList() = default;
  14. explicit VarList(VarList *varlist);
  15. explicit VarList(VarSpace *varspace);
  16. ~VarList() = default;
  17. VarList(const VarList &) = delete;
  18. VarList &operator=(const VarList &) = delete;
  19. void connect(VarList *varlist);
  20. inline void push(VarSpace *varspace_);
  21. template <typename Callable,typename...T>
  22. void forEach(Callable func, T...arg);
  23. template <typename Callable,typename...T>
  24. void forEachLock(Callable func, T...arg);
  25. [[nodiscard]] virtual Var *findVar(const std::string &name);
  26. virtual bool defineVar(const std::string &name, Object *data);
  27. virtual bool defineVar(const std::string &name, Var *data);
  28. virtual bool setVar(const std::string &name, Object *data);
  29. virtual bool delVar(const std::string &name);
  30. [[nodiscard]] inline Object *findObject(const std::string &name);
  31. inline void GcLinkObject(std::queue<Object *> &queue); /* 虽然不是GcObject, 但是也设定改函数便于将其包含的varspace快速压入queue中 */
  32. protected:
  33. std::mutex lock;
  34. private:
  35. std::list<VarSpace *> varspace;
  36. };
  37. }
  38. #include "varlist.inline.h"
  39. #include "varlist.template.h"
  40. #endif //AFUN_VARLIST_H