NSCL DDAS 12.2-009
Support for XIA DDAS at FRIB
CTclCommand.h
Go to the documentation of this file.
1/*
2 This software is Copyright by the Board of Trustees of Michigan
3 State University (c) Copyright 2017.
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 Authors:
11 Ron Fox
12 Giordano Cerriza
13 NSCL
14 Michigan State University
15 East Lansing, MI 48824-1321
16*/
17
22#ifndef CTCLCOMMAND_H
23#define CTCLCOMMAND_H
24
25#include <tcl.h>
26
27#include <string>
28#include <vector>
36private:
37 Tcl_Interp *m_pInterp;
38 std::string m_cmdName;
39
40public:
41 CTclCommand(Tcl_Interp *pInterp, const char *cmdName);
42 virtual ~CTclCommand();
43
44 // Subclasses must implement this method. It gets control
45 // when the actual command is executed.
46
47 virtual int operator()(std::vector<Tcl_Obj *> &argv) = 0;
48
49 // services for concrete subclasses.
50protected:
51 Tcl_Interp *getInterpreter() { return m_pInterp; }
52 void requireExactly(std::vector<Tcl_Obj *> &objv, int nParams);
53 void requireAtMost(std::vector<Tcl_Obj *> &objv, int max);
54 void setResult(const char *result);
55 void setResult(Tcl_Obj *result);
56 void setResult(double value);
57 void setResult(int value);
58
59 int getInteger(Tcl_Obj *intObj);
60 double getDouble(Tcl_Obj *dblObj);
61
62private:
63 static int commandRelay(ClientData pObject, Tcl_Interp *pInterp, int objc,
64 Tcl_Obj *const objv[]);
65};
66
67#endif
Definition: CTclCommand.h:35
virtual int operator()(std::vector< Tcl_Obj * > &argv)=0
virtual ~CTclCommand()
Definition: CTclCommand.cpp:44
double getDouble(Tcl_Obj *dblObj)
Definition: CTclCommand.cpp:133
int getInteger(Tcl_Obj *intObj)
Definition: CTclCommand.cpp:118
void requireAtMost(std::vector< Tcl_Obj * > &objv, int max)
Definition: CTclCommand.cpp:71
void requireExactly(std::vector< Tcl_Obj * > &objv, int nParams)
Definition: CTclCommand.cpp:55
Tcl_Interp * getInterpreter()
Definition: CTclCommand.h:51
CTclCommand(Tcl_Interp *pInterp, const char *cmdName)
Definition: CTclCommand.cpp:36
void setResult(const char *result)
Definition: CTclCommand.cpp:85