tzwrapper.cc: fixed use of iterator after erase
[barry.git] / src / controllerpriv.h
blob0bd7b203d0c801beae5a0797d9546c1b77a518e6
1 ///
2 /// \file controllerpriv.h
3 /// Private data for the Controller class
4 ///
6 /*
7 Copyright (C) 2005-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_CONTROLLERPRIVATE_H__
23 #define __BARRY_CONTROLLERPRIVATE_H__
25 #include "probe.h"
26 #include "pin.h"
27 #include "socket.h"
28 #include "router.h"
29 #include "m_ipmodem.h"
31 namespace Barry {
33 class Controller;
35 class PrivateControllerData
37 friend class Controller;
39 // DO NOT add your Mode class to this list unless it *needs*
40 // low level access to things like Usb::Device. By adding
41 // your Mode class to this list, you are making it non-portable.
42 friend class Barry::Mode::IpModem;
45 private:
46 ProbeResult m_result;
47 Usb::Device m_dev;
48 Usb::Interface *m_iface;
49 Pin m_pin;
50 SocketZero m_zero;
51 SocketRoutingQueue *m_queue; //< ptr to external object; no delete
53 private:
54 PrivateControllerData(const ProbeResult &device, int default_timeout)
55 : m_result(device)
56 , m_dev(device.m_dev, default_timeout)
57 , m_iface(0)
58 , m_pin(device.m_pin)
59 , m_zero(m_dev, device.m_ep.write, device.m_ep.read, device.m_zeroSocketSequence)
60 , m_queue(0)
64 PrivateControllerData(const ProbeResult &device,
65 SocketRoutingQueue &queue, int default_timeout)
66 : m_result(device)
67 , m_dev(device.m_dev, default_timeout)
68 , m_iface(0)
69 , m_pin(device.m_pin)
70 , m_zero(queue, device.m_ep.write, device.m_zeroSocketSequence)
71 , m_queue(&queue)
75 public:
76 ~PrivateControllerData()
78 // detach the router from our device
79 if( m_queue ) {
80 m_queue->ClearUsbDevice();
81 m_queue = 0;
84 // cleanup the interface
85 delete m_iface;
89 } // namespace Barry
91 #endif