/*==================================================================================================
	CASettingsStorage.h

	$Log: CASettingsStorage.h,v $
	Revision 1.2  2005/09/09 23:48:54  jcm10
	merge stuff
	
	Revision 1.1.2.3  2005/09/01 16:59:14  jcm10
	finish off the initial implementation
	
	Revision 1.1.2.2  2005/08/31 00:39:41  jcm10
	more implementation
	
	Revision 1.1.2.1  2005/08/30 01:09:25  jcm10
	first checked in (but not working yet!)
	
	Revision 0.0  8/29/05 3:30:48 PM  moorf
	Created
		
	$NoKeywords: $
==================================================================================================*/
#if !defined(__CASettingsStorage_h__)
#define __CASettingsStorage_h__

//==================================================================================================
//	Includes
//==================================================================================================

//	System Includes
#include <CoreAudio/CoreAudioTypes.h>
#include <CoreFoundation/CoreFoundation.h>

//	Stamdard Library Includes
#include <stdio.h>

//==================================================================================================
//	CASettingsStorage
//==================================================================================================

class CASettingsStorage
{

//	Construction/Destruction
public:
							CASettingsStorage(const char* inSettingsFilePath);
							~CASettingsStorage();

//	Operations
public:
	void					CopyBoolValue(const CFStringRef inKey, bool& outValue, bool inDefaultValue = false) const;
	void					CopySInt32Value(const CFStringRef inKey, SInt32& outValue, SInt32 inDefaultValue = 0) const;
	void					CopyUInt32Value(const CFStringRef inKey, UInt32& outValue, UInt32 inDefaultValue = 0) const;
	void					CopySInt64Value(const CFStringRef inKey, SInt64& outValue, SInt64 inDefaultValue = 0) const;
	void					CopyUInt64Value(const CFStringRef inKey, UInt64& outValue, UInt64 inDefaultValue = 0) const;
	void					CopyFloat32Value(const CFStringRef inKey, Float32& outValue, Float32 inDefaultValue = 0) const;
	void					CopyFloat64Value(const CFStringRef inKey, Float64& outValue, Float64 inDefaultValue = 0) const;
	void					CopyNumberValue(const CFStringRef inKey, CFNumberRef& outValue, CFNumberRef inDefaultValue = NULL) const;	
	void					CopyStringValue(const CFStringRef inKey, CFStringRef& outValue, CFStringRef inDefaultValue = NULL) const;	
	void					CopyArrayValue(const CFStringRef inKey, CFArrayRef& outValue, CFArrayRef inDefaultValue = NULL) const;	
	void					CopyDictionaryValue(const CFStringRef inKey, CFDictionaryRef& outValue, CFDictionaryRef inDefaultValue = NULL) const;	
	void					CopyDataValue(const CFStringRef inKey, CFDataRef& outValue, CFDataRef inDefaultValue = NULL) const;
	void					CopyCFTypeValue(const CFStringRef inKey, CFTypeRef& outValue, CFTypeRef inDefaultValue = NULL) const;
	
	void					SetSInt32Value(const CFStringRef inKey, SInt32 inValue);
	void					SetUInt32Value(const CFStringRef inKey, UInt32 inValue);
	void					SetSInt64Value(const CFStringRef inKey, SInt64 inValue);
	void					SetUInt64Value(const CFStringRef inKey, UInt64 inValue);
	void					SetFloat32Value(const CFStringRef inKey, Float32 inValue);
	void					SetFloat64Value(const CFStringRef inKey, Float64 inValue);
	void					SetNumberValue(const CFStringRef inKey, const CFNumberRef inValue);
	void					SetStringValue(const CFStringRef inKey, const CFStringRef inValue);
	void					SetArrayValue(const CFStringRef inKey, const CFArrayRef inValue);
	void					SetDictionaryValue(const CFStringRef inKey, const CFDictionaryRef inValue);
	void					SetDataValue(const CFStringRef inKey, const CFDataRef inValue);
	void					SetCFTypeValue(const CFStringRef inKey, const CFTypeRef inValue);
	
	void					RemoveValue(const CFStringRef inKey);
	void					RemoveAllValues();
	
	void					SendNotification(const CFStringRef inName, CFDictionaryRef inData = NULL, bool inPostToAllSessions = true) const;

//	Implementation
private:
	void					RefreshSettings();
	void					SaveSettings();

	char*					mSettingsFilePath;
	CFMutableDictionaryRef	mSettingsCache;
	struct timespec			mSettingsCacheTime;

};

#endif
