Panda3D
|
00001 // Filename: pStatClientImpl.h 00002 // Created by: drose (23Dec04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PSTATCLIENTIMPL_H 00016 #define PSTATCLIENTIMPL_H 00017 00018 #include "pandabase.h" 00019 00020 // This class doesn't exist at all unless DO_PSTATS is defined. 00021 #ifdef DO_PSTATS 00022 00023 #include "pStatFrameData.h" 00024 #include "connectionManager.h" 00025 #include "queuedConnectionReader.h" 00026 #include "connectionWriter.h" 00027 #include "netAddress.h" 00028 00029 #include "trueClock.h" 00030 #include "pmap.h" 00031 00032 class PStatClient; 00033 class PStatServerControlMessage; 00034 class PStatCollector; 00035 class PStatCollectorDef; 00036 class PStatThread; 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Class : PStatClientImpl 00040 // Description : This class is the implementation of the actual 00041 // PStatClient class (which is just for interface). All 00042 // of the stuff to manage sending stats up to the server 00043 // is handled by this class. 00044 // 00045 // This separation between PStatClient and 00046 // PStatClientImpl allows the global PStatClient to be 00047 // constructed at static init time, without having to 00048 // consult any config variables at that time. We don't 00049 // actually do any real work until someone explicitly 00050 // calls PStatClient::connect(). 00051 // 00052 // This class doesn't exist at all unless DO_PSTATS is 00053 // defined. 00054 //////////////////////////////////////////////////////////////////// 00055 class EXPCL_PANDA_PSTATCLIENT PStatClientImpl : public ConnectionManager { 00056 public: 00057 PStatClientImpl(PStatClient *client); 00058 ~PStatClientImpl(); 00059 00060 INLINE void set_client_name(const string &name); 00061 INLINE string get_client_name() const; 00062 INLINE void set_max_rate(double rate); 00063 INLINE double get_max_rate() const; 00064 00065 INLINE double get_real_time() const; 00066 00067 INLINE void client_main_tick(); 00068 bool client_connect(string hostname, int port); 00069 void client_disconnect(); 00070 INLINE bool client_is_connected() const; 00071 00072 INLINE void client_resume_after_pause(); 00073 00074 void new_frame(int thread_index); 00075 00076 private: 00077 void transmit_frame_data(int thread_index, int frame_number, 00078 const PStatFrameData &frame_data); 00079 00080 void transmit_control_data(); 00081 00082 TrueClock *_clock; 00083 double _delta; 00084 double _last_frame; 00085 00086 // Networking stuff 00087 string get_hostname(); 00088 void send_hello(); 00089 void report_new_collectors(); 00090 void report_new_threads(); 00091 void handle_server_control_message(const PStatServerControlMessage &message); 00092 00093 virtual void connection_reset(const PT(Connection) &connection, 00094 bool okflag); 00095 00096 PStatClient *_client; 00097 00098 bool _is_connected; 00099 bool _got_udp_port; 00100 00101 NetAddress _server; 00102 QueuedConnectionReader _reader; 00103 ConnectionWriter _writer; 00104 00105 PT(Connection) _tcp_connection; 00106 PT(Connection) _udp_connection; 00107 00108 int _collectors_reported; 00109 int _threads_reported; 00110 00111 string _hostname; 00112 string _client_name; 00113 double _max_rate; 00114 00115 double _tcp_count_factor; 00116 double _udp_count_factor; 00117 unsigned int _tcp_count; 00118 unsigned int _udp_count; 00119 }; 00120 00121 #include "pStatClientImpl.I" 00122 00123 #endif // DO_PSTATS 00124 00125 #endif 00126