2 * Copyright 2007-2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
8 #ifndef _B_DRIVER_SETTINGS_H
9 #define _B_DRIVER_SETTINGS_H
12 #include <SupportDefs.h>
15 struct driver_parameter
;
16 struct driver_settings
;
23 class BDriverParameter
;
24 class BDriverParameterContainer
;
27 class BDriverParameterIterator
{
29 BDriverParameterIterator();
30 BDriverParameterIterator(
31 const BDriverParameterIterator
& other
);
32 ~BDriverParameterIterator();
35 BDriverParameter
Next();
37 BDriverParameterIterator
& operator=(
38 const BDriverParameterIterator
& other
);
41 friend class BDriverParameterContainer
;
45 BDriverParameterIterator(Delegate
* delegate
);
46 void _SetTo(Delegate
* delegate
, bool addReference
);
53 class BDriverParameterContainer
{
55 BDriverParameterContainer();
56 virtual ~BDriverParameterContainer();
58 int32
CountParameters() const;
59 const driver_parameter
* Parameters() const;
60 BDriverParameter
ParameterAt(int32 index
) const;
61 bool FindParameter(const char* name
,
62 BDriverParameter
* _parameter
) const;
63 BDriverParameter
GetParameter(const char* name
) const;
65 BDriverParameterIterator
ParameterIterator() const;
66 BDriverParameterIterator
ParameterIterator(const char* name
) const;
68 const char* GetParameterValue(const char* name
,
69 const char* unknownValue
= NULL
,
70 const char* noValue
= NULL
) const;
71 bool GetBoolParameterValue(const char* name
,
72 bool unknownValue
= false,
73 bool noValue
= false) const;
74 int32
GetInt32ParameterValue(const char* name
,
75 int32 unknownValue
= 0,
76 int32 noValue
= 0) const;
77 int64
GetInt64ParameterValue(const char* name
,
78 int64 unknownValue
= 0,
79 int64 noValue
= 0) const;
82 virtual const driver_parameter
* GetParametersAndCount(int32
& _count
) const
91 class BDriverSettings
: public BDriverParameterContainer
{
94 virtual ~BDriverSettings();
96 status_t
Load(const char* driverNameOrAbsolutePath
);
97 status_t
Load(const entry_ref
& ref
);
98 status_t
SetToString(const char* string
);
102 virtual const driver_parameter
* GetParametersAndCount(int32
& _count
) const;
105 void* fSettingsHandle
;
106 const driver_settings
* fSettings
;
110 class BDriverParameter
: public BDriverParameterContainer
{
114 const driver_parameter
* parameter
);
115 BDriverParameter(const BDriverParameter
& other
);
116 virtual ~BDriverParameter();
118 void SetTo(const driver_parameter
* parameter
);
120 bool IsValid() const;
122 const char* Name() const;
123 int32
CountValues() const;
124 const char* const* Values() const;
125 const char* ValueAt(int32 index
,
126 const char* noValue
= NULL
) const;
127 bool BoolValueAt(int32 index
,
128 bool noValue
= false) const;
129 int32
Int32ValueAt(int32 index
,
130 int32 noValue
= 0) const;
131 int64
Int64ValueAt(int32 index
,
132 int64 noValue
= 0) const;
134 BDriverParameter
& operator=(const BDriverParameter
& other
);
137 virtual const driver_parameter
* GetParametersAndCount(int32
& _count
) const;
140 const driver_parameter
* fParameter
;
144 } // namespace BPrivate
147 using BPrivate::BDriverParameterIterator
;
148 using BPrivate::BDriverSettings
;
149 using BPrivate::BDriverParameter
;
152 #endif // _B_DRIVER_SETTINGS_H