Panda3D

pStatReader.h
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pStatReader.h
10 * @author drose
11 * @date 2000-07-09
12 */
13
14 #ifndef PSTATREADER_H
15 #define PSTATREADER_H
16
17 #include "pandatoolbase.h"
18
19 #include "pStatClientData.h"
20 #include "pStatMonitor.h"
21
22 #include "connectionReader.h"
23 #include "connectionWriter.h"
24 #include "referenceCount.h"
25 #include "circBuffer.h"
26
27 class PStatServer;
28 class PStatMonitor;
29 class PStatClientControlMessage;
30 class PStatFrameData;
31
32 // This is the maximum number of frame records that will be queued up from
33 // this particular client between processing loops.
34 static const int queued_frame_records = 500;
35
36 /**
37 * This is the class that does all the work for handling communications from a
38 * single Panda client. It reads sockets received from the client and boils
39 * them down into PStatData.
40 */
41 class PStatReader : public ConnectionReader {
42 public:
43 PStatReader(PStatServer *manager, PStatMonitor *monitor);
44 ~PStatReader();
45
46 void close();
47
48 void set_tcp_connection(Connection *tcp_connection);
49 void lost_connection();
50 void idle();
51
52 PStatMonitor *get_monitor();
53
54 private:
55 std::string get_hostname();
56 void send_hello();
57
58 virtual void receive_datagram(const NetDatagram &datagram);
59
60 void handle_client_control_message(const PStatClientControlMessage &message);
61 void handle_client_udp_data(const Datagram &datagram);
62 void dequeue_frame_data();
63
64 private:
65 PStatServer *_manager;
66 PT(PStatMonitor) _monitor;
67 ConnectionWriter _writer;
68
69 PT(Connection) _tcp_connection;
70 PT(Connection) _udp_connection;
71 int _udp_port;
72
73 PT(PStatClientData) _client_data;
74
75 std::string _hostname;
76
77 class FrameData {
78 public:
79 int _thread_index;
80 int _frame_number;
81 PStatFrameData *_frame_data;
82 };
83 typedef CircBuffer<FrameData, queued_frame_records> QueuedFrameData;
84 QueuedFrameData _queued_frame_data;
85 };
86
87 #endif
circBuffer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CircBuffer< FrameData, queued_frame_records >
ConnectionReader
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
Definition: connectionReader.h:50
ConnectionWriter
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
Definition: connectionWriter.h:35
Connection
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:29
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
NetDatagram
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:40
PStatClientControlMessage
This kind of message is sent from the client to the server on the TCP socket to establish critical co...
Definition: pStatClientControlMessage.h:30
PStatClientData
The data associated with a particular client, but not with any one particular frame or thread: the li...
Definition: pStatClientData.h:36
PStatFrameData
Contains the raw timing and level data for a single frame.
Definition: pStatFrameData.h:33
PStatMonitor
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:39
PStatReader
This is the class that does all the work for handling communications from a single Panda client.
Definition: pStatReader.h:41
PStatReader::lost_connection
void lost_connection()
This is called by the PStatServer when it detects that the connection has been lost.
Definition: pStatReader.cxx:94
PStatReader::set_tcp_connection
void set_tcp_connection(Connection *tcp_connection)
This is intended to be called only once, immediately after construction, by the PStatListener that cr...
Definition: pStatReader.cxx:72
PStatReader::idle
void idle()
Called each frame to do what needs to be done for the monitor's user- defined idle routines.
Definition: pStatReader.cxx:110
PStatReader::close
void close()
This will be called by the PStatClientData in response to its close() call.
Definition: pStatReader.cxx:61
PStatReader::get_monitor
PStatMonitor * get_monitor()
Returns the monitor that this reader serves.
Definition: pStatReader.cxx:119
PStatServer
The overall manager of the network connections.
Definition: pStatServer.h:36
connectionReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
connectionWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatClientData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatMonitor.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.