X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevices%2Fdevice.hpp;h=fd78960c153f50917eb08fca0745e54186c104f2;hp=529fdd5b33c42e0bc52fc42bb1e49a5f72559c38;hb=2601ce965fc455d23f5a964b84ddd74eb93705c4;hpb=da30ecb7e72bd2547e524258efa5ec642988b70b diff --git a/pv/devices/device.hpp b/pv/devices/device.hpp index 529fdd5b..fd78960c 100644 --- a/pv/devices/device.hpp +++ b/pv/devices/device.hpp @@ -14,45 +14,71 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #ifndef PULSEVIEW_PV_DEVICES_DEVICE_HPP #define PULSEVIEW_PV_DEVICES_DEVICE_HPP #include +#include +using std::shared_ptr; +using std::string; namespace sigrok { +class ConfigKey; class Device; class Session; } // namespace sigrok namespace pv { + +class DeviceManager; + namespace devices { class Device { protected: - Device(); + Device() = default; public: virtual ~Device(); - std::shared_ptr session() const; + shared_ptr session() const; + + shared_ptr device() const; + + template + T read_config(const sigrok::ConfigKey *key, const T default_value = 0); + + /** + * Builds the full name. It only contains all the fields. + */ + virtual string full_name() const = 0; + + /** + * Builds the display name. It only contains fields as required. + * @param device_manager a reference to the device manager is needed + * so that other similarly titled devices can be detected. + */ + virtual string display_name( + const DeviceManager &device_manager) const = 0; + + virtual void open() = 0; - std::shared_ptr device() const; + virtual void close() = 0; - virtual void create() = 0; + virtual void start(); virtual void run(); virtual void stop(); protected: - std::shared_ptr session_; - std::shared_ptr device_; + shared_ptr session_; + shared_ptr device_; }; } // namespace devices