CFEL - ASG Software Suite  2.5.0
CASS
jocassview/tcpclient.h
Go to the documentation of this file.
1 //Copyright (C) 2011, 2013 Lutz Foucar
2 
3 /**
4  * @file jocassview/tcpclient.h file contains the classes connect to cass
5  *
6  * @author Lutz Foucar
7  */
8 #ifndef _TCPCLIENT_H
9 #define _TCPCLIENT_H
10 
11 #include <list>
12 #include <tr1/memory>
13 
14 #include <QtCore/QObject>
15 #include <QtCore/QString>
16 
17 #include "data_source.h"
18 
19 namespace cass
20 {
21 class HistogramBackend;
22 }//end namespace cass
23 
24 class QStringList;
25 class CASSsoapProxy;
26 
27 namespace jocassview
28 {
29 
30 /** the tcp client that connects to the cass server
31  *
32  * @author Lutz Foucar
33  */
34 class TCPClient : public QObject, public DataSource
35 {
36  Q_OBJECT
37 
38 public:
39  /** default constructor */
40  TCPClient();
41 
42  /** destructor */
43  virtual ~TCPClient();
44 
45  /** retrieve a specific result
46  *
47  * @return Histogram for requested key
48  * @param key the key of the requested result
49  * @param id the event id of the histogram to be returned
50  */
51  result_t::shared_pointer result(const QString &key,quint64 id=0);
52 
53  /** retrieve a list of results all with the same id
54  *
55  * @return list of shared pointers of the requested results
56  * @param list the list of keys who's histograms should be retrieved
57  */
59 
60  /** retrieve the list of available histograms
61  *
62  * @return the list of names of available histograms
63  */
65 
66  /** return the type of source we are
67  *
68  * @return "TCPClient"
69  */
70  QString type() const;
71 
72  /** retrieve the transferred bytes */
73  size_t receivedBytes()const;
74 
75 public slots:
76  /** reload .ini file */
77  void reloadIni() const;
78 
79  /** broadcast a command to all processors in the server
80  *
81  * @param command The command to broadcast
82  */
83  void broadcastCommand(const QString& command) const;
84 
85  /** broadcast a command to all processors in the server
86  *
87  * @param key The key of the Postprocessor to send the command to
88  * @param command The command to broadcast
89  */
90  void sendCommandTo(const QString &key, const QString& command) const;
91 
92  /** change the server to connect to
93  *
94  * @param serverstring the server name and port as string
95  */
96  void setServer(const QString &serverstring);
97 
98  /** tell the server to quit */
99  void quitServer() const;
100 
101  /** clear the histogram of a processor
102  *
103  * @param key The key of the Postprocessor whos histograms should be cleared
104  */
105  void clearHistogram(QString key) const;
106 
107 private:
108  /** the amount of bytes transferred */
109  mutable size_t _transferredBytes;
110 
111  /** the server string
112  *
113  * @note this is needed because the client only hold a pointer to the string
114  * and not the string itself.
115  */
116  std::string _server;
117 };
118 }//end namespace jocassview
119 #endif
size_t _transferredBytes
the amount of bytes transferred
void reloadIni() const
reload .ini file
void quitServer() const
tell the server to quit
virtual ~TCPClient()
destructor
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
Definition: result.hpp:323
contains the base class data sources
void broadcastCommand(const QString &command) const
broadcast a command to all processors in the server
QString type() const
return the type of source we are
void setServer(const QString &serverstring)
change the server to connect to
base class for data sources
Definition: data_source.h:26
void clearHistogram(QString key) const
clear the histogram of a processor
QStringList resultNames()
retrieve the list of available histograms
size_t receivedBytes() const
retrieve the transferred bytes
std::string _server
the server string
the tcp client that connects to the cass server
void sendCommandTo(const QString &key, const QString &command) const
broadcast a command to all processors in the server
QVector< result_t::shared_pointer > results(const QStringList &list)
retrieve a list of results all with the same id
result_t::shared_pointer result(const QString &key, quint64 id=0)
retrieve a specific result
TCPClient()
default constructor