FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
TCLVariable.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 // CTCLVariable.h:
19 //
20 // This file defines the CTCLVariable class.
21 //
22 // Author:
23 // Ron Fox
24 // NSCL
25 // Michigan State University
26 // East Lansing, MI 48824-1321
27 // mailto:fox@nscl.msu.edu
28 //
29 // Copyright 1999 NSCL, All Rights Reserved.
30 //
32 
33 #ifndef TCLVARIABLE_H //Required for current class
34 #define TCLVARIABLE_H
35 
36 #ifndef TCLVERSIONHACKS_H
37 #include "TCLVersionHacks.h"
38 #endif
39  //Required for base classes
40 #ifndef TCLINTERPRETEROBJECT_H
41 #include "TCLInterpreterObject.h"
42 #endif
43 
44 #ifndef TCLPLUSTYPES_H
45 #include <libtclplusdatatypes.h>
46 #endif
47 
48 #include <string>
49 
51 {
52  std::string m_sVariable; // Name of the variable represented.
53  TCLPLUS::Bool_t m_fTracing; // kfTRUE if tracing is enabled.
54  TCLPLUS::Int_t m_nTraceFlags; // Set of trace flags for variable.
55  std::string m_sTraceIndex;
56 public:
57  // Default construtor needed to allow use in STL container.
58 
59  CTCLVariable() :
60  m_fTracing(false),
61  m_nTraceFlags(0)
62  {}
63 
64 
65  //Constructor with arguments
66 
67 
68  CTCLVariable (std::string am_sVariable, TCLPLUS::Bool_t am_fTracing ) :
70  m_sVariable (am_sVariable),
71  m_fTracing (am_fTracing)
72  { }
73  CTCLVariable (CTCLInterpreter* pInterp,
74  std::string am_sVariable, TCLPLUS::Bool_t am_fTracing ) :
75  CTCLInterpreterObject(pInterp),
76  m_sVariable (am_sVariable),
77  m_fTracing (am_fTracing)
78  { }
79  virtual ~CTCLVariable();
80  //Copy constructor
81 
82  CTCLVariable (const CTCLVariable& aCTCLVariable ) :
83  CTCLInterpreterObject (aCTCLVariable),
84  m_sVariable(" "),
85  m_fTracing(TCLPLUS::kfFALSE)
86  {
87  DoAssign(aCTCLVariable);
88  }
89 
90  //Operator= Assignment Operator
91 
92  CTCLVariable& operator= (const CTCLVariable& aCTCLVariable)
93  {
94  if (this == &aCTCLVariable) return *this;
95  CTCLInterpreterObject::operator=(aCTCLVariable);
96  DoAssign(aCTCLVariable);
97 
98  return *this;
99  }
100 
101  //Operator== Equality Operator
102 
103  int operator== (const CTCLVariable& aCTCLVariable) const
104  {
105  return (
106  (CTCLInterpreterObject::operator== (aCTCLVariable)) &&
107  (m_sVariable == aCTCLVariable.m_sVariable) &&
108  (m_fTracing == aCTCLVariable.m_fTracing)
109  );
110  }
111  // Selectors
112 
113 public:
114 
115  std::string getVariableName() const
116  {
117  return m_sVariable;
118  }
119  TCLPLUS::Bool_t IsTracing() const
120  {
121  return m_fTracing;
122  }
123  // Mutators:
124 
125 public:
126 
127  void setVariableName (const std::string am_sVariable)
128  {
129  if(IsTracing()) UnTrace();
130  m_sVariable = am_sVariable;
131  }
132 protected:
133  void setTracing (TCLPLUS::Bool_t am_fTracing)
134  {
135  m_fTracing = am_fTracing;
136  }
137  // Additional operations:
138  //
139 public:
140  virtual char* operator() (char* pName,
141  char* pSubscript,
142  int Flags) ;
143 
144  static char* TraceRelay (ClientData pObject, Tcl_Interp* pInterpreter,
145  tclConstCharPtr pName,
146  tclConstCharPtr pIndex,
147  int flags) ;
148 
149  const char* Set (const char* pValue, int flags=TCL_LEAVE_ERR_MSG |
150  TCL_GLOBAL_ONLY) ;
151  const char* Set (const char* pSubscript, const char* pValue,
152  int flags=TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY) ;
153  const char* Get (int flags=TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY,
154  char* pIndex=0) ;
155  int Link (void* pVariable, int Type) ;
156  void Unlink () ;
157  int Trace (int flags=TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
158  char* pIndex = (char*)TCLPLUS::kpNULL) ;
159 
160  void UnTrace () ;
161 
162 
163 
164  // Protecterd utility functions:
165  //
166 protected:
167  void DoAssign(const CTCLVariable& rRhs);
168 };
169 
170 #endif
Definition: TCLInterpreterObject.h:46
Definition: TCLInterpreter.h:59
Definition: TCLVariable.h:50