blob: cac0b85c53dadc79e3d9b272e64e3c826decf670 [file] [log] [blame]
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <iio.h>
#include <memory>
#include <string>
#include "libmems/export.h"
#include "libmems/iio_channel.h"
namespace libmems {
class IioDevice;
class LIBMEMS_EXPORT IioChannelImpl : public IioChannel {
// iio_channel objects are kept alive by the IioContextImpl.
IioChannelImpl(iio_channel* channel, int device_id, const char* device_name);
IioChannelImpl(const IioChannelImpl&) = delete;
IioChannelImpl& operator=(const IioChannelImpl&) = delete;
~IioChannelImpl() override = default;
const char* GetId() const override;
bool IsEnabled() const override;
void SetEnabled(bool en) override;
bool SetScanElementsEnabled(bool en) override;
base::Optional<std::string> ReadStringAttribute(
const std::string& name) const override;
base::Optional<int64_t> ReadNumberAttribute(
const std::string& name) const override;
base::Optional<double> ReadDoubleAttribute(
const std::string& name) const override;
bool WriteStringAttribute(const std::string& name,
const std::string& value) override;
bool WriteNumberAttribute(const std::string& name, int64_t value) override;
bool WriteDoubleAttribute(const std::string& name, double value) override;
base::Optional<int64_t> Convert(const uint8_t* src) const;
base::Optional<uint64_t> Length() const;
iio_channel* const channel_; // non-owned
std::string log_prefix_;
} // namespace libmems