Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

JobCMethod.cxx

Go to the documentation of this file.
00001 
00002 // $Id: JobCMethod.cxx,v 1.18 2009/02/28 21:46:13 gmieg Exp $
00003 //
00004 // Class for the possible methods that can hang of a job module and be
00005 // added to a path
00006 //
00007 // messier@huhepl.harvard.edu
00009 #include <cassert>
00010 
00011 #include "JobControl/JobCMethod.h"
00012 #include "MessageService/MsgService.h"
00013 #include "JobControl/JobCResult.h"
00014 #include "JobControl/JobCModule.h"
00015 
00016 //......................................................................
00017 
00018 CVSID("$Id: JobCMethod.cxx,v 1.18 2009/02/28 21:46:13 gmieg Exp $");
00019 
00020 //......................................................................
00021 
00022 const JobCMethod* JobCMethod::GetMethodByName(const string& m) 
00023 {
00024 //======================================================================
00025 // Return a pointer to a method specified name name m
00026 //======================================================================
00027   if (m == "Get") {
00028     static const JobCMethod get(JobCMethod::kGet);
00029     return &get;
00030   }
00031   if (m == "Put") {
00032     static const JobCMethod put(JobCMethod::kPut);
00033     return &put;
00034   }
00035   if (m == "Ana") {
00036     static const JobCMethod ana(JobCMethod::kAna);
00037     return &ana;
00038   }
00039   if (m == "Reco") {
00040     static const JobCMethod reco(JobCMethod::kReco);
00041     return &reco;
00042   }
00043   if (m == "Void") {
00044     static const JobCMethod voidmethod(JobCMethod::kVoidMethod);
00045     return &voidmethod;
00046   }
00047   MSG("JobC",Msg::kError) << "method name = " << m << "\n";
00048   return 0;
00049 }
00050 
00051 //......................................................................
00052 
00053 JobCMethod::JobCMethod(JobCMethod::Method_t code) : fMethodCode(code) { }
00054 
00055 //......................................................................
00056 
00057 JobCResult JobCMethod::Execute(JobCModule* mod, MomNavigator* mom) const
00058 {
00059 //======================================================================
00060 // Purpose: Pass the "MINOSObjectMap" to a specific method of a module
00061 //          for processing
00062 //
00063 // Inputs: mom - pointer to the "MINOSObjectMap"
00064 //         mod - pointer to a a job module
00065 //
00066 // Returns: Pass/Fail/NoDecision
00067 //======================================================================
00068   switch(fMethodCode) {
00069   case JobCMethod::kGet:            return mod->Get(mom);
00070   case JobCMethod::kPut:            return mod->Put(mom);
00071   case JobCMethod::kAna:            return mod->Ana(mom);
00072   case JobCMethod::kReco:           return mod->Reco(mom);
00073   default:
00074     MSG("JobC", Msg::kFatal) 
00075       << "Attempt to execute invalid JobCMethod. Code=" 
00076       << (int)fMethodCode << "\n";
00077     abort();
00078     break;
00079   }
00080   // Should never get here but this keeps compilers quiet
00081   return JobCResult::kFatal;
00082 }
00083 
00084 //......................................................................
00085 
00086 bool JobCMethod::Exists(const JobCModule* /* module */ ) const
00087 {
00088 //======================================================================
00089 // Purpose: Test if a module implements this method
00090 // 
00091 // Note: I can't think of a good way to do this yet so for now this
00092 // does nothing
00093 //======================================================================
00094   return true;
00095 }
00096 
00097 //......................................................................
00098 
00099 const char* JobCMethod::GetName() const 
00100 {
00101 //======================================================================
00102 // Purpose: What is the name of this Module??
00103 // Returns: The name of this module
00104 //======================================================================
00105   // The order and content of gsMethodName and gsMethodCode must match
00106   // exactly
00107   static const char *gsMethodName[] = {
00108     "Void",
00109     "Get",
00110     "Put",
00111     "Ana",
00112     "Reco",
00113   };
00114   return gsMethodName[fMethodCode];
00115 }
00116 
00117 //......................................................................
00118 
00119 int JobCMethod::operator==(JobCMethod::Method_t rhs) const
00120 {
00121 //======================================================================
00122 // Purpose: Test for equality betweeb two methods
00123 //
00124 // Returns: true/false (0 or 1)
00125 //======================================================================
00126   return (fMethodCode == rhs);
00127 }
00128 
00129 //......................................................................
00130 
00131 int JobCMethod::operator!=(JobCMethod::Method_t rhs) const
00132 {
00133 //======================================================================
00134 // Purpose: Test for equality betweeb two methods
00135 //
00136 // Returns: true/false (0 or 1)
00137 //======================================================================
00138   return (fMethodCode != rhs);
00139 }
00140 

Generated on Mon Feb 15 11:06:49 2010 for loon by  doxygen 1.3.9.1