controllerpriv.h

Go to the documentation of this file.
00001 ///
00002 /// \file       controllerpriv.h
00003 ///             Private data for the Controller class
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/)
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #ifndef __BARRY_CONTROLLERPRIVATE_H__
00023 #define __BARRY_CONTROLLERPRIVATE_H__
00024 
00025 #include "probe.h"
00026 #include "pin.h"
00027 #include "socket.h"
00028 #include "router.h"
00029 #include "m_ipmodem.h"
00030 
00031 namespace Barry {
00032 
00033 class Controller;
00034 
00035 class PrivateControllerData
00036 {
00037         friend class Controller;
00038 
00039         // DO NOT add your Mode class to this list unless it *needs*
00040         // low level access to things like Usb::Device.  By adding
00041         // your Mode class to this list, you are making it non-portable.
00042         friend class Barry::Mode::IpModem;
00043 
00044 
00045 private:
00046         ProbeResult m_result;
00047         Usb::Device m_dev;
00048         Usb::Interface *m_iface;
00049         Pin m_pin;
00050         SocketZero m_zero;
00051         SocketRoutingQueue *m_queue;    //< ptr to external object; no delete
00052 
00053 private:
00054         PrivateControllerData(const ProbeResult &device, int default_timeout)
00055                 : m_result(device)
00056                 , m_dev(device.m_dev, default_timeout)
00057                 , m_iface(0)
00058                 , m_pin(device.m_pin)
00059                 , m_zero(m_dev, device.m_ep.write, device.m_ep.read, device.m_zeroSocketSequence)
00060                 , m_queue(0)
00061         {
00062         }
00063 
00064         PrivateControllerData(const ProbeResult &device,
00065                 SocketRoutingQueue &queue, int default_timeout)
00066                 : m_result(device)
00067                 , m_dev(device.m_dev, default_timeout)
00068                 , m_iface(0)
00069                 , m_pin(device.m_pin)
00070                 , m_zero(queue, device.m_ep.write, device.m_zeroSocketSequence)
00071                 , m_queue(&queue)
00072         {
00073         }
00074 
00075 public:
00076         ~PrivateControllerData()
00077         {
00078                 // detach the router from our device
00079                 if( m_queue ) {
00080                         m_queue->ClearUsbDevice();
00081                         m_queue = 0;
00082                 }
00083 
00084                 // cleanup the interface
00085                 delete m_iface;
00086         }
00087 };
00088 
00089 } // namespace Barry
00090 
00091 #endif