smartmontools SVN Rev 3317
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
smart_device Class Reference

Base class for all devices. More...

#include <dev_interface.h>

Collaboration diagram for smart_device:
Collaboration graph
[legend]

List of all members.

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

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.
 smart_device (do_not_use_in_implementation_classes)
 Dummy constructor for abstract classes.
device_infoset_info ()
 R/W access to device info struct.
smart_interfacesmi ()
 Get interface which produced this object.
const smart_interfacesmi () const
 Get interface which produced this object (const).

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::legacy_scsi_device, os_freebsd::freebsd_scsi_device, os_freebsd::freebsd_areca_ata_device, os_freebsd::freebsd_areca_scsi_device, os_linux::linux_scsi_device, os_linux::linux_megaraid_device, os_linux::linux_areca_ata_device, os_linux::linux_areca_scsi_device, os_win32::win_areca_ata_device, os_win32::win_areca_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]
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 ( ) [inline, protected]

R/W access to device info struct.

Definition at line 133 of file dev_interface.h.

const smart_interface* smart_device::smi ( ) const [inline, protected]

Get interface which produced this object (const).

Definition at line 209 of file dev_interface.h.

smart_interface* smart_device::smi ( ) [inline, protected]

Get interface which produced this object.

Definition at line 206 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.

ata_device* smart_device::to_ata ( ) [inline]

Downcast to ATA device.

Definition at line 99 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

Definition at line 221 of file dev_interface.h.

Definition at line 216 of file dev_interface.h.

Definition at line 215 of file dev_interface.h.

Definition at line 214 of file dev_interface.h.

Definition at line 223 of file dev_interface.h.


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