Panda3D
vertexSlider.cxx
1 // Filename: vertexSlider.cxx
2 // Created by: drose (28Mar05)
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 "vertexSlider.h"
16 #include "vertexTransform.h"
17 #include "bamReader.h"
18 #include "bamWriter.h"
19 #include "indent.h"
20 #include "sliderTable.h"
21 
22 TypeHandle VertexSlider::_type_handle;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Function: VertexSlider::Constructor
26 // Access: Published
27 // Description:
28 ////////////////////////////////////////////////////////////////////
29 VertexSlider::
30 VertexSlider(const InternalName *name) : _name(name) {
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: VertexSlider::Destructor
35 // Access: Published, Virtual
36 // Description:
37 ////////////////////////////////////////////////////////////////////
38 VertexSlider::
39 ~VertexSlider() {
40  // We shouldn't destruct while any SliderTables are holding our
41  // pointer.
42  nassertv(_tables.empty());
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: VertexSlider::output
47 // Access: Published, Virtual
48 // Description:
49 ////////////////////////////////////////////////////////////////////
50 void VertexSlider::
51 output(ostream &out) const {
52  out << get_type() << " " << *get_name();
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: VertexSlider::write
57 // Access: Published, Virtual
58 // Description:
59 ////////////////////////////////////////////////////////////////////
60 void VertexSlider::
61 write(ostream &out, int indent_level) const {
62  indent(out, indent_level)
63  << *this << " = " << get_slider() << "\n";
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: VertexSlider::mark_modified
68 // Access: Protected
69 // Description: Intended to be called by a derived class whenever the
70 // reported transform might have changed. Without
71 // calling this method, changes to get_slider() may not
72 // be propagated through the system.
73 ////////////////////////////////////////////////////////////////////
74 void VertexSlider::
75 mark_modified(Thread *current_thread) {
76  CDWriter cdata(_cycler, true, current_thread);
77  cdata->_modified = VertexTransform::get_next_modified(current_thread);
78 
79  Tables::iterator ti;
80  for (ti = _tables.begin(); ti != _tables.end(); ++ti) {
81  (*ti)->update_modified(cdata->_modified, current_thread);
82  }
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function: VertexSlider::write_datagram
87 // Access: Public, Virtual
88 // Description: Writes the contents of this object to the datagram
89 // for shipping out to a Bam file.
90 ////////////////////////////////////////////////////////////////////
91 void VertexSlider::
93  TypedWritable::write_datagram(manager, dg);
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: VertexSlider::fillin
98 // Access: Protected
99 // Description: This internal function is called by make_from_bam to
100 // read in all of the relevant data from the BamFile for
101 // the new VertexSlider.
102 ////////////////////////////////////////////////////////////////////
103 void VertexSlider::
104 fillin(DatagramIterator &scan, BamReader *manager) {
105  TypedWritable::fillin(scan, manager);
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: VertexSlider::CData::make_copy
110 // Access: Public, Virtual
111 // Description:
112 ////////////////////////////////////////////////////////////////////
113 CycleData *VertexSlider::CData::
114 make_copy() const {
115  return new CData(*this);
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: VertexSlider::CData::write_datagram
120 // Access: Public, Virtual
121 // Description: Writes the contents of this object to the datagram
122 // for shipping out to a Bam file.
123 ////////////////////////////////////////////////////////////////////
124 void VertexSlider::CData::
125 write_datagram(BamWriter *manager, Datagram &dg) const {
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: VertexSlider::CData::complete_pointers
130 // Access: Public, Virtual
131 // Description: Receives an array of pointers, one for each time
132 // manager->read_pointer() was called in fillin().
133 // Returns the number of pointers processed.
134 ////////////////////////////////////////////////////////////////////
135 int VertexSlider::CData::
136 complete_pointers(TypedWritable **p_list, BamReader *manager) {
137  int pi = CycleData::complete_pointers(p_list, manager);
138 
139  return pi;
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function: VertexSlider::CData::fillin
144 // Access: Public, Virtual
145 // Description: This internal function is called by make_from_bam to
146 // read in all of the relevant data from the BamFile for
147 // the new VertexSlider.
148 ////////////////////////////////////////////////////////////////////
149 void VertexSlider::CData::
150 fillin(DatagramIterator &scan, BamReader *manager) {
151 }
const InternalName * get_name() const
Returns the name of this particular slider.
Definition: vertexSlider.I:25
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
static UpdateSeq get_next_modified(Thread *current_thread)
Returns a monotonically increasing sequence.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
Definition: cycleData.cxx:55
A thread; that is, a lightweight process.
Definition: thread.h:51
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.