smartmontools  SVN Rev 4071
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
smart_device Class Referenceabstract

Base class for all devices. More...

#include <dev_interface.h>

Collaboration diagram for smart_device:
Collaboration graph
[legend]

Classes

struct  device_info
 Device info strings. More...
 
struct  error_info
 Error (number,message) pair. More...
 

Public Member Functions

virtual ~smart_device () throw ()
 
bool is_ata () const
 Return true if ATA device. More...
 
bool is_scsi () const
 Return true if SCSI device. More...
 
ata_deviceto_ata ()
 Downcast to ATA device. More...
 
const ata_deviceto_ata () const
 Downcast to ATA device (const). More...
 
scsi_deviceto_scsi ()
 Downcast to SCSI device. More...
 
const scsi_deviceto_scsi () const
 Downcast to SCSI device (const). More...
 
const device_infoget_info () const
 Get device info struct. More...
 
const char * get_dev_name () const
 Get device (path)name. More...
 
const char * get_info_name () const
 Get informal name. More...
 
const char * get_dev_type () const
 Get device type. More...
 
const char * get_req_type () const
 Get type requested by user, empty if none. More...
 
const error_infoget_err () const
 Get last error info struct. More...
 
int get_errno () const
 Get last error number. More...
 
const char * get_errmsg () const
 Get last error message. More...
 
virtual bool is_syscall_unsup () const
 Return true if last error indicates an unsupported system call. More...
 
bool set_err (int no, const char *msg,...) __attribute_format_printf(3
 Set last error number and message. More...
 
bool bool set_err (const error_info &err)
 Set last error info struct. More...
 
void clear_err ()
 Clear last error info. More...
 
bool set_err (int no)
 Set last error number and default message. More...
 
virtual bool is_open () const =0
 Return true if device is open. More...
 
virtual bool open ()=0
 Open device, return false on error. More...
 
virtual bool close ()=0
 Close device, return false on error. More...
 
virtual smart_deviceautodetect_open ()
 Open device with autodetection support. More...
 
virtual bool owns (const smart_device *dev) const
 Return true if other device is owned by this device. More...
 
virtual void release (const smart_device *dev)
 Release ownership of other device. More...
 

Protected Types

enum  do_not_use_in_implementation_classes { never_called }
 Dummy enum for dummy constructor. More...
 

Protected Member Functions

 smart_device (smart_interface *intf, const char *dev_name, const char *dev_type, const char *req_type)
 Constructor to init interface and device info. More...
 
 smart_device (do_not_use_in_implementation_classes)
 Dummy constructor for abstract classes. More...
 
device_infoset_info ()
 R/W access to device info struct. More...
 
smart_interfacesmi ()
 Get interface which produced this object. More...
 
const smart_interfacesmi () const
 Get interface which produced this object (const). More...
 

Private Member Functions

 smart_device (const smart_device &)
 
void operator= (const smart_device &)
 

Private Attributes

smart_interfacem_intf
 
device_info m_info
 
error_info m_err
 
ata_devicem_ata_ptr
 
scsi_devicem_scsi_ptr
 

Friends

class ata_device
 
class scsi_device
 

Detailed Description

Base class for all devices.

Definition at line 38 of file dev_interface.h.

Member Enumeration Documentation

Dummy enum for dummy constructor.

Enumerator
never_called 

Definition at line 78 of file dev_interface.h.

Constructor & Destructor Documentation

smart_device::smart_device ( smart_interface intf,
const char *  dev_name,
const char *  dev_type,
const char *  req_type 
)
protected

Constructor to init interface and device info.

Must be called in implementation classes.

Definition at line 41 of file dev_interface.cpp.

smart_device::smart_device ( do_not_use_in_implementation_classes  )
protected

Dummy constructor for abstract classes.

Must never be called in implementation classes.

Definition at line 48 of file dev_interface.cpp.

smart_device::~smart_device ( )
throw (
)
virtual

Definition at line 54 of file dev_interface.cpp.

smart_device::smart_device ( const smart_device )
private

Member Function Documentation

smart_device * smart_device::autodetect_open ( )
virtual

Open device with autodetection support.

May return another device for further access. In this case, the original pointer is no longer valid. Default implementation calls 'open()' and returns 'this'.

Reimplemented in os_linux::linux_areca_scsi_device, os_linux::linux_areca_ata_device, os_linux::linux_megaraid_device, os_freebsd::freebsd_areca_scsi_device, os_freebsd::freebsd_areca_ata_device, os_freebsd::freebsd_scsi_device, os_linux::linux_scsi_device, os_win32::win_areca_scsi_device, os_win32::win_areca_ata_device, os::legacy_scsi_device, and sat::sat_device.

Definition at line 85 of file dev_interface.cpp.

void smart_device::clear_err ( )
inline

Clear last error info.

Definition at line 165 of file dev_interface.h.

virtual bool smart_device::close ( )
pure virtual
const char* smart_device::get_dev_name ( ) const
inline

Get device (path)name.

Definition at line 119 of file dev_interface.h.

const char* smart_device::get_dev_type ( ) const
inline

Get device type.

Definition at line 125 of file dev_interface.h.

const error_info& smart_device::get_err ( ) const
inline

Get last error info struct.

Definition at line 141 of file dev_interface.h.

const char* smart_device::get_errmsg ( ) const
inline

Get last error message.

Definition at line 147 of file dev_interface.h.

int smart_device::get_errno ( ) const
inline

Get last error number.

Definition at line 144 of file dev_interface.h.

const device_info& smart_device::get_info ( ) const
inline

Get device info struct.

Definition at line 115 of file dev_interface.h.

const char* smart_device::get_info_name ( ) const
inline

Get informal name.

Definition at line 122 of file dev_interface.h.

const char* smart_device::get_req_type ( ) const
inline

Get type requested by user, empty if none.

Definition at line 128 of file dev_interface.h.

bool smart_device::is_ata ( ) const
inline

Return true if ATA device.

Definition at line 92 of file dev_interface.h.

virtual bool smart_device::is_open ( ) const
pure virtual
bool smart_device::is_scsi ( ) const
inline

Return true if SCSI device.

Definition at line 95 of file dev_interface.h.

bool smart_device::is_syscall_unsup ( ) const
virtual

Return true if last error indicates an unsupported system call.

Default implementation returns true on ENOSYS and ENOTSUP.

Definition at line 58 of file dev_interface.cpp.

virtual bool smart_device::open ( )
pure virtual
void smart_device::operator= ( const smart_device )
private
bool smart_device::owns ( const smart_device dev) const
virtual

Return true if other device is owned by this device.

Default implementation returns false.

Reimplemented in tunnelled_device_base.

Definition at line 91 of file dev_interface.cpp.

void smart_device::release ( const smart_device dev)
virtual

Release ownership of other device.

Default implementation does nothing.

Reimplemented in tunnelled_device< BaseDev, TunnelDev >, tunnelled_device< ata_device_with_command_set, scsi_device >, tunnelled_device< ata_device, scsi_device >, and tunnelled_device_base.

Definition at line 96 of file dev_interface.cpp.

bool smart_device::set_err ( int  no,
const char *  msg,
  ... 
)

Set last error number and message.

Printf()-like formatting is supported. Returns false always to allow use as a return expression.

Definition at line 69 of file dev_interface.cpp.

bool bool smart_device::set_err ( const error_info err)
inline

Set last error info struct.

Definition at line 161 of file dev_interface.h.

bool smart_device::set_err ( int  no)

Set last error number and default message.

Message is retrieved from interface's get_msg_for_errno(no).

Definition at line 80 of file dev_interface.cpp.

device_info& smart_device::set_info ( )
inlineprotected

R/W access to device info struct.

Definition at line 133 of file dev_interface.h.

smart_interface* smart_device::smi ( )
inlineprotected

Get interface which produced this object.

Definition at line 206 of file dev_interface.h.

const smart_interface* smart_device::smi ( ) const
inlineprotected

Get interface which produced this object (const).

Definition at line 209 of file dev_interface.h.

ata_device* smart_device::to_ata ( )
inline

Downcast to ATA device.

Definition at line 99 of file dev_interface.h.

const ata_device* smart_device::to_ata ( ) const
inline

Downcast to ATA device (const).

Definition at line 102 of file dev_interface.h.

scsi_device* smart_device::to_scsi ( )
inline

Downcast to SCSI device.

Definition at line 105 of file dev_interface.h.

const scsi_device* smart_device::to_scsi ( ) const
inline

Downcast to SCSI device (const).

Definition at line 108 of file dev_interface.h.

Friends And Related Function Documentation

friend class ata_device
friend

Definition at line 220 of file dev_interface.h.

friend class scsi_device
friend

Definition at line 222 of file dev_interface.h.

Member Data Documentation

ata_device* smart_device::m_ata_ptr
private

Definition at line 221 of file dev_interface.h.

error_info smart_device::m_err
private

Definition at line 216 of file dev_interface.h.

device_info smart_device::m_info
private

Definition at line 215 of file dev_interface.h.

smart_interface* smart_device::m_intf
private

Definition at line 214 of file dev_interface.h.

scsi_device* smart_device::m_scsi_ptr
private

Definition at line 223 of file dev_interface.h.


The documentation for this class was generated from the following files: