FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
TCLProcessor.h
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2005.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Author:
11  Ron Fox
12  NSCL
13  Michigan State University
14  East Lansing, MI 48824-1321
15 */
16 
17 
18 #ifndef TCLPROCESSOR_H
19 #define TCLPROCESSOR_H
20 
21 #ifndef TCLINTERPRETEROBJECT_H
22 #include <TCLInterpreterObject.h>
23 #endif
24 
25 
26 #include <string>
27 #include <vector>
28 
29 // Forward classes
30 
31 class CTCLInterpreter;
32 class CTCLResult;
34 
47 {
48  // Data members:
49 private:
50  std::string m_Command; // (initial) Name of the command.
51  CTCLCompatibilityProcessor* m_pObjectProcessor; // Adaptor.
52 
53  // Constructors and other canonicals.
54 public:
55  CTCLProcessor(const std::string sCommand, CTCLInterpreter* pInterp);
56  CTCLProcessor(const char* pCommand, CTCLInterpreter* pInterp);
57  virtual ~CTCLProcessor();
58 
59 private:
60  CTCLProcessor(const CTCLProcessor& rhs);
61  CTCLProcessor& operator=(const CTCLProcessor& rhs);
62  //
63  // these used to be public but I doubt they are really useful.
64  //
65  int operator==(const CTCLProcessor& rhs) const;
66  int operator!=(const CTCLProcessor& rhs) const;
67 public:
68 
69  // Selectors we must retain for compatibility with the old use
70  // we omitted begin()/end() as they no longer have meaning,
71  // and will have to deal with any usage we see in SpecTcl e.g.
72 
73  std::string getCommandName() const;
74 
75  // Operations and overrides:
76 
77  virtual int operator()(CTCLInterpreter& rInterpreter,
78  CTCLResult& rResult,
79  int argc, char** argv) = 0; // pure.
80  virtual void OnDelete();
81 
82  void Register();
83  void Unregister();
84  void RegisterAll(); // Not really different than register now.
85  void UnregisterAll();
86 
87  // The functions below should be refactorable into the interpreter object:
88 
89  static std::string ConcatenateParameters (int nArguments,
90  char* pArguments[]) ;
91  int ParseInt (const char* pString, int* pInteger) ;
92  int ParseInt (const std::string& rString, int* pInteger) {
93  return ParseInt(rString.c_str(), pInteger);
94  }
95 
96  int ParseDouble (const char* pString, double* pDouble) ;
97  int ParseDouble (const std::string& rString, double* pDouble) {
98  return ParseDouble(rString.c_str(), pDouble);
99  }
100 
101  int ParseBoolean (const char* pString, TCLPLUS::Bool_t* pBoolean) ;
102  int ParseBoolean (const std::string& rString, TCLPLUS::Bool_t* pBoolean) {
103  return ParseBoolean(rString.c_str(), pBoolean);
104  }
105 
106  static int MatchKeyword(std::vector<std::string>& MatchTable,
107  const std::string& rValue,
108  int NoMatch = -1);
109  virtual void preCommand(); // Called just prior to operator()
110  virtual void postCommand(); // Called on return from operator()
111  virtual void preDelete(); // Ditto for OnDelete().
112  virtual void postDelete();
113 
114  CTCLInterpreter* Bind(CTCLInterpreter& binding);
115  CTCLInterpreter* Bind(CTCLInterpreter* binding);
116 
117 
118  // Utilities available for derived classes.
119 protected:
120 
121  void NextParam(int& argc, char**& argv) {
122  argc--;
123  argv++;
124  }
125 };
126 #endif
void Register()
Definition: TCLProcessor.cpp:94
std::string getCommandName() const
Definition: TCLProcessor.cpp:76
Definition: TCLInterpreterObject.h:46
Definition: TCLInterpreter.h:59
int ParseBoolean(const char *pString, TCLPLUS::Bool_t *pBoolean)
Definition: TCLProcessor.cpp:250
Definition: TCLResult.h:55
static int MatchKeyword(std::vector< std::string > &MatchTable, const std::string &rValue, int NoMatch=-1)
Definition: TCLProcessor.cpp:284
int ParseInt(const char *pString, int *pInteger)
Definition: TCLProcessor.cpp:184
int ParseDouble(const char *pString, double *pDouble)
Definition: TCLProcessor.cpp:220
Definition: TCLProcessor.h:46
virtual void preCommand()
Definition: TCLProcessor.cpp:303
virtual void postCommand()
Definition: TCLProcessor.cpp:313
virtual ~CTCLProcessor()
Definition: TCLProcessor.cpp:65
void RegisterAll()
Definition: TCLProcessor.cpp:109
virtual void postDelete()
Definition: TCLProcessor.cpp:329
static std::string ConcatenateParameters(int nArguments, char *pArguments[])
Definition: TCLProcessor.cpp:155
virtual void OnDelete()
Definition: TCLProcessor.cpp:85
virtual void preDelete()
Definition: TCLProcessor.cpp:321
void UnregisterAll()
Definition: TCLProcessor.cpp:118
Definition: TCLCompatibilityProcessor.h:47