Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

jtagctrl_factory.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of Jelie,
00003  * (c) 2002 Julien Pilet <julien.pilet@epfl.ch> and
00004  * Stephane Magnenat <stephane.magnenat@epfl.ch>
00005  *
00006  * Jelie is free software; you can redistribute it
00007  * and/or modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the License,
00009  * or (at your option) any later version.
00010  *
00011  * Jelie is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with Foobar; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00031 #include "jtagctrl_factory.h"
00032 #include <string.h>
00033 #include <stdio.h>
00034 
00035 #ifdef HAVE_CONFIG_H
00036 #include <config.h>
00037 #endif
00038 
00039 #ifdef USE_JTAG_CONTROL_EZUSB
00040 #include "ezusb_jtag.h"
00041 #endif
00042 #ifdef USE_JTAG_CONTROL_PP
00043 #include "pp_jtag.h"
00044 #endif
00045 #ifdef USE_JTAG_CONTROL_PPNEW
00046 #include "jtag_driver.h"
00047 #include "jtag_commander.h"
00048 #include "altera_jtag.h"
00049 #include "jtag_pp_commander.h"
00050 #endif // USE_JTAG_CONTROL_PPNEW
00051 
00052 JTAGControlFactory::JTAGControlFactory(void)
00053 {
00054 #ifdef USE_JTAG_CONTROL_EZUSB
00055         controls.push_back(new EzUSBJTAG());
00056 #endif
00057 #ifdef USE_JTAG_CONTROL_PP
00058         controls.push_back(new PPJTAG());
00059 #endif
00060 #ifdef USE_JTAG_CONTROL_PPNEW
00061         JTAG_Driver * driver ;
00062         driver = (JTAG_Driver *)new AlteraByteBlasterJTAG();
00063         controls.push_back(new JTAG_ParallelPort_Commander( driver )); 
00064 #endif // USE_JTAG_CONTROL_PPNEW 
00065 }
00066 
00067 JTAGControlFactory::~JTAGControlFactory(void)
00068 {
00069         for (std::vector<JTAGControl *>::iterator it=controls.begin(); it!=controls.end(); ++it)
00070         {
00071                 assert(*it);
00072                 delete (*it);
00073         }
00074         controls.clear();
00075 }
00076 
00077 JTAGControl *JTAGControlFactory::getPrefered(const char *name, int argc, char *argv[]) const
00078 {
00079         for (std::vector<JTAGControl *>::const_iterator it=controls.begin(); it!=controls.end(); ++it)
00080     {
00081                 assert(*it);
00082                 if (strcmp((*it)->getName(), name)==0)
00083                 {
00084                         if ((*it)->init(argc, argv))
00085                                 return (*it);
00086                 }
00087     }
00088         return NULL;
00089 }
00090 
00091 JTAGControl *JTAGControlFactory::getAvailable(int argc, char *argv[]) const
00092 {
00093         for (std::vector<JTAGControl *>::const_iterator it=controls.begin(); it!=controls.end(); ++it)
00094         {
00095                 assert (*it);
00096                 if ((*it)->init(argc, argv))
00097                         return (*it);
00098         }
00099         return NULL;
00100 }
00101 
00102 void JTAGControlFactory::dumpList(void) const
00103 {
00104         for (std::vector<JTAGControl *>::const_iterator it=controls.begin(); it!=controls.end(); ++it)
00105     {
00106                 assert(*it);
00107         printf("%s\n", (*it)->getName());
00108     }
00109 }

Generated on Fri May 16 13:01:45 2003 for Jelie by doxygen1.2.15