Enrico Granata | 60a818d | 2019-05-09 09:56:09 -0700 | [diff] [blame^] | 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef MEMS_SETUP_IIO_CONTEXT_IMPL_H_ |
| 6 | #define MEMS_SETUP_IIO_CONTEXT_IMPL_H_ |
| 7 | |
| 8 | #include <iio.h> |
| 9 | |
| 10 | #include <map> |
| 11 | #include <memory> |
| 12 | #include <string> |
| 13 | #include <vector> |
| 14 | |
| 15 | #include "mems_setup/iio_context.h" |
| 16 | |
| 17 | namespace mems_setup { |
| 18 | |
| 19 | class IioContextImpl : public IioContext { |
| 20 | public: |
| 21 | IioContextImpl(); |
| 22 | ~IioContextImpl() override = default; |
| 23 | |
| 24 | void Reload() override; |
| 25 | IioDevice* GetDevice(const std::string& name) override; |
| 26 | |
| 27 | private: |
| 28 | using ContextUniquePtr = |
| 29 | std::unique_ptr<iio_context, decltype(&iio_context_destroy)>; |
| 30 | |
| 31 | iio_context* GetCurrentContext() const; |
| 32 | |
| 33 | std::map<std::string, std::unique_ptr<IioDevice>> devices_; |
| 34 | std::vector<ContextUniquePtr> context_; |
| 35 | |
| 36 | DISALLOW_COPY_AND_ASSIGN(IioContextImpl); |
| 37 | }; |
| 38 | |
| 39 | } // namespace mems_setup |
| 40 | |
| 41 | #endif // MEMS_SETUP_IIO_CONTEXT_IMPL_H_ |