Panda3D
pStatClientData.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 pStatClientData.h
10  * @author drose
11  * @date 2000-07-11
12  */
13 
14 #ifndef PSTATCLIENTDATA_H
15 #define PSTATCLIENTDATA_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "pStatThreadData.h"
20 
21 #include "pStatClientVersion.h"
22 #include "referenceCount.h"
23 #include "pointerTo.h"
24 #include "bitArray.h"
25 
26 #include "pvector.h"
27 #include "vector_int.h"
28 
29 class PStatReader;
30 
31 /**
32  * The data associated with a particular client, but not with any one
33  * particular frame or thread: the list of collectors and threads, for
34  * instance.
35  */
37 public:
39  ~PStatClientData();
40 
41  bool is_alive() const;
42  void close();
43 
44  int get_num_collectors() const;
45  bool has_collector(int index) const;
46  const PStatCollectorDef &get_collector_def(int index) const;
47  std::string get_collector_name(int index) const;
48  std::string get_collector_fullname(int index) const;
49  bool set_collector_has_level(int index, int thread_index, bool flag);
50  bool get_collector_has_level(int index, int thread_index) const;
51 
52  int get_num_toplevel_collectors() const;
53  int get_toplevel_collector(int index) const;
54 
55  int get_num_threads() const;
56  bool has_thread(int index) const;
57  std::string get_thread_name(int index) const;
58  const PStatThreadData *get_thread_data(int index) const;
59 
60  int get_child_distance(int parent, int child) const;
61 
62 
64  void define_thread(int thread_index, const std::string &name = std::string());
65 
66  void record_new_frame(int thread_index, int frame_number,
67  PStatFrameData *frame_data);
68 private:
69  void slot_collector(int collector_index);
70  void update_toplevel_collectors();
71 
72 private:
73  bool _is_alive;
74  PStatReader *_reader;
75 
76  class Collector {
77  public:
78  PStatCollectorDef *_def;
79  BitArray _is_level;
80  };
81 
83  Collectors _collectors;
84 
85  typedef vector_int ToplevelCollectors;
86  ToplevelCollectors _toplevel_collectors;
87 
88  class Thread {
89  public:
90  std::string _name;
91  PT(PStatThreadData) _data;
92  };
93  typedef pvector<Thread> Threads;
94  Threads _threads;
95 
96  static PStatCollectorDef _null_collector;
97  friend class PStatReader;
98 };
99 
100 #endif
bitArray.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PStatClientData::has_collector
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise.
Definition: pStatClientData.cxx:81
PStatClientData::record_new_frame
void record_new_frame(int thread_index, int frame_number, PStatFrameData *frame_data)
Makes room for and stores a new frame's worth of data associated with some particular thread (which m...
Definition: pStatClientData.cxx:317
pvector< Collector >
vector_int.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PStatClientData::get_collector_def
const PStatCollectorDef & get_collector_def(int index) const
Returns the nth collector definition.
Definition: pStatClientData.cxx:90
PStatClientData::close
void close()
Closes the client connection if it is open.
Definition: pStatClientData.cxx:59
PStatCollectorDef
Defines the details about the Collectors: the name, the suggested color, etc.
Definition: pStatCollectorDef.h:29
PStatClientData::get_num_threads
int get_num_threads() const
Returns the total number of threads the Data knows about.
Definition: pStatClientData.cxx:194
PStatClientVersion
Records the version number of a particular client.
Definition: pStatClientVersion.h:26
PStatClientData::get_thread_name
std::string get_thread_name(int index) const
Returns the name of the indicated thread.
Definition: pStatClientData.cxx:213
PStatClientData::get_collector_has_level
bool get_collector_has_level(int index, int thread_index) const
Returns whether the given collector has level data (and consequently, whether it should appear on the...
Definition: pStatClientData.cxx:165
PStatClientData::get_num_collectors
int get_num_collectors() const
Returns the total number of collectors the Data knows about.
Definition: pStatClientData.cxx:71
PStatClientData
The data associated with a particular client, but not with any one particular frame or thread: the li...
Definition: pStatClientData.h:36
PStatClientData::add_collector
void add_collector(PStatCollectorDef *def)
Adds a new collector definition to the dataset.
Definition: pStatClientData.cxx:262
pStatThreadData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PStatClientData::set_collector_has_level
bool set_collector_has_level(int index, int thread_index, bool flag)
Indicates whether the given collector has level data (and consequently, whether it should appear on t...
Definition: pStatClientData.cxx:135
PStatClientData::get_collector_name
std::string get_collector_name(int index) const
Returns the name of the indicated collector.
Definition: pStatClientData.cxx:101
PStatClientData::get_toplevel_collector
int get_toplevel_collector(int index) const
Returns the collector index of the nth toplevel collector.
Definition: pStatClientData.cxx:185
PStatThreadData
A collection of FrameData structures for recently-received frames within a particular thread.
Definition: pStatThreadData.h:34
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PStatClientData::define_thread
void define_thread(int thread_index, const std::string &name=std::string())
Adds a new thread definition to the dataset.
Definition: pStatClientData.cxx:290
PStatClientData::is_alive
bool is_alive() const
Returns true if the data is actively getting filled by a connected client, or false if the client has...
Definition: pStatClientData.cxx:51
PStatClientData::has_thread
bool has_thread(int index) const
Returns true if the indicated thread has been defined by the client already, false otherwise.
Definition: pStatClientData.cxx:204
PStatClientData::get_num_toplevel_collectors
int get_num_toplevel_collectors() const
Returns the total number of collectors that are toplevel collectors.
Definition: pStatClientData.cxx:175
PStatClientData::get_collector_fullname
std::string get_collector_fullname(int index) const
Returns the "full name" of the indicated collector.
Definition: pStatClientData.cxx:115
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PStatClientData::get_child_distance
int get_child_distance(int parent, int child) const
Returns the number of Collectors between the indicated parent and the child Collector in the relation...
Definition: pStatClientData.cxx:239
PStatClientData::get_thread_data
const PStatThreadData * get_thread_data(int index) const
Returns the data associated with the indicated thread.
Definition: pStatClientData.cxx:225
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatClientVersion.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BitArray
A dynamic array with an unlimited number of bits.
Definition: bitArray.h:40
PStatReader
This is the class that does all the work for handling communications from a single Panda client.
Definition: pStatReader.h:41
PStatFrameData
Contains the raw timing and level data for a single frame.
Definition: pStatFrameData.h:33