SpModule.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "sp_svc.h"
  3. #include "sp_iom.h"
  4. #include "sp_mod.h"
  5. #include "sp_cfg.h"
  6. #include "sp_log.h"
  7. #include "array.h"
  8. class SpEntity;
  9. typedef ErrorCodeEnum (*EntryRoutine)();
  10. class SpModule
  11. {
  12. public:
  13. SpModule(sp_mod_t *mod, sp_cfg_shell_module_t *cfg_mod);
  14. ~SpModule();
  15. ErrorCodeEnum Init(const char *url);
  16. VOID Term();
  17. void SetThreadEntity(SpEntity* pEntity);
  18. SpEntity* GetThreadEntity();
  19. sp_iom_t *get_iom() { return m_iom; }
  20. sp_mod_t *get_mod() { return m_mod; }
  21. ErrorCodeEnum AddEntityBase(CEntityBase *pEntity);
  22. ErrorCodeEnum RemoveEntityBase(CEntityBase *pEntity);
  23. ErrorCodeEnum GetEntityBase(const char *pszEntityName,CSmartPointer<CEntityBase> &pEntity);
  24. int GetEntityCount();
  25. SpEntity *FindEntity(const char *lpName);
  26. ErrorCodeEnum Run();
  27. static void SetEntryRoutine(EntryRoutine pfMain, EntryRoutine pfExit) { s_pfMain = pfMain;s_pfExit = pfExit;}
  28. void LogMessage(const LogTypeEnum LogType, const SeverityLevelEnum Level, DWORD dwSysErrorCode, DWORD dwUserErrorCode, const char *pMessage);
  29. void LogMessage(const LogTypeEnum LogType, const SeverityLevelEnum Level, DWORD dwSysErrorCode, DWORD dwUserErrorCode, const char* pMessage, const linkContext& t_context);
  30. void getEntryRoutine(void **pfMain, void **pfExit) { *pfMain = (void*)s_pfMain; *pfExit = (void*)s_pfExit; }
  31. private:
  32. int on_module_init();
  33. int on_module_term();
  34. static int __on_module_init(sp_mod_stub_t *, void *user_data);
  35. static int __on_module_term(sp_mod_stub_t *, void *user_data);
  36. private:
  37. DWORD m_dwEntityTls;
  38. array_header_t *m_arrEntity;
  39. sp_iom_t *m_iom;
  40. sp_mod_t *m_mod;
  41. sp_cfg_shell_module_t *m_cfg_mod;
  42. sp_log_client_t *m_anonymous_log;
  43. sp_mod_stub_t *m_stub;
  44. static EntryRoutine s_pfMain;
  45. static EntryRoutine s_pfExit;
  46. };
  47. SpModule *GetSpModule();