]> git.donarmstrong.com Git - mothur.git/blob - commandfactory.cpp
finishing the container classes, combining read.otu and read.list commands. some...
[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 "readotucommand.h"
13 #include "clustercommand.h"
14 #include "parselistcommand.h"
15 #include "collectcommand.h"
16 #include "collectsharedcommand.h"
17 #include "rarefactcommand.h"
18 #include "summarycommand.h"
19 #include "summarysharedcommand.h"
20 #include "rarefactsharedcommand.h"
21 #include "nocommand.h"
22 #include "quitcommand.h"
23 #include "helpcommand.h"
24 #include "commandfactory.hpp"
25 #include "deconvolutecommand.h"
26 #include <exception>
27
28
29 /***********************************************************/
30
31 /***********************************************************/
32 CommandFactory::CommandFactory(){
33         command = new NoCommand();
34 }
35
36 /***********************************************************/
37
38 /***********************************************************/
39 CommandFactory::~CommandFactory(){
40         delete command;
41 }
42
43 /***********************************************************/
44
45 /***********************************************************/
46 //This function calls the appropriate command fucntions based on user input.
47 Command* CommandFactory::getCommand(string commandName){
48         try {
49                 delete command;   //delete the old command
50
51                          if(commandName == "read.dist")                         {       command = new ReadDistCommand();                }
52                 else if(commandName == "read.otu")                              {       command = new ReadOtuCommand();                 }
53                 else if(commandName == "cluster")                               {       command = new ClusterCommand();                 }
54                 else if(commandName == "deconvolute")                   {       command = new DeconvoluteCommand();             }
55                 else if(commandName == "help")                                  {       command = new HelpCommand();                    }
56                 else if(commandName == "quit")                                  {       command = new QuitCommand();                    }
57                 else if(commandName == "collect.single")                {       command = new CollectCommand();                 }
58                 else if(commandName == "collect.shared")                {       command = new CollectSharedCommand();   }
59                 else if(commandName == "rarefaction.single")    {       command = new RareFactCommand();                }
60                 else if(commandName == "rarefaction.shared")    {       command = new RareFactSharedCommand();  }
61                 else if(commandName == "summary.single")                {       command = new SummaryCommand();                 }
62                 else if(commandName == "summary.shared")                {       command = new SummarySharedCommand();   }
63                 else                                                                                    {       command = new NoCommand();                              }
64
65                 return command;
66         }
67         catch(exception& e) {
68                 cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
69                 exit(1);
70         }
71         catch(...) {
72                 cout << "An unknown error has occurred in the CommandFactory class function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
73                 exit(1);
74         }
75
76 }
77 /***********************************************************/
78
79 /***********************************************************/