Panda3D
pStatCollectorDef.cxx
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 pStatCollectorDef.cxx
10  * @author drose
11  * @date 2000-07-09
12  */
13 
14 #include "pStatCollectorDef.h"
15 
16 #include "datagram.h"
17 #include "datagramIterator.h"
18 
19 
20 /**
21  *
22  */
23 PStatCollectorDef::
24 PStatCollectorDef() {
25  _index = 0;
26  _parent_index = 0;
27  _suggested_color.r = 0.0;
28  _suggested_color.g = 0.0;
29  _suggested_color.b = 0.0;
30  _sort = -1;
31  _suggested_scale = 0.0;
32  _factor = 1.0;
33  _is_active = true;
34  _active_explicitly_set = false;
35 }
36 
37 /**
38  *
39  */
40 PStatCollectorDef::
41 PStatCollectorDef(int index, const std::string &name) :
42  _index(index),
43  _name(name)
44 {
45  _parent_index = 0;
46  _suggested_color.r = 0.0;
47  _suggested_color.g = 0.0;
48  _suggested_color.b = 0.0;
49  _sort = -1;
50  _suggested_scale = 0.0;
51  _factor = 1.0;
52  _is_active = true;
53  _active_explicitly_set = false;
54 }
55 
56 /**
57  * This is normally called only by the PStatClient when the new
58  * PStatCollectorDef is created; it sets the parent of the CollectorDef and
59  * inherits whatever properties are appropriate.
60  */
62 set_parent(const PStatCollectorDef &parent) {
63  _parent_index = parent._index;
64  _level_units = parent._level_units;
65  _suggested_scale = parent._suggested_scale;
66  _factor = parent._factor;
67  _is_active = parent._is_active;
68  _active_explicitly_set = parent._active_explicitly_set;
69 }
70 
71 /**
72  * Writes the definition of the collectorDef to the datagram.
73  */
75 write_datagram(Datagram &destination) const {
76  destination.add_int16(_index);
77  destination.add_string(_name);
78  destination.add_int16(_parent_index);
79  destination.add_float32(_suggested_color.r);
80  destination.add_float32(_suggested_color.g);
81  destination.add_float32(_suggested_color.b);
82  destination.add_int16(_sort);
83  destination.add_string(_level_units);
84  destination.add_float32(_suggested_scale);
85  destination.add_float32(_factor);
86 }
87 
88 /**
89  * Extracts the collectorDef definition from the datagram.
90  */
93  _index = source.get_int16();
94  _name = source.get_string();
95  _parent_index = source.get_int16();
96  _suggested_color.r = source.get_float32();
97  _suggested_color.g = source.get_float32();
98  _suggested_color.b = source.get_float32();
99  _sort = source.get_int16();
100  _level_units = source.get_string();
101  _suggested_scale = source.get_float32();
102  _factor = source.get_float32();
103 }
A class to retrieve the individual data elements previously stored in a Datagram.
PN_float32 get_float32()
Extracts a 32-bit single-precision floating-point number.
int16_t get_int16()
Extracts a signed 16-bit integer.
std::string get_string()
Extracts a variable-length string.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
void add_int16(int16_t value)
Adds a signed 16-bit integer to the datagram.
Definition: datagram.I:58
void add_float32(PN_float32 value)
Adds a 32-bit single-precision floating-point number to the datagram.
Definition: datagram.I:114
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
Definition: datagram.I:219
Records the version number of a particular client.
Defines the details about the Collectors: the name, the suggested color, etc.
void set_parent(const PStatCollectorDef &parent)
This is normally called only by the PStatClient when the new PStatCollectorDef is created; it sets th...
void read_datagram(DatagramIterator &source, PStatClientVersion *version)
Extracts the collectorDef definition from the datagram.
void write_datagram(Datagram &destination) const
Writes the definition of the collectorDef to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.