Panda3D
 All Classes Functions Variables Enumerations
pStatCollectorDef.cxx
1 // Filename: pStatCollectorDef.cxx
2 // Created by: drose (09Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "pStatCollectorDef.h"
16 
17 #include "datagram.h"
18 #include "datagramIterator.h"
19 
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: PStatCollectorDef::Default Constructor
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 PStatCollectorDef::
27 PStatCollectorDef() {
28  _index = 0;
29  _parent_index = 0;
30  _suggested_color.r = 0.0;
31  _suggested_color.g = 0.0;
32  _suggested_color.b = 0.0;
33  _sort = -1;
34  _suggested_scale = 0.0;
35  _factor = 1.0;
36  _is_active = true;
37  _active_explicitly_set = false;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: PStatCollectorDef::Constructor
42 // Access: Public
43 // Description:
44 ////////////////////////////////////////////////////////////////////
45 PStatCollectorDef::
46 PStatCollectorDef(int index, const string &name) :
47  _index(index),
48  _name(name)
49 {
50  _parent_index = 0;
51  _suggested_color.r = 0.0;
52  _suggested_color.g = 0.0;
53  _suggested_color.b = 0.0;
54  _sort = -1;
55  _suggested_scale = 0.0;
56  _factor = 1.0;
57  _is_active = true;
58  _active_explicitly_set = false;
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: PStatCollectorDef::set_parent
63 // Access: Public
64 // Description: This is normally called only by the PStatClient when
65 // the new PStatCollectorDef is created; it sets the
66 // parent of the CollectorDef and inherits whatever
67 // properties are appropriate.
68 ////////////////////////////////////////////////////////////////////
70 set_parent(const PStatCollectorDef &parent) {
71  _parent_index = parent._index;
72  _level_units = parent._level_units;
73  _suggested_scale = parent._suggested_scale;
74  _factor = parent._factor;
75  _is_active = parent._is_active;
76  _active_explicitly_set = parent._active_explicitly_set;
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: PStatCollectorDef::write_datagram
81 // Access: Public
82 // Description: Writes the definition of the collectorDef to the
83 // datagram.
84 ////////////////////////////////////////////////////////////////////
86 write_datagram(Datagram &destination) const {
87  destination.add_int16(_index);
88  destination.add_string(_name);
89  destination.add_int16(_parent_index);
90  destination.add_float32(_suggested_color.r);
91  destination.add_float32(_suggested_color.g);
92  destination.add_float32(_suggested_color.b);
93  destination.add_int16(_sort);
94  destination.add_string(_level_units);
95  destination.add_float32(_suggested_scale);
96  destination.add_float32(_factor);
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: PStatCollectorDef::read_datagram
101 // Access: Public
102 // Description: Extracts the collectorDef definition from the datagram.
103 ////////////////////////////////////////////////////////////////////
106  _index = source.get_int16();
107  _name = source.get_string();
108  _parent_index = source.get_int16();
109  _suggested_color.r = source.get_float32();
110  _suggested_color.g = source.get_float32();
111  _suggested_color.b = source.get_float32();
112  _sort = source.get_int16();
113  _level_units = source.get_string();
114  _suggested_scale = source.get_float32();
115  _factor = source.get_float32();
116 }
void set_parent(const PStatCollectorDef &parent)
This is normally called only by the PStatClient when the new PStatCollectorDef is created; it sets th...
void add_string(const string &str)
Adds a variable-length string to the datagram.
Definition: datagram.I:351
void write_datagram(Datagram &destination) const
Writes the definition of the collectorDef to the datagram.
void add_float32(PN_float32 value)
Adds a 32-bit single-precision floating-point number to the datagram.
Definition: datagram.I:217
PN_int16 get_int16()
Extracts a signed 16-bit integer.
string get_string()
Extracts a variable-length string.
PN_float32 get_float32()
Extracts a 32-bit single-precision floating-point number.
void add_int16(PN_int16 value)
Adds a signed 16-bit integer to the datagram.
Definition: datagram.I:148
Records the version number of a particular client.
A class to retrieve the individual data elements previously stored in a Datagram. ...
Defines the details about the Collectors: the name, the suggested color, etc.
void read_datagram(DatagramIterator &source, PStatClientVersion *version)
Extracts the collectorDef definition from the datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43