1 // DriverSettings.h 2 3 #ifndef USERLAND_FS_DRIVER_SETTINGS_H 4 #define USERLAND_FS_DRIVER_SETTINGS_H 5 6 struct driver_parameter; 7 struct driver_settings; 8 9 namespace UserlandFSUtil { 10 11 class DriverParameter; 12 class DriverParameterContainer; 13 14 // DriverParameterIterator 15 class DriverParameterIterator { 16 public: 17 DriverParameterIterator(); 18 DriverParameterIterator( 19 const DriverParameterIterator& other); 20 ~DriverParameterIterator(); 21 22 bool HasNext() const; 23 bool GetNext(DriverParameter* parameter); 24 25 DriverParameterIterator& operator=( 26 const DriverParameterIterator& other); 27 28 private: 29 friend class DriverParameterContainer; 30 class Delegate; 31 32 DriverParameterIterator(Delegate* delegate); 33 void _SetTo(Delegate* delegate, bool addReference); 34 35 Delegate* fDelegate; 36 }; 37 38 // DriverParameterContainer 39 class DriverParameterContainer { 40 public: 41 DriverParameterContainer(); 42 virtual ~DriverParameterContainer(); 43 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; 50 51 DriverParameterIterator GetParameterIterator() const; 52 DriverParameterIterator GetParameterIterator( 53 const char* name) const; 54 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; 67 68 protected: 69 virtual const driver_parameter* 70 GetParametersAndCount(int32* count) const = 0; 71 72 private: 73 class Iterator; 74 class NameIterator; 75 }; 76 77 // DriverSettings 78 class DriverSettings : public DriverParameterContainer { 79 public: 80 DriverSettings(); 81 virtual ~DriverSettings(); 82 83 status_t Load(const char* driverName); 84 void Unset(); 85 86 protected: 87 virtual const driver_parameter* 88 GetParametersAndCount(int32* count) const; 89 90 private: 91 void* fSettingsHandle; 92 const driver_settings* fSettings; 93 }; 94 95 // DriverParameter 96 class DriverParameter : public DriverParameterContainer { 97 public: 98 DriverParameter(); 99 virtual ~DriverParameter(); 100 101 void SetTo(const driver_parameter* parameter); 102 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; 114 115 protected: 116 virtual const driver_parameter* 117 GetParametersAndCount(int32* count) const; 118 119 private: 120 const driver_parameter* fParameter; 121 }; 122 123 } // namespace UserlandFSUtil 124 125 using UserlandFSUtil::DriverParameterIterator; 126 using UserlandFSUtil::DriverParameterContainer; 127 using UserlandFSUtil::DriverSettings; 128 using UserlandFSUtil::DriverParameter; 129 130 #endif // USERLAND_FS_DRIVER_SETTINGS_H 131