22#ifndef DEVICEBUILDER_HPP
23#define DEVICEBUILDER_HPP
27#include <libm2k/m2kglobal.hpp>
28#include <libm2k/context.hpp>
30#include <unordered_set>
47class LIBM2K_API ContextBuilder {
48 static std::vector<Context*> s_connectedDevices;
53 explicit ContextBuilder();
69 static Context* contextOpen(
const char*);
73 static Context* contextOpen(
struct iio_context*,
const char*);
77 static Context* contextOpen();
81 static M2k*
m2kOpen(
const char*);
85 static M2k*
m2kOpen(
struct iio_context*,
const char*);
105 static std::map<ContextTypes, std::vector<std::string>> m_dev_map;
106 static std::map<ContextTypes, std::string> m_dev_name_map;
108 static ContextTypes identifyContext(iio_context *ctx);
109 static Context* buildContext(ContextTypes type,
111 struct iio_context *ctx,
113 bool ownsContext =
false);
114 static bool m_disable_logging;
116 static std::map<std::string, int> reference_count;
117 static void incrementReferenceCount(std::string uri);
118 static void decrementReferenceCount(std::string uri);
119 static bool checkLastReference(std::string uri);
120 static Context* searchInConnectedDevices(std::string uri);
135LIBM2K_API Context* contextOpen();
141LIBM2K_API Context* contextOpen(
const char* uri);
147LIBM2K_API Context* contextOpen(
struct iio_context* ctx,
const char* uri);
170LIBM2K_API
M2k*
m2kOpen(
struct iio_context* ctx,
const char* uri);
Controls the IIO context.
Definition context.hpp:52
Controls the ADALM2000.
Definition m2k.hpp:55
Generic M2K enumerations.
LIBM2K_API std::vector< std::string > getAllContexts()
List all available contexts.
LIBM2K_API void enableLogging(bool enable)
Enable/disable the logging system.
LIBM2K_API M2k * m2kOpen()
Open an ADALM2000.
LIBM2K_API void contextClose(Context *ctx, bool deinit=true)
Destroy the given context.
LIBM2K_API std::vector< struct libm2k::CONTEXT_INFO * > getContextsInfo()
List the information about all available contexts.
LIBM2K_API M2k * m2kOpen(const char *uri)
Open an ADALM2000 based on a given uri.
LIBM2K_API void contextCloseAll()
Close all the devices.
LIBM2K_API std::string getVersion()
Get library version.