aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/component/ComponentManagerBase.h
blob: 9559a3dd254ae4ec65aea4557ed7a2e01ec6bdad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include "nx/nxuri.h"
#include "service/api_service.h"
#include "component/ifc_component.h"
#include <deque>
#include "component/ifc_component_sync.h"

class ComponentManagerBase
{
public:
	void SetServiceAPI(api_service *service_api);
	int Load();
	
	void SetFrameworkGUID(GUID guid);
	GUID GetFrameworkGUID();
	void SetApplicationGUID(GUID guid);
	GUID GetApplicationGUID();
	
	virtual int AddComponent(ifc_component *component);
	
protected:
	ComponentManagerBase();
	int LateLoad(ifc_component *mod);
	enum Phase
	{
		PHASE_INITIALIZE=0, /* components are still being added */
		PHASE_REGISTERED=1, /* RegisterServices() has been called on all components */
		PHASE_LOADING=2, /* OnLoading() has been called on all components */
		PHASE_LOADED=3, /* OnLoaded() has been called on all components */
	};
	Phase phase;
	typedef std::deque<ifc_component*> ComponentList;
	ComponentList components;
	api_service *service_api;
	ifc_component_sync *component_sync;
	
	GUID framework_guid;
	GUID application_guid;
	
private:
	/* your implementation needs to override this.  You should call FreeLibrary(component->component_info.hModule); or dlclose(component->component_info.dl_handle); or similar */
	virtual void CloseComponent(ifc_component *component)=0;
};