summaryrefslogtreecommitdiff
path: root/Common/ComponentData.h
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2003-09-17 19:07:23 +0000
committerStef Walter <stef@thewalter.net>2003-09-17 19:07:23 +0000
commit3f95d417d9e623ac0c74df8ef11d7a01846392dd (patch)
tree45ec73f2dc07eafd7f41a6f62a8cdfbaa279469f /Common/ComponentData.h
Initial ImportHEADmaster
Diffstat (limited to 'Common/ComponentData.h')
-rw-r--r--Common/ComponentData.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/Common/ComponentData.h b/Common/ComponentData.h
new file mode 100644
index 0000000..75dcdbb
--- /dev/null
+++ b/Common/ComponentData.h
@@ -0,0 +1,111 @@
+//////////////////////////////////////////////////////////////////
+// CComponentData
+//
+// Exposes the IPropertyBag interface for the components to store
+// their data in.
+//
+// Also supports other host specific settings.
+//
+// Current implementation saves the data in the registry and only
+// saves when requested to by host.
+//
+// Component can pass a Variant NULL to delete the specified
+// property
+//
+// Only the following types are supported for now:
+// VT_UI1
+// VT_I2
+// VT_I4
+// VT_R4
+// VT_R8
+// VT_CY
+// VT_BSTR
+//////////////////////////////////////////////////////////////////
+
+
+#if !defined(COMPONENTDATA_H__2AA70045_1988_11D2_B2D4_0020182B97FC__INCLUDED_)
+#define COMPONENTDATA_H__2AA70045_1988_11D2_B2D4_0020182B97FC__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+// ComponentData.h : header file
+//
+
+#define DATA_KEY _T("Data")
+
+#include "../common/interfaces.h"
+#include <map>
+#include <utility>
+using std::map;
+using std::make_pair;
+
+#include <mystring.h>
+
+typedef map<string, CComVariant> string_variant_map;
+
+/////////////////////////////////////////////////////////////////////////////
+// CComponentData command target
+class ATL_NO_VTABLE CComponentData :
+ public CComObjectRootEx<CComMultiThreadModel>,
+ public IPropertyBag
+{
+
+// Attributes
+public:
+ CComponentData();
+ virtual ~CComponentData();
+
+
+public:
+ // Host specific functions
+ // Add String support later when needed.
+ bool WriteInt(const string& sKey, int nValue);
+ int GetInt(const string& sKey, int nDefault);
+ bool Delete(const string& sKey);
+
+ // Can be used by Host and also called from the
+ // IPropertyBag Implementation below
+ HRESULT Write(const string& sValName, const VARIANT& varVal);
+ HRESULT Read(const string& sValName, VARIANT& varVal);
+
+ // Initializes Key
+ HRESULT Initialize(const string& sKey);
+
+
+ // Saves All Setting to Registry Key
+ // If sKey = NULL then saves to key given in Initialize
+ HRESULT Save(string sKey = _T(""));
+
+
+ // Returns an IUnknown to IPropertyBag
+// IUnknown* GetIUnknown(bool bAddRef = false);
+
+
+protected:
+
+ // Arrays of Settings to be written to Registry
+ // Supports Integers and Strings Only
+ string_variant_map m_mapValues;
+
+ // Registry Key
+ string m_sKey;
+
+public:
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CComponentData)
+ COM_INTERFACE_ENTRY(IPropertyBag)
+END_COM_MAP()
+
+ // IPropertyBag Interface
+ STDMETHOD(Read)(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
+ STDMETHOD(Write)(LPCOLESTR pszPropName, VARIANT* pVar);
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // !defined(COMPONENTDATA_H__2AA70045_1988_11D2_B2D4_0020182B97FC__INCLUDED_)