2013-09-30 03:11:23 +04:00
|
|
|
/*
|
2015-03-04 01:48:26 +03:00
|
|
|
* Copyright 2006-2015, Haiku, Inc. All Rights Reserved.
|
2013-09-30 03:11:23 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
* Michael Lotz <mmlr@mlotz.ch>
|
|
|
|
*/
|
|
|
|
#ifndef DRIVER_SETTINGS_MESSAGE_ADAPTER_H
|
|
|
|
#define DRIVER_SETTINGS_MESSAGE_ADAPTER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <driver_settings.h>
|
|
|
|
#include <Message.h>
|
|
|
|
|
|
|
|
|
2015-03-04 01:48:26 +03:00
|
|
|
class DriverSettingsConverter {
|
|
|
|
public:
|
|
|
|
DriverSettingsConverter();
|
|
|
|
virtual ~DriverSettingsConverter();
|
|
|
|
|
|
|
|
virtual status_t ConvertFromDriverSettings(
|
|
|
|
const driver_parameter& parameter,
|
2015-03-23 19:54:41 +03:00
|
|
|
const char* name, int32 index, uint32 type,
|
2015-06-18 00:03:30 +03:00
|
|
|
BMessage& target);
|
|
|
|
virtual status_t ConvertEmptyFromDriverSettings(
|
|
|
|
const driver_parameter& parameter,
|
|
|
|
const char* name, uint32 type,
|
|
|
|
BMessage& target);
|
|
|
|
|
2015-03-04 01:48:26 +03:00
|
|
|
virtual status_t ConvertToDriverSettings(const BMessage& source,
|
|
|
|
const char* name, int32 index,
|
2015-06-18 00:03:30 +03:00
|
|
|
uint32 type, BString& value);
|
2015-03-04 01:48:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-09-30 03:11:23 +04:00
|
|
|
struct settings_template {
|
|
|
|
uint32 type;
|
|
|
|
const char* name;
|
|
|
|
const settings_template* sub_template;
|
|
|
|
bool parent_value;
|
2015-03-04 01:48:26 +03:00
|
|
|
DriverSettingsConverter* converter;
|
2013-09-30 03:11:23 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DriverSettingsMessageAdapter {
|
|
|
|
public:
|
|
|
|
DriverSettingsMessageAdapter();
|
|
|
|
~DriverSettingsMessageAdapter();
|
|
|
|
|
|
|
|
status_t ConvertFromDriverSettings(
|
|
|
|
const driver_settings& settings,
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
BMessage& message);
|
|
|
|
status_t ConvertFromDriverSettings(const char* path,
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
BMessage& message);
|
|
|
|
|
|
|
|
status_t ConvertToDriverSettings(
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
BString& settings, const BMessage& message);
|
|
|
|
status_t ConvertToDriverSettings(const char* path,
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
const BMessage& message);
|
|
|
|
|
|
|
|
private:
|
|
|
|
const settings_template* _FindSettingsTemplate(
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
const char* name);
|
|
|
|
const settings_template* _FindParentValueTemplate(
|
|
|
|
const settings_template* settingsTemplate);
|
|
|
|
status_t _AddParameter(const driver_parameter& parameter,
|
2015-03-04 01:48:26 +03:00
|
|
|
const settings_template& settingsTemplate,
|
2013-09-30 03:11:23 +04:00
|
|
|
BMessage& message);
|
|
|
|
|
|
|
|
status_t _ConvertFromDriverParameter(
|
|
|
|
const driver_parameter& parameter,
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
BMessage& message);
|
|
|
|
|
|
|
|
status_t _AppendSettings(
|
|
|
|
const settings_template* settingsTemplate,
|
|
|
|
BString& settings, const BMessage& message,
|
|
|
|
const char* name, type_code type,
|
|
|
|
int32 count,
|
|
|
|
const char* settingName = NULL);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DRIVER_SETTINGS_MESSAGE_ADAPTER_H
|