copyright : (C) 2008 by Marek Vavruša
email : opensource@intra2net.com and marek@vavrusa.com
***************************************************************************/
+/*
+Copyright (C) 2008 by Marek Vavruša
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Lesser General Public License *
- * version 2.1 as published by the Free Software Foundation; *
- * *
- ***************************************************************************/
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
#include "ftdi.hpp"
#include "ftdi.h"
{
public:
Private()
- : ftdi(0), dev(0), open(false)
+ : ftdi(0), dev(0), open(false)
{
+ ftdi = ftdi_new();
+ }
+
+ ~Private()
+ {
+ if (open)
+ ftdi_usb_close(ftdi);
+
+ ftdi_free(ftdi);
}
bool open;
Context::Context()
: d( new Private() )
{
- d->ftdi = ftdi_new();
}
/*! \brief Destructor.
*/
Context::~Context()
{
- if (d->open)
- close();
-
- ftdi_free(d->ftdi);
- delete d;
}
bool Context::is_open()
Eeprom::~Eeprom()
{
- delete d;
}
void Eeprom::init_defaults()
class List::Private
{
public:
- Private()
- : list(0)
+ Private(struct ftdi_device_list* devlist)
+ : list(devlist)
{}
+ ~Private()
+ {
+ ftdi_list_free(&list);
+ }
+
struct ftdi_device_list* list;
};
List::List(struct ftdi_device_list* devlist)
- : ListBase(), d( new Private() )
+ : ListBase(), d( new Private(devlist) )
{
if (devlist != 0)
{
// Iterate list
- Context* c = 0;
for (d->list = devlist; d->list != 0; d->list = d->list->next)
{
- c = new Context();
- c->set_usb_device(d->list->dev);
+ Context c;
+ c.set_usb_device(d->list->dev);
+ c.get_strings();
push_back(c);
}
-
- // Store pointer
- d->list = devlist;
}
}
List::~List()
{
- // Deallocate instances
- for (iterator it = begin(); it != end(); it++)
- delete *it;
-
- // Clear list
- clear();
- ftdi_list_free(&d->list);
-
- // Delete d-ptr
- delete d;
}
List* List::find_all(int vendor, int product)