4 * Home page of code is: http://smartmontools.sourceforge.net
6 * Copyright (C) 2008 Christian Franke <smartmontools-support@lists.sourceforge.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * You should have received a copy of the GNU General Public License
14 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
18 #ifndef DEV_TUNNELLED_H
19 #define DEV_TUNNELLED_H
21 #define DEV_TUNNELLED_H_CVSID "$Id: dev_tunnelled.h,v 1.1 2008/07/25 21:16:00 chrfranke Exp $\n"
23 #include "dev_interface.h"
25 /////////////////////////////////////////////////////////////////////////////
26 // tunnelled_device_base
28 /// Common functionality for all tunnelled_device classes.
30 class tunnelled_device_base
31 : virtual public /*implements*/ smart_device
34 explicit tunnelled_device_base(smart_device
* tunnel_dev
);
37 virtual ~tunnelled_device_base() throw();
39 virtual bool is_open() const;
45 virtual bool owns(const smart_device
* dev
) const;
47 virtual void release(const smart_device
* dev
);
50 smart_device
* m_tunnel_base_dev
;
54 /////////////////////////////////////////////////////////////////////////////
57 /// Implement a device by tunneling through another device
59 template <class BaseDev
, class TunnelDev
>
60 class tunnelled_device
62 public tunnelled_device_base
65 typedef TunnelDev tunnel_device_type
;
68 explicit tunnelled_device(tunnel_device_type
* tunnel_dev
)
69 : smart_device(smart_device::never_called
),
70 tunnelled_device_base(tunnel_dev
),
71 m_tunnel_dev(tunnel_dev
)
75 virtual void release(const smart_device
* dev
)
77 if (m_tunnel_dev
== dev
)
79 tunnelled_device_base::release(dev
);
82 tunnel_device_type
* get_tunnel_dev()
83 { return m_tunnel_dev
; }
85 const tunnel_device_type
* get_tunnel_dev() const
86 { return m_tunnel_dev
; }
89 tunnel_device_type
* m_tunnel_dev
;
92 #endif // DEV_TUNNELLED_H