kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Reuse generic value filtering code for scan method filtering
rodzic
c234ce6b77
commit
c1d4369410
|
@ -111,7 +111,6 @@ class ScannerInterfaceUsb;
|
||||||
class TestScannerInterface;
|
class TestScannerInterface;
|
||||||
|
|
||||||
// sensor.h
|
// sensor.h
|
||||||
class ScanMethodFilter;
|
|
||||||
struct GenesysFrontendLayout;
|
struct GenesysFrontendLayout;
|
||||||
struct Genesys_Frontend;
|
struct Genesys_Frontend;
|
||||||
struct SensorExposure;
|
struct SensorExposure;
|
||||||
|
|
|
@ -154,7 +154,7 @@ struct MotorProfile
|
||||||
// the resolutions this profile is good for
|
// the resolutions this profile is good for
|
||||||
ValueFilterAny<unsigned> resolutions = VALUE_FILTER_ANY;
|
ValueFilterAny<unsigned> resolutions = VALUE_FILTER_ANY;
|
||||||
// the scan method this profile is good for. If the list is empty, good for any method.
|
// the scan method this profile is good for. If the list is empty, good for any method.
|
||||||
ScanMethodFilter scan_methods = ScanMethodFilter::ANY;
|
ValueFilterAny<ScanMethod> scan_methods = VALUE_FILTER_ANY;
|
||||||
|
|
||||||
unsigned max_exposure = 0; // 0 - any exposure
|
unsigned max_exposure = 0; // 0 - any exposure
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,16 +117,6 @@ std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const ScanMethodFilter& methods)
|
|
||||||
{
|
|
||||||
if (methods.matches_any()) {
|
|
||||||
out << "ANY";
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
out << format_vector_unsigned(4, methods.methods());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
|
std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
out << "Genesys_Sensor{\n"
|
out << "Genesys_Sensor{\n"
|
||||||
|
|
|
@ -248,46 +248,6 @@ struct SensorExposure {
|
||||||
std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure);
|
std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure);
|
||||||
|
|
||||||
|
|
||||||
class ScanMethodFilter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct Any {};
|
|
||||||
static constexpr Any ANY{};
|
|
||||||
|
|
||||||
ScanMethodFilter() : matches_any_{false} {}
|
|
||||||
ScanMethodFilter(Any) : matches_any_{true} {}
|
|
||||||
ScanMethodFilter(std::initializer_list<ScanMethod> methods) :
|
|
||||||
matches_any_{false},
|
|
||||||
methods_{methods}
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool matches(ScanMethod method) const
|
|
||||||
{
|
|
||||||
if (matches_any_)
|
|
||||||
return true;
|
|
||||||
auto it = std::find(methods_.begin(), methods_.end(), method);
|
|
||||||
return it != methods_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const ScanMethodFilter& other) const
|
|
||||||
{
|
|
||||||
return matches_any_ == other.matches_any_ && methods_ == other.methods_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool matches_any() const { return matches_any_; }
|
|
||||||
const std::vector<ScanMethod>& methods() const { return methods_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool matches_any_ = false;
|
|
||||||
std::vector<ScanMethod> methods_;
|
|
||||||
|
|
||||||
template<class Stream>
|
|
||||||
friend void serialize(Stream& str, ScanMethodFilter& x);
|
|
||||||
};
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const ScanMethodFilter& methods);
|
|
||||||
|
|
||||||
|
|
||||||
struct Genesys_Sensor {
|
struct Genesys_Sensor {
|
||||||
|
|
||||||
Genesys_Sensor() = default;
|
Genesys_Sensor() = default;
|
||||||
|
|
|
@ -287,7 +287,7 @@ void genesys_init_motor_tables()
|
||||||
profile.step_type = StepType::QUARTER;
|
profile.step_type = StepType::QUARTER;
|
||||||
profile.motor_vref = 2;
|
profile.motor_vref = 2;
|
||||||
profile.resolutions = VALUE_FILTER_ANY;
|
profile.resolutions = VALUE_FILTER_ANY;
|
||||||
profile.scan_methods = ScanMethodFilter::ANY;
|
profile.scan_methods = VALUE_FILTER_ANY;
|
||||||
motor.fast_profiles.push_back(std::move(profile));
|
motor.fast_profiles.push_back(std::move(profile));
|
||||||
|
|
||||||
s_motors->push_back(std::move(motor));
|
s_motors->push_back(std::move(motor));
|
||||||
|
|
Ładowanie…
Reference in New Issue