xref: /haiku/headers/private/userlandfs/shared/DriverSettings.h (revision 83812f67529c88d4fb4b942162a9f21142e683fa)
1*83812f67SIngo Weinhold // DriverSettings.h
2*83812f67SIngo Weinhold 
3*83812f67SIngo Weinhold #ifndef USERLAND_FS_DRIVER_SETTINGS_H
4*83812f67SIngo Weinhold #define USERLAND_FS_DRIVER_SETTINGS_H
5*83812f67SIngo Weinhold 
6*83812f67SIngo Weinhold struct driver_parameter;
7*83812f67SIngo Weinhold struct driver_settings;
8*83812f67SIngo Weinhold 
9*83812f67SIngo Weinhold namespace UserlandFSUtil {
10*83812f67SIngo Weinhold 
11*83812f67SIngo Weinhold class DriverParameter;
12*83812f67SIngo Weinhold class DriverParameterContainer;
13*83812f67SIngo Weinhold 
14*83812f67SIngo Weinhold // DriverParameterIterator
15*83812f67SIngo Weinhold class DriverParameterIterator {
16*83812f67SIngo Weinhold public:
17*83812f67SIngo Weinhold 								DriverParameterIterator();
18*83812f67SIngo Weinhold 								DriverParameterIterator(
19*83812f67SIngo Weinhold 									const DriverParameterIterator& other);
20*83812f67SIngo Weinhold 								~DriverParameterIterator();
21*83812f67SIngo Weinhold 
22*83812f67SIngo Weinhold 			bool				HasNext() const;
23*83812f67SIngo Weinhold 			bool				GetNext(DriverParameter* parameter);
24*83812f67SIngo Weinhold 
25*83812f67SIngo Weinhold 			DriverParameterIterator& operator=(
26*83812f67SIngo Weinhold 									const DriverParameterIterator& other);
27*83812f67SIngo Weinhold 
28*83812f67SIngo Weinhold private:
29*83812f67SIngo Weinhold 			friend class DriverParameterContainer;
30*83812f67SIngo Weinhold 			class Delegate;
31*83812f67SIngo Weinhold 
32*83812f67SIngo Weinhold 								DriverParameterIterator(Delegate* delegate);
33*83812f67SIngo Weinhold 					void		_SetTo(Delegate* delegate, bool addReference);
34*83812f67SIngo Weinhold 
35*83812f67SIngo Weinhold 		Delegate*				fDelegate;
36*83812f67SIngo Weinhold };
37*83812f67SIngo Weinhold 
38*83812f67SIngo Weinhold // DriverParameterContainer
39*83812f67SIngo Weinhold class DriverParameterContainer {
40*83812f67SIngo Weinhold public:
41*83812f67SIngo Weinhold 								DriverParameterContainer();
42*83812f67SIngo Weinhold 	virtual						~DriverParameterContainer();
43*83812f67SIngo Weinhold 
44*83812f67SIngo Weinhold 			int32				CountParameters() const;
45*83812f67SIngo Weinhold 			const driver_parameter*	GetParameters() const;
46*83812f67SIngo Weinhold 			bool				GetParameterAt(int32 index,
47*83812f67SIngo Weinhold 									DriverParameter* parameter) const;
48*83812f67SIngo Weinhold 			bool				FindParameter(const char* name,
49*83812f67SIngo Weinhold 									DriverParameter* parameter) const;
50*83812f67SIngo Weinhold 
51*83812f67SIngo Weinhold 			DriverParameterIterator	GetParameterIterator() const;
52*83812f67SIngo Weinhold 			DriverParameterIterator	GetParameterIterator(
53*83812f67SIngo Weinhold 									const char* name) const;
54*83812f67SIngo Weinhold 
55*83812f67SIngo Weinhold 			const char*			GetParameterValue(const char* name,
56*83812f67SIngo Weinhold 									const char* unknownValue = NULL,
57*83812f67SIngo Weinhold 									const char* noValue = NULL) const;
58*83812f67SIngo Weinhold 			bool				GetBoolParameterValue(const char* name,
59*83812f67SIngo Weinhold 									bool unknownValue = false,
60*83812f67SIngo Weinhold 									bool noValue = false) const;
61*83812f67SIngo Weinhold 			int32				GetInt32ParameterValue(const char* name,
62*83812f67SIngo Weinhold 									int32 unknownValue = 0,
63*83812f67SIngo Weinhold 									int32 noValue = 0) const;
64*83812f67SIngo Weinhold 			int64				GetInt64ParameterValue(const char* name,
65*83812f67SIngo Weinhold 									int64 unknownValue = 0,
66*83812f67SIngo Weinhold 									int64 noValue = 0) const;
67*83812f67SIngo Weinhold 
68*83812f67SIngo Weinhold protected:
69*83812f67SIngo Weinhold 	virtual	const driver_parameter*
70*83812f67SIngo Weinhold 								GetParametersAndCount(int32* count) const = 0;
71*83812f67SIngo Weinhold 
72*83812f67SIngo Weinhold private:
73*83812f67SIngo Weinhold 			class Iterator;
74*83812f67SIngo Weinhold 			class NameIterator;
75*83812f67SIngo Weinhold };
76*83812f67SIngo Weinhold 
77*83812f67SIngo Weinhold // DriverSettings
78*83812f67SIngo Weinhold class DriverSettings : public DriverParameterContainer {
79*83812f67SIngo Weinhold public:
80*83812f67SIngo Weinhold 								DriverSettings();
81*83812f67SIngo Weinhold 	virtual						~DriverSettings();
82*83812f67SIngo Weinhold 
83*83812f67SIngo Weinhold 			status_t			Load(const char* driverName);
84*83812f67SIngo Weinhold 			void				Unset();
85*83812f67SIngo Weinhold 
86*83812f67SIngo Weinhold protected:
87*83812f67SIngo Weinhold 	virtual	const driver_parameter*
88*83812f67SIngo Weinhold 								GetParametersAndCount(int32* count) const;
89*83812f67SIngo Weinhold 
90*83812f67SIngo Weinhold private:
91*83812f67SIngo Weinhold 			void*				fSettingsHandle;
92*83812f67SIngo Weinhold 			const driver_settings*	fSettings;
93*83812f67SIngo Weinhold };
94*83812f67SIngo Weinhold 
95*83812f67SIngo Weinhold // DriverParameter
96*83812f67SIngo Weinhold class DriverParameter : public DriverParameterContainer {
97*83812f67SIngo Weinhold public:
98*83812f67SIngo Weinhold 								DriverParameter();
99*83812f67SIngo Weinhold 	virtual						~DriverParameter();
100*83812f67SIngo Weinhold 
101*83812f67SIngo Weinhold 			void				SetTo(const driver_parameter* parameter);
102*83812f67SIngo Weinhold 
103*83812f67SIngo Weinhold 			const char*			GetName() const;
104*83812f67SIngo Weinhold 			int32				CountValues() const;
105*83812f67SIngo Weinhold 			const char* const*	GetValues() const;
106*83812f67SIngo Weinhold 			const char*			ValueAt(int32 index,
107*83812f67SIngo Weinhold 									const char* noValue = NULL) const;
108*83812f67SIngo Weinhold 			bool				BoolValueAt(int32 index,
109*83812f67SIngo Weinhold 									bool noValue = false) const;
110*83812f67SIngo Weinhold 			int32				Int32ValueAt(int32 index,
111*83812f67SIngo Weinhold 									int32 noValue = 0) const;
112*83812f67SIngo Weinhold 			int64				Int64ValueAt(int32 index,
113*83812f67SIngo Weinhold 									int64 noValue = 0) const;
114*83812f67SIngo Weinhold 
115*83812f67SIngo Weinhold protected:
116*83812f67SIngo Weinhold 	virtual	const driver_parameter*
117*83812f67SIngo Weinhold 								GetParametersAndCount(int32* count) const;
118*83812f67SIngo Weinhold 
119*83812f67SIngo Weinhold private:
120*83812f67SIngo Weinhold 			const driver_parameter*	fParameter;
121*83812f67SIngo Weinhold };
122*83812f67SIngo Weinhold 
123*83812f67SIngo Weinhold }	// namespace UserlandFSUtil
124*83812f67SIngo Weinhold 
125*83812f67SIngo Weinhold using UserlandFSUtil::DriverParameterIterator;
126*83812f67SIngo Weinhold using UserlandFSUtil::DriverParameterContainer;
127*83812f67SIngo Weinhold using UserlandFSUtil::DriverSettings;
128*83812f67SIngo Weinhold using UserlandFSUtil::DriverParameter;
129*83812f67SIngo Weinhold 
130*83812f67SIngo Weinhold #endif	// USERLAND_FS_DRIVER_SETTINGS_H
131