summaryrefslogtreecommitdiff
path: root/Common/ComponentArray.h
blob: 892faaee1574989fe6077e7af8e593c18b188dbb (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//////////////////////////////////////////////////////////////////
//  
// ComponentArray.h: interface for the CComponentArray class.
// 
// Class that holds all the components for the application
// Need to call LoadComponents before you can use them
//
// Derived from a vector so you can access the components each 
// as it's own CComponentHolder, but takes care of the Loading
// and Unloading itself.
//
// 'Installed Components' are components that haven't been used
// yet by a user, but have been installed on the system. 
// The Loading code first loops through all the user's components
// and then sees if it's missing anything that's installed but 
// hasn't been used yet.
//
// The reason for a distiction between a Program ID and a Registry
// Key is to support multiple instances of components in the future
// if needed. Each component would be inited from it's own Key. The
// keys could also be used as Stream ID's in a OLE Storage etc...
//
//////////////////////////////////////////////////////////////////////

#if !defined(COMPONENTARRAY_H__ADB16FE6_1B31_11D2_B2D4_0020182B97FC__INCLUDED_)
#define COMPONENTARRAY_H__ADB16FE6_1B31_11D2_B2D4_0020182B97FC__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "..\Common\ComponentHolder.h"

#include <mystring.h>
#include <vector>
using std::vector;

// An Array of CComponentHolder's with inbuilt Loading and Unloading

typedef vector<CComponentHolder*> ArrayComponents;
typedef vector<string> string_array;
class CComponentArray 
	: public ArrayComponents
{
public:
	CComponentArray();
	virtual ~CComponentArray();

public:

	// Load Components from Registry
	UINT LoadComponents();

	// Remove Components from Memory
	UINT UnloadComponents();

	// Save Comoponents Data to Registry
	HRESULT SaveComponentData();

protected:

	/////////////////////////////////////////////////////////
	// List of All Installed Components
	// Used to Compare with User's Current Components
	string_array m_asInstalledComponents;

	// Load List of All Installed Components
	UINT LoadInstalledComponents();

	// Called when Loading a Component
	bool CheckOffInstalledComponent(const string& sID);
	HRESULT AddComponent(const string& sID);

	// Gets the Component ID from a Registry KeyName
	// eg: 'NightSecurity.ClearInetCache' would come from 'NightSecurity.ClearInetCache 2'
	string GetIDFromKey(const string& sKeyName);

};

#endif // !defined(COMPONENTARRAY_H__ADB16FE6_1B31_11D2_B2D4_0020182B97FC__INCLUDED_)