00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PSTATSERVER_H
00016 #define PSTATSERVER_H
00017
00018 #include "pandatoolbase.h"
00019 #include "pStatListener.h"
00020 #include "connectionManager.h"
00021 #include "vector_stdfloat.h"
00022 #include "pmap.h"
00023 #include "pdeque.h"
00024
00025 class PStatReader;
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class PStatServer : public ConnectionManager {
00042 public:
00043 PStatServer();
00044 ~PStatServer();
00045
00046 bool listen(int port = -1);
00047
00048 void poll();
00049 void main_loop(bool *interrupt_flag = NULL);
00050
00051 virtual PStatMonitor *make_monitor()=0;
00052 void add_reader(Connection *connection, PStatReader *reader);
00053 void remove_reader(Connection *connection, PStatReader *reader);
00054
00055 int get_udp_port();
00056 void release_udp_port(int port);
00057
00058 int get_num_user_guide_bars() const;
00059 double get_user_guide_bar_height(int n) const;
00060 void move_user_guide_bar(int n, double height);
00061 int add_user_guide_bar(double height);
00062 void remove_user_guide_bar(int n);
00063 int find_user_guide_bar(double from_height, double to_height) const;
00064
00065 virtual bool is_thread_safe();
00066
00067 protected:
00068 virtual void connection_reset(const PT(Connection) &connection,
00069 bool okflag);
00070
00071 private:
00072 void user_guide_bars_changed();
00073
00074 PStatListener *_listener;
00075
00076 typedef pmap<PT(Connection), PStatReader *> Readers;
00077 Readers _readers;
00078 typedef pvector<PStatReader *> LostReaders;
00079 LostReaders _lost_readers;
00080 LostReaders _removed_readers;
00081
00082 typedef pdeque<int> Ports;
00083 Ports _available_udp_ports;
00084 int _next_udp_port;
00085
00086 typedef vector_stdfloat GuideBars;
00087 GuideBars _user_guide_bars;
00088 };
00089
00090 #endif