Panda3D
cycleData.h
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 cycleData.h
10 * @author drose
11 * @date 2002-02-21
12 */
13
14#ifndef CYCLEDATA_H
15#define CYCLEDATA_H
16
17#include "pandabase.h"
18#include "typeHandle.h"
19#include "nodeReferenceCount.h"
20
21class BamWriter;
22class BamReader;
23class TypedWritable;
24class Datagram;
26
27/**
28 * A single page of data maintained by a PipelineCycler. Normally you should
29 * inherit from this class to define the data structures that are important to
30 * protect between stages of a pipeline. See PipelineCycler.
31 */
32#ifdef DO_PIPELINING
33
34// If we are compiling in pipelining support, we maintain a pointer to a
35// CycleData object in each containing class, instead of the object itself.
36// Thus, it should be a ReferenceCount object. Furthermore, since we want to
37// make a distinction between references within the cycler, and references
38// outside the cycler (e.g. GeomPipelineReader), we make it a
39// NodeReferenceCount.
40class EXPCL_PANDA_PIPELINE CycleData : public NodeReferenceCount
41
42#else // !DO_PIPELINING
43
44// If we are *not* compiling in pipelining support, the CycleData object is
45// stored directly within its containing classes, and hence should not be a
46// ReferenceCount object.
47class EXPCL_PANDA_PIPELINE CycleData : public MemoryBase
48
49#endif // DO_PIPELINING
50{
51public:
52 INLINE CycleData() = default;
53 INLINE CycleData(CycleData &&from) = default;
54 INLINE CycleData(const CycleData &copy) = default;
55 virtual ~CycleData();
56
57 CycleData &operator = (CycleData &&from) = default;
58 CycleData &operator = (const CycleData &copy) = default;
59
60 virtual CycleData *make_copy() const=0;
61
62 virtual void write_datagram(BamWriter *, Datagram &) const;
63 virtual void write_datagram(BamWriter *, Datagram &, void *extra_data) const;
64 virtual int complete_pointers(TypedWritable **p_list, BamReader *manager);
65 virtual void fillin(DatagramIterator &scan, BamReader *manager);
66 virtual void fillin(DatagramIterator &scan, BamReader *manager,
67 void *extra_data);
68
69 virtual TypeHandle get_parent_type() const;
70 virtual void output(std::ostream &out) const;
71
72#ifdef DO_PIPELINING
73public:
74 static TypeHandle get_class_type() {
75 return _type_handle;
76 }
77
78 static void init_type() {
79 NodeReferenceCount::init_type();
80 register_type(_type_handle, "CycleData",
81 NodeReferenceCount::get_class_type());
82 }
83
84private:
85 static TypeHandle _type_handle;
86#endif
87};
88
89INLINE std::ostream &
90operator << (std::ostream &out, const CycleData &cd) {
91 cd.output(out);
92 return out;
93}
94
95#include "cycleData.I"
96
97#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: cycleData.cxx:76
virtual void output(std::ostream &out) const
Formats the contents of the CycleData in some meaningful way for humans.
Definition: cycleData.cxx:85
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...
Definition: cycleData.cxx:58
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:32
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:48
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
Definition: memoryBase.h:65
This class specializes ReferenceCount to add an additional counter, called node_ref_count,...
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.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.