Panda3D
cfCommand.cxx
1 // Filename: cfCommand.cxx
2 // Created by: drose (19Feb09)
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 "cfCommand.h"
16 
17 TypeHandle CFCommand::_type_handle;
18 TypeHandle CFDoCullCommand::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: CFCommand::Destructor
22 // Access: Published, Virtual
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 CFCommand::
26 ~CFCommand() {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: CFDoCullCommand::register_with_read_factory
31 // Access: Public, Static
32 // Description: Tells the BamReader how to create objects of type
33 // CFDoCullCommand.
34 ////////////////////////////////////////////////////////////////////
37  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: CFDoCullCommand::write_datagram
42 // Access: Public, Virtual
43 // Description: Writes the contents of this object to the datagram
44 // for shipping out to a Bam file.
45 ////////////////////////////////////////////////////////////////////
48  TypedWritable::write_datagram(manager, dg);
49  manager->write_pointer(dg, _scene);
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: CFDoCullCommand::update_bam_nested
54 // Access: Public, Virtual
55 // Description: Called by the BamWriter when this object has not
56 // itself been modified recently, but it should check
57 // its nested objects for updates.
58 ////////////////////////////////////////////////////////////////////
61  manager->consider_update(_scene);
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: CFDoCullCommand::complete_pointers
66 // Access: Public, Virtual
67 // Description: Receives an array of pointers, one for each time
68 // manager->read_pointer() was called in fillin().
69 // Returns the number of pointers processed.
70 ////////////////////////////////////////////////////////////////////
73  int pi = TypedWritable::complete_pointers(p_list, manager);
74 
75  PandaNode *scene;
76  DCAST_INTO_R(scene, p_list[pi++], pi);
77  _scene = scene;
78 
79  return pi;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: CFDoCullCommand::make_from_bam
84 // Access: Protected, Static
85 // Description: This function is called by the BamReader's factory
86 // when a new object of type CFDoCullCommand is encountered
87 // in the Bam file. It should create the CFDoCullCommand
88 // and extract its information from the file.
89 ////////////////////////////////////////////////////////////////////
90 TypedWritable *CFDoCullCommand::
91 make_from_bam(const FactoryParams &params) {
92  CFDoCullCommand *node = new CFDoCullCommand;
93  DatagramIterator scan;
94  BamReader *manager;
95 
96  parse_params(params, scan, manager);
97  node->fillin(scan, manager);
98 
99  return node;
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: CFDoCullCommand::fillin
104 // Access: Protected
105 // Description: This internal function is called by make_from_bam to
106 // read in all of the relevant data from the BamFile for
107 // the new CFDoCullCommand.
108 ////////////////////////////////////////////////////////////////////
109 void CFDoCullCommand::
110 fillin(DatagramIterator &scan, BamReader *manager) {
111  TypedWritable::fillin(scan, manager);
112  manager->read_pointer(scan);
113 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
Definition: cfCommand.cxx:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
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'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.
Starts the cull process for a particular DisplayRegion.
Definition: cfCommand.h:62
static void register_with_read_factory()
Tells the BamReader how to create objects of type CFDoCullCommand.
Definition: cfCommand.cxx:36
virtual void update_bam_nested(BamWriter *manager)
Called by the BamWriter when this object has not itself been modified recently, but it should check i...
Definition: cfCommand.cxx:60
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()...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cfCommand.cxx:47
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:90
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:213
A class to retrieve the individual data elements previously stored in a Datagram. ...
void consider_update(const TypedWritable *obj)
Should be called from TypedWritable::update_bam_nested() to recursively check the entire hiererachy o...
Definition: bamWriter.cxx:237
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
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
Definition: bamWriter.cxx:279
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
Definition: bamReader.cxx:658