ComponentManagerBase.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "nx/nxuri.h"
  3. #include "service/api_service.h"
  4. #include "component/ifc_component.h"
  5. #include <deque>
  6. #include "component/ifc_component_sync.h"
  7. class ComponentManagerBase
  8. {
  9. public:
  10. void SetServiceAPI(api_service *service_api);
  11. int Load();
  12. void SetFrameworkGUID(GUID guid);
  13. GUID GetFrameworkGUID();
  14. void SetApplicationGUID(GUID guid);
  15. GUID GetApplicationGUID();
  16. virtual int AddComponent(ifc_component *component);
  17. protected:
  18. ComponentManagerBase();
  19. int LateLoad(ifc_component *mod);
  20. enum Phase
  21. {
  22. PHASE_INITIALIZE=0, /* components are still being added */
  23. PHASE_REGISTERED=1, /* RegisterServices() has been called on all components */
  24. PHASE_LOADING=2, /* OnLoading() has been called on all components */
  25. PHASE_LOADED=3, /* OnLoaded() has been called on all components */
  26. };
  27. Phase phase;
  28. typedef std::deque<ifc_component*> ComponentList;
  29. ComponentList components;
  30. api_service *service_api;
  31. ifc_component_sync *component_sync;
  32. GUID framework_guid;
  33. GUID application_guid;
  34. private:
  35. /* your implementation needs to override this. You should call FreeLibrary(component->component_info.hModule); or dlclose(component->component_info.dl_handle); or similar */
  36. virtual void CloseComponent(ifc_component *component)=0;
  37. };