blob: e44583e25adf5fa28250e1c0c2604cf1bc447dc7 [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.
#ifndef LIBMEMS_IIO_CHANNEL_H_
#define LIBMEMS_IIO_CHANNEL_H_
#include <string>
#include <base/macros.h>
#include <base/optional.h>
#include "libmems/export.h"
namespace libmems {
class LIBMEMS_EXPORT IioDevice;
// The IioChannel represents a channel on an IIO device, for example the
// X axis on an accelerometer.
// Channels can be enabled and/or disabled via this class.
class IioChannel {
public:
virtual ~IioChannel() = default;
// Returns the unique ID of this channel.
virtual const char* GetId() const = 0;
// Returns true if this channel is enabled.
virtual bool IsEnabled() const = 0;
// Sets this channel's enabled status to |en|.
// Returns false on failure.
virtual bool SetEnabled(bool en) = 0;
// Reads the |name| attribute of this channel and returns the value
// as a string. It will return base::nullopt if the attribute cannot
// be read.
virtual base::Optional<std::string> ReadStringAttribute(
const std::string& name) const = 0;
// Reads the |name| attribute of this channel and returns the value
// as a signed number. It will return base::nullopt if the attribute
// cannot be read or is not a valid number.
virtual base::Optional<int64_t> ReadNumberAttribute(
const std::string& name) const = 0;
protected:
IioChannel() = default;
private:
DISALLOW_COPY_AND_ASSIGN(IioChannel);
};
} // namespace libmems
#endif // LIBMEMS_IIO_CHANNEL_H_