Panda3D

Loading...
Searching...
No Matches
pStatClientImpl.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 pStatClientImpl.h
10 * @author drose
11 * @date 2004-12-23
12 */
13
14#ifndef PSTATCLIENTIMPL_H
15#define PSTATCLIENTIMPL_H
16
17#include "pandabase.h"
18
19// This class doesn't exist at all unless DO_PSTATS is defined.
20#ifdef DO_PSTATS
21
22#include "pStatFrameData.h"
23#include "connectionManager.h"
24#include "queuedConnectionReader.h"
25#include "connectionWriter.h"
26#include "netAddress.h"
27
28#include "trueClock.h"
29#include "pmap.h"
30
31 class PStatClient;
32 class PStatServerControlMessage;
33 class PStatCollector;
34 class PStatCollectorDef;
35 class PStatThread;
36
37/**
38 * This class is the implementation of the actual PStatClient class (which is
39 * just for interface). All of the stuff to manage sending stats up to the
40 * server is handled by this class.
41 *
42 * This separation between PStatClient and PStatClientImpl allows the global
43 * PStatClient to be constructed at static init time, without having to
44 * consult any config variables at that time. We don't actually do any real
45 * work until someone explicitly calls PStatClient::connect().
46 *
47 * This class doesn't exist at all unless DO_PSTATS is defined.
48 */
49 class EXPCL_PANDA_PSTATCLIENT PStatClientImpl : public ConnectionManager {
50 public:
51 PStatClientImpl(PStatClient *client);
52 ~PStatClientImpl();
53
54 INLINE void set_client_name(const std::string &name);
55 INLINE std::string get_client_name() const;
56 INLINE void set_max_rate(double rate);
57 INLINE double get_max_rate() const;
58
59 INLINE double get_real_time() const;
60
61 INLINE void client_main_tick();
62 bool client_connect(std::string hostname, int port);
63 void client_disconnect();
64 INLINE bool client_is_connected() const;
65
66 INLINE void client_resume_after_pause();
67
68 void new_frame(int thread_index);
69 void add_frame(int thread_index, const PStatFrameData &frame_data);
70
71 private:
72 void transmit_frame_data(int thread_index, int frame_number,
73 const PStatFrameData &frame_data);
74
75 void transmit_control_data();
76
77 TrueClock *_clock;
78 double _delta;
79 double _last_frame;
80
81 // Networking stuff
82 std::string get_hostname();
83 void send_hello();
84 void report_new_collectors();
85 void report_new_threads();
86 void handle_server_control_message(const PStatServerControlMessage &message);
87
88 virtual void connection_reset(const PT(Connection) &connection,
89 bool okflag);
90
91 PStatClient *_client;
92
93 bool _is_connected;
94 bool _got_udp_port;
95
96 NetAddress _server;
97 QueuedConnectionReader _reader;
98 ConnectionWriter _writer;
99
100 PT(Connection) _tcp_connection;
101 PT(Connection) _udp_connection;
102
103 int _collectors_reported;
104 int _threads_reported;
105
106 std::string _hostname;
107 std::string _client_name;
108 double _max_rate;
109
110 double _tcp_count_factor;
111 double _udp_count_factor;
112 unsigned int _tcp_count;
113 unsigned int _udp_count;
114};
115
116#include "pStatClientImpl.I"
117
118#endif // DO_PSTATS
119
120#endif
ConnectionManager
The primary interface to the low-level networking layer in this package.
Definition connectionManager.h:41
PStatClient
Manages the communications to report statistics via a network connection to a remote PStatServer.
Definition pStatClient.h:266
PStatCollectorDef
Defines the details about the Collectors: the name, the suggested color, etc.
Definition pStatCollectorDef.h:29
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition pStatCollector.h:43
PStatServerControlMessage
This kind of message is sent from the server to the client on the TCP socket to establish critical co...
Definition pStatServerControlMessage.h:27
PStatThread
A lightweight class that represents a single thread of execution to PStats.
Definition pStatThread.h:28
connectionManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
connectionWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
netAddress.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatClientImpl.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatFrameData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
queuedConnectionReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
trueClock.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.