]> git.donarmstrong.com Git - mothur.git/blob - commandfactory.cpp
working on libshuff
[mothur.git] / commandfactory.cpp
1 /*
2  *  commandfactory.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 10/25/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
10 #include "command.hpp"
11 #include "readdistcommand.h"
12 #include "readtreecommand.h"
13 #include "readotucommand.h"
14 #include "clustercommand.h"
15 #include "parselistcommand.h"
16 #include "collectcommand.h"
17 #include "collectsharedcommand.h"
18 #include "getgroupcommand.h"
19 #include "getlabelcommand.h"
20 #include "getlinecommand.h"
21 #include "rarefactcommand.h"
22 #include "summarycommand.h"
23 #include "summarysharedcommand.h"
24 #include "rarefactsharedcommand.h"
25 #include "nocommand.h"
26 #include "quitcommand.h"
27 #include "helpcommand.h"
28 #include "commandfactory.hpp"
29 #include "deconvolutecommand.h"
30 #include "parsimonycommand.h"
31 #include "unifracunweightedcommand.h"
32 #include "unifracweightedcommand.h"
33 #include "libshuffcommand.h"
34 #include "mothur.h"
35
36
37 /***********************************************************/
38
39 /***********************************************************/
40 CommandFactory::CommandFactory(){
41         command = new NoCommand();
42 }
43
44 /***********************************************************/
45
46 /***********************************************************/
47 CommandFactory::~CommandFactory(){
48         delete command;
49 }
50
51 /***********************************************************/
52
53 /***********************************************************/
54 //This function calls the appropriate command fucntions based on user input.
55 Command* CommandFactory::getCommand(string commandName){
56         try {
57                 delete command;   //delete the old command
58
59                          if(commandName == "read.dist")                         {       command = new ReadDistCommand();                        }
60                 else if(commandName == "read.otu")                              {       command = new ReadOtuCommand();                         }
61                 else if(commandName == "read.tree")                             {       command = new ReadTreeCommand();                        }
62                 else if(commandName == "cluster")                               {       command = new ClusterCommand();                         }
63                 else if(commandName == "deconvolute")                   {       command = new DeconvoluteCommand();                     }
64                 else if(commandName == "parsimony")                             {       command = new ParsimonyCommand();                       }
65                 else if(commandName == "help")                                  {       command = new HelpCommand();                            }
66                 else if(commandName == "quit")                                  {       command = new QuitCommand();                            }
67                 else if(commandName == "collect.single")                {       command = new CollectCommand();                         }
68                 else if(commandName == "collect.shared")                {       command = new CollectSharedCommand();           }
69                 else if(commandName == "rarefaction.single")    {       command = new RareFactCommand();                        }
70                 else if(commandName == "rarefaction.shared")    {       command = new RareFactSharedCommand();          }
71                 else if(commandName == "summary.single")                {       command = new SummaryCommand();                         }
72                 else if(commandName == "summary.shared")                {       command = new SummarySharedCommand();           }
73                 else if(commandName == "unifrac.weighted")              {       command = new UnifracWeightedCommand();         }
74                 else if(commandName == "unifrac.unweighted")    {       command = new UnifracUnweightedCommand();       }
75                 else if(commandName == "get.group")             {   command = new GetgroupCommand();                    }
76                 else if(commandName == "get.label")             {   command = new GetlabelCommand();                    }
77                 else if(commandName == "get.line")              {   command = new GetlineCommand();                             }
78                 else if(commandName == "libshuff")              {   command = new LibShuffCommand();                    }
79                 else                                                                                    {       command = new NoCommand();                                      }
80
81                 return command;
82         }
83         catch(exception& e) {
84                 cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
85                 exit(1);
86         }
87         catch(...) {
88                 cout << "An unknown error has occurred in the CommandFactory class function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
89                 exit(1);
90         }
91
92 }
93 /***********************************************************/
94