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
void add_collector(PStatCollectorDef *def)
Adds a new collector definition to the dataset.
int get_toplevel_collector(int index) const
Returns the collector index of the nth toplevel collector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void close()
Closes the client connection if it is open.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
The data associated with a particular client, but not with any one particular frame or thread: the li...
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const PStatCollectorDef & get_collector_def(int index) const
Returns the nth collector definition.
std::string get_collector_fullname(int index) const
Returns the "full name" of the indicated collector.
int get_num_threads() const
Returns the total number of threads the Data knows about.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
std::string get_collector_name(int index) const
Returns the name of the indicated collector.
A dynamic array with an unlimited number of bits.
Definition: bitArray.h:39
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise.
This is the class that does all the work for handling communications from a single Panda client.
Definition: pStatReader.h:41
Records the version number of a particular client.
bool is_alive() const
Returns true if the data is actively getting filled by a connected client, or false if the client has...
bool has_thread(int index) const
Returns true if the indicated thread has been defined by the client already, false otherwise.
Contains the raw timing and level data for a single frame.
int get_num_collectors() const
Returns the total number of collectors the Data knows about.
A collection of FrameData structures for recently-received frames within a particular thread.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const PStatThreadData * get_thread_data(int index) const
Returns the data associated with the indicated thread.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void define_thread(int thread_index, const std::string &name=std::string())
Adds a new thread definition to the dataset.
Defines the details about the Collectors: the name, the suggested color, etc.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_toplevel_collectors() const
Returns the total number of collectors that are toplevel collectors.
std::string get_thread_name(int index) const
Returns the name of the indicated thread.
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...