Panda3D
Loading...
Searching...
No Matches
userVertexSlider.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 userVertexSlider.cxx
10 * @author drose
11 * @date 2005-03-28
12 */
13
14#include "userVertexSlider.h"
15#include "bamReader.h"
16#include "bamWriter.h"
17
18TypeHandle UserVertexSlider::_type_handle;
19
20/**
21 *
22 */
23UserVertexSlider::
24UserVertexSlider(const std::string &name) :
25 VertexSlider(InternalName::make(name))
26{
27}
28
29/**
30 *
31 */
32UserVertexSlider::
33UserVertexSlider(const InternalName *name) :
34 VertexSlider(name)
35{
36}
37
38/**
39 * Returns the current slider value.
40 */
42get_slider() const {
43 CDReader cdata(_cycler);
44 return cdata->_slider;
45}
46
47/**
48 *
49 */
50CycleData *UserVertexSlider::CData::
51make_copy() const {
52 return new CData(*this);
53}
54
55/**
56 * Tells the BamReader how to create objects of type UserVertexSlider.
57 */
60 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
61}
62
63/**
64 * Writes the contents of this object to the datagram for shipping out to a
65 * Bam file.
66 */
68write_datagram(BamWriter *manager, Datagram &dg) {
70
71 manager->write_cdata(dg, _cycler);
72}
73
74/**
75 * This function is called by the BamReader's factory when a new object of
76 * type UserVertexSlider is encountered in the Bam file. It should create the
77 * UserVertexSlider and extract its information from the file.
78 */
79TypedWritable *UserVertexSlider::
80make_from_bam(const FactoryParams &params) {
81 UserVertexSlider *object = new UserVertexSlider("");
83 BamReader *manager;
84
85 parse_params(params, scan, manager);
86 object->fillin(scan, manager);
87
88 return object;
89}
90
91/**
92 * This internal function is called by make_from_bam to read in all of the
93 * relevant data from the BamFile for the new UserVertexSlider.
94 */
95void UserVertexSlider::
96fillin(DatagramIterator &scan, BamReader *manager) {
97 VertexSlider::fillin(scan, manager);
98
99 manager->read_cdata(scan, _cycler);
100}
101
102/**
103 * Writes the contents of this object to the datagram for shipping out to a
104 * Bam file.
105 */
106void UserVertexSlider::CData::
107write_datagram(BamWriter *manager, Datagram &dg) const {
108 dg.add_stdfloat(_slider);
109}
110
111/**
112 * This internal function is called by make_from_bam to read in all of the
113 * relevant data from the BamFile for the new UserVertexSlider.
114 */
115void UserVertexSlider::CData::
116fillin(DatagramIterator &scan, BamReader *manager) {
117 _slider = scan.get_stdfloat();
118}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition bamReader.I:275
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition bamReader.I:177
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
Definition datagram.I:133
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition factory.I:73
Encodes a string name in a hash table, mapping it to a pointer.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
This is a specialization on VertexSlider that allows the user to specify any arbitrary slider valie h...
static void register_with_read_factory()
Tells the BamReader how to create objects of type UserVertexSlider.
virtual PN_stdfloat get_slider() const
Returns the current slider value.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is an abstract base class that retains some slider value, which is a linear value that typically...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.