btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / userlandfs / shared / DriverSettings.h
blobeb61b69b3e59f8f65c89748e0eea7d76e693bde6
1 // DriverSettings.h
3 #ifndef USERLAND_FS_DRIVER_SETTINGS_H
4 #define USERLAND_FS_DRIVER_SETTINGS_H
6 struct driver_parameter;
7 struct driver_settings;
9 namespace UserlandFSUtil {
11 class DriverParameter;
12 class DriverParameterContainer;
14 // DriverParameterIterator
15 class DriverParameterIterator {
16 public:
17 DriverParameterIterator();
18 DriverParameterIterator(
19 const DriverParameterIterator& other);
20 ~DriverParameterIterator();
22 bool HasNext() const;
23 bool GetNext(DriverParameter* parameter);
25 DriverParameterIterator& operator=(
26 const DriverParameterIterator& other);
28 private:
29 friend class DriverParameterContainer;
30 class Delegate;
32 DriverParameterIterator(Delegate* delegate);
33 void _SetTo(Delegate* delegate, bool addReference);
35 Delegate* fDelegate;
38 // DriverParameterContainer
39 class DriverParameterContainer {
40 public:
41 DriverParameterContainer();
42 virtual ~DriverParameterContainer();
44 int32 CountParameters() const;
45 const driver_parameter* GetParameters() const;
46 bool GetParameterAt(int32 index,
47 DriverParameter* parameter) const;
48 bool FindParameter(const char* name,
49 DriverParameter* parameter) const;
51 DriverParameterIterator GetParameterIterator() const;
52 DriverParameterIterator GetParameterIterator(
53 const char* name) const;
55 const char* GetParameterValue(const char* name,
56 const char* unknownValue = NULL,
57 const char* noValue = NULL) const;
58 bool GetBoolParameterValue(const char* name,
59 bool unknownValue = false,
60 bool noValue = false) const;
61 int32 GetInt32ParameterValue(const char* name,
62 int32 unknownValue = 0,
63 int32 noValue = 0) const;
64 int64 GetInt64ParameterValue(const char* name,
65 int64 unknownValue = 0,
66 int64 noValue = 0) const;
68 protected:
69 virtual const driver_parameter*
70 GetParametersAndCount(int32* count) const = 0;
72 private:
73 class Iterator;
74 class NameIterator;
77 // DriverSettings
78 class DriverSettings : public DriverParameterContainer {
79 public:
80 DriverSettings();
81 virtual ~DriverSettings();
83 status_t Load(const char* driverName);
84 void Unset();
86 protected:
87 virtual const driver_parameter*
88 GetParametersAndCount(int32* count) const;
90 private:
91 void* fSettingsHandle;
92 const driver_settings* fSettings;
95 // DriverParameter
96 class DriverParameter : public DriverParameterContainer {
97 public:
98 DriverParameter();
99 virtual ~DriverParameter();
101 void SetTo(const driver_parameter* parameter);
103 const char* GetName() const;
104 int32 CountValues() const;
105 const char* const* GetValues() const;
106 const char* ValueAt(int32 index,
107 const char* noValue = NULL) const;
108 bool BoolValueAt(int32 index,
109 bool noValue = false) const;
110 int32 Int32ValueAt(int32 index,
111 int32 noValue = 0) const;
112 int64 Int64ValueAt(int32 index,
113 int64 noValue = 0) const;
115 protected:
116 virtual const driver_parameter*
117 GetParametersAndCount(int32* count) const;
119 private:
120 const driver_parameter* fParameter;
123 } // namespace UserlandFSUtil
125 using UserlandFSUtil::DriverParameterIterator;
126 using UserlandFSUtil::DriverParameterContainer;
127 using UserlandFSUtil::DriverSettings;
128 using UserlandFSUtil::DriverParameter;
130 #endif // USERLAND_FS_DRIVER_SETTINGS_H