Jamoma API  0.6.0.a19
CASettingsStorage.h
1 /* Copyright © 2007 Apple Inc. All Rights Reserved.
2 
3  Disclaimer: IMPORTANT: This Apple software is supplied to you by
4  Apple Inc. ("Apple") in consideration of your agreement to the
5  following terms, and your use, installation, modification or
6  redistribution of this Apple software constitutes acceptance of these
7  terms. If you do not agree with these terms, please do not use,
8  install, modify or redistribute this Apple software.
9 
10  In consideration of your agreement to abide by the following terms, and
11  subject to these terms, Apple grants you a personal, non-exclusive
12  license, under Apple's copyrights in this original Apple software (the
13  "Apple Software"), to use, reproduce, modify and redistribute the Apple
14  Software, with or without modifications, in source and/or binary forms;
15  provided that if you redistribute the Apple Software in its entirety and
16  without modifications, you must retain this notice and the following
17  text and disclaimers in all such redistributions of the Apple Software.
18  Neither the name, trademarks, service marks or logos of Apple Inc.
19  may be used to endorse or promote products derived from the Apple
20  Software without specific prior written permission from Apple. Except
21  as expressly stated in this notice, no other rights or licenses, express
22  or implied, are granted by Apple herein, including but not limited to
23  any patent rights that may be infringed by your derivative works or by
24  other works in which the Apple Software may be incorporated.
25 
26  The Apple Software is provided by Apple on an "AS IS" basis. APPLE
27  MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
28  THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
29  FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
30  OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
31 
32  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
33  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
36  MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
37  AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
38  STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
39  POSSIBILITY OF SUCH DAMAGE.
40 */
41 #if !defined(__CASettingsStorage_h__)
42 #define __CASettingsStorage_h__
43 
44 //==================================================================================================
45 // Includes
46 //==================================================================================================
47 
48 // System Includes
49 #include <CoreAudio/CoreAudioTypes.h>
50 #include <CoreFoundation/CoreFoundation.h>
51 
52 // Stamdard Library Includes
53 #include <stdio.h>
54 #include <sys/stat.h>
55 
56 //==================================================================================================
57 // CASettingsStorage
58 //==================================================================================================
59 
60 class CASettingsStorage
61 {
62 
63 // Construction/Destruction
64 public:
65  CASettingsStorage(const char* inSettingsFilePath, mode_t inSettingsFileAccessMode = 0);
66  ~CASettingsStorage();
67 
68 // Operations
69 public:
70  void CopyBoolValue(const CFStringRef inKey, bool& outValue, bool inDefaultValue = false) const;
71  void CopySInt32Value(const CFStringRef inKey, SInt32& outValue, SInt32 inDefaultValue = 0) const;
72  void CopyUInt32Value(const CFStringRef inKey, UInt32& outValue, UInt32 inDefaultValue = 0) const;
73  void CopySInt64Value(const CFStringRef inKey, SInt64& outValue, SInt64 inDefaultValue = 0) const;
74  void CopyUInt64Value(const CFStringRef inKey, UInt64& outValue, UInt64 inDefaultValue = 0) const;
75  void CopyFloat32Value(const CFStringRef inKey, Float32& outValue, Float32 inDefaultValue = 0) const;
76  void CopyFloat64Value(const CFStringRef inKey, Float64& outValue, Float64 inDefaultValue = 0) const;
77  void CopyNumberValue(const CFStringRef inKey, CFNumberRef& outValue, CFNumberRef inDefaultValue = NULL) const;
78  void CopyStringValue(const CFStringRef inKey, CFStringRef& outValue, CFStringRef inDefaultValue = NULL) const;
79  void CopyArrayValue(const CFStringRef inKey, CFArrayRef& outValue, CFArrayRef inDefaultValue = NULL) const;
80  void CopyDictionaryValue(const CFStringRef inKey, CFDictionaryRef& outValue, CFDictionaryRef inDefaultValue = NULL) const;
81  void CopyDataValue(const CFStringRef inKey, CFDataRef& outValue, CFDataRef inDefaultValue = NULL) const;
82  void CopyCFTypeValue(const CFStringRef inKey, CFTypeRef& outValue, CFTypeRef inDefaultValue = NULL) const;
83 
84  void SetSInt32Value(const CFStringRef inKey, SInt32 inValue);
85  void SetUInt32Value(const CFStringRef inKey, UInt32 inValue);
86  void SetSInt64Value(const CFStringRef inKey, SInt64 inValue);
87  void SetUInt64Value(const CFStringRef inKey, UInt64 inValue);
88  void SetFloat32Value(const CFStringRef inKey, Float32 inValue);
89  void SetFloat64Value(const CFStringRef inKey, Float64 inValue);
90  void SetNumberValue(const CFStringRef inKey, const CFNumberRef inValue);
91  void SetStringValue(const CFStringRef inKey, const CFStringRef inValue);
92  void SetArrayValue(const CFStringRef inKey, const CFArrayRef inValue);
93  void SetDictionaryValue(const CFStringRef inKey, const CFDictionaryRef inValue);
94  void SetDataValue(const CFStringRef inKey, const CFDataRef inValue);
95  void SetCFTypeValue(const CFStringRef inKey, const CFTypeRef inValue);
96 
97  void RemoveValue(const CFStringRef inKey);
98  void RemoveAllValues();
99 
100  void SendNotification(const CFStringRef inName, CFDictionaryRef inData = NULL, bool inPostToAllSessions = true) const;
101  void ForceRefresh();
102 
103 // Implementation
104 private:
105  void RefreshSettings();
106  void SaveSettings();
107 
108  char* mSettingsFilePath;
109  mode_t mSettingsFileAccessMode;
110  CFMutableDictionaryRef mSettingsCache;
111  struct timespec mSettingsCacheTime;
112  bool mSettingsCacheForceRefresh;
113 
114 };
115 
116 #endif