1 /// 2 /// \file SoapySDR/Registry.hpp 3 /// 4 /// Device factory registration API. 5 /// 6 /// \copyright 7 /// Copyright (c) 2014-2015 Josh Blum 8 /// SPDX-License-Identifier: BSL-1.0 9 /// 10 11 #pragma once 12 #include <SoapySDR/Config.hpp> 13 #include <SoapySDR/Version.hpp> 14 #include <SoapySDR/Types.hpp> 15 #include <vector> 16 #include <string> 17 #include <map> 18 19 namespace SoapySDR 20 { 21 22 //! forward declaration of device 23 class Device; 24 25 //! typedef for a device enumeration function 26 typedef KwargsList (*FindFunction)(const Kwargs &); 27 28 //! typedef for a device factory function 29 typedef Device* (*MakeFunction)(const Kwargs &); 30 31 //! typedef for a dictionary of find functions 32 typedef std::map<std::string, FindFunction> FindFunctions; 33 34 //! typedef for a dictionary of make functions 35 typedef std::map<std::string, MakeFunction> MakeFunctions; 36 37 /*! 38 * A registry object loads device functions into the global registry. 39 */ 40 class SOAPY_SDR_API Registry 41 { 42 public: 43 44 /*! 45 * Register a SDR device find and make function. 46 * \param name a unique name to identify the entry 47 * \param find the find function returns an arg list 48 * \param make the make function returns a device sptr 49 * \param abi this value must be SOAPY_SDR_ABI_VERSION 50 */ 51 Registry(const std::string &name, const FindFunction &find, const MakeFunction &make, const std::string &abi); 52 53 //! Cleanup this registry entry 54 ~Registry(void); 55 56 /*! 57 * List all loaded find functions. 58 * \return a dictionary of registry entry names to find functions 59 */ 60 static FindFunctions listFindFunctions(void); 61 62 /*! 63 * List all loaded make functions. 64 * \return a dictionary of registry entry names to make functions 65 */ 66 static MakeFunctions listMakeFunctions(void); 67 68 private: 69 std::string _name; 70 }; 71 72 } 73