FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
TCLChannel.h
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2014.
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  Jeromy Tompkins
13  NSCL
14  Michigan State University
15  East Lansing, MI 48824-1321
16 */
17 
18 #ifndef TCL_CHANNEL_H
19 #define TCL_CHANNEL_H
20 
21 // Headers:
22 
23 #include <tcl.h>
24 
25 #ifndef TCLINTERPRETEROBJECT_H
26 #include <TCLInterpreterObject.h>
27 #endif
28 
29 #include <string>
30 
67 {
68  // Member data:
69 
70 private:
71  Tcl_Channel m_Channel;
72  bool m_fCloseOnDestroy;
73  bool m_fRegistered;
74 
75 
76  // Constructors and Destructor.
77 
78 public:
79 
80  CTCLChannel(CTCLInterpreter* pInterp,
81  std::string Filename,
82  const char* pMode,
83  int permissions) ;
85  int argc,
86  const char** pargv,
87  int flags);
89  int port,
90  std::string host) ;
92  int port,
93  Tcl_TcpAcceptProc* proc,
94  ClientData AppData) ;
96  Tcl_Channel Channel);
97  CTCLChannel(const CTCLChannel& rhs);
98  virtual ~CTCLChannel();
99 
100  // Canonical operations (assignment and (in)equality comparison.
101 
102 
103 private:
104  CTCLChannel& operator=(const CTCLChannel& rhs);
105 
106  int operator==(const CTCLChannel& rhs) const;
107  int operator!=(const CTCLChannel& rhs) const;
108 public:
109  // Selectors:
110 
111 public:
112  Tcl_Channel getChannel() const {
113  return m_Channel;
114  }
115  bool ClosesOnDestroy() const {
116  return m_fCloseOnDestroy;
117  }
118  // Mutators:
119 
120 protected:
121  void setChannel(Tcl_Channel Channel) {
122  m_Channel = Channel;
123  }
124  void CloseOnDestroy(bool state) {
125  m_fCloseOnDestroy = state;
126  }
127 
128  // Operations on a channel:
129 
130 public:
131  int Read( void** pData, int nChars);
132  int Write(const void* pData, int nBytes);
133 
134  bool atEof();
135  void Flush();
136  void Close();
137  void Register();
138  void SetEncoding(std::string Name);
139  std::string GetEncoding();
140 };
141 #endif
CTCLChannel(CTCLInterpreter *pInterp, std::string Filename, const char *pMode, int permissions)
Construct file channel.
Definition: TCLInterpreterObject.h:46
Definition: TCLInterpreter.h:59
void Register()
Expose channel name to scripts (dangerous!!)
Definition: TCLChannel.cpp:381
std::string GetEncoding()
Definition: TCLChannel.cpp:401
Definition: TCLChannel.h:66
bool atEof()
True if EOF on channel.
Definition: TCLChannel.cpp:343
void SetEncoding(std::string Name)
Definition: TCLChannel.cpp:391
void Close()
Close channel (dangerous!!!).
Definition: TCLChannel.cpp:362
virtual ~CTCLChannel()
Definition: TCLChannel.cpp:254
int Read(void **pData, int nChars)
Read data from the channel.
Definition: TCLChannel.cpp:291
void Flush()
Flush channel data buffers.
Definition: TCLChannel.cpp:352
int Write(const void *pData, int nBytes)
Write data to the channel.
Definition: TCLChannel.cpp:334