30#define WRITE_PTA(Manager, dest, Write_func, array) \
31 if (!Manager->register_pta(dest, array.p())) \
33 Write_func(Manager, dest, array); \
63class EXPCL_PANDA_PUTIL BamWriter :
public BamEnums {
74 bool has_object(
const TypedWritable *obj)
const;
91 EXTENSION(PyObject *get_file_version()
const);
96 MAKE_PROPERTY(file_version, get_file_version);
120 int before_major,
int before_minor);
123 void object_destructs(TypedWritable *
object);
125 void write_object_id(
Datagram &dg,
int object_id);
126 void write_pta_id(
Datagram &dg,
int pta_id);
127 int enqueue_object(
const TypedWritable *
object);
130 int _file_major, _file_minor;
132 bool _file_stdfloat_double;
133 BamTextureMode _file_texture_mode;
138 TypedWritable *_root_node =
nullptr;
141 pset<int, int_hash> _types_written;
153 StoreState(
int object_id) : _object_id(object_id), _refcount(nullptr) {}
155 typedef phash_map<const TypedWritable *, StoreState, pointer_hash> StateMap;
162 UpdateSeq _writing_seq;
167 BamObjectCode _next_boc;
171 bool _long_object_id;
175 typedef pdeque<const TypedWritable *> ObjectQueue;
176 ObjectQueue _object_queue;
181 typedef vector_int FreedObjectIds;
182 FreedObjectIds _freed_object_ids;
186 typedef phash_map<const void *, int, pointer_hash> PTAMap;
192 DatagramSink *_target;
195 friend class TypedWritable;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void flush()
Ensures that all data written thus far is manifested on the output stream.
void set_file_minor_ver(int minor_ver)
Changes the minor .bam version to write.
get_file_endian
Returns the endian preference indicated by the Bam file currently being written.
bool has_object(const TypedWritable *obj) const
Returns true if the object has previously been written (or at least requested to be written) to the b...
bool write_object(const TypedWritable *obj)
Writes a single object to the Bam file, so that the BamReader::read_object() can later correctly rest...
int get_file_major_ver() const
Returns the major version number of the Bam file currently being written.
void consider_update(const TypedWritable *obj)
Should be called from TypedWritable::update_bam_nested() to recursively check the entire hiererachy o...
void write_file_data(SubfileInfo &result, const Filename &filename)
Writes a block of auxiliary file data from the indicated file (within the vfs).
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
bool init()
Initializes the BamWriter prior to writing any objects to its output stream.
bool register_pta(Datagram &packet, const void *ptr)
Prepares to write a PointerToArray to the Bam file, unifying references to the same pointer across th...
get_file_texture_mode
Returns the BamTextureMode preference indicated by the Bam file currently being written.
get_filename
If a BAM is a file, then the BamWriter should contain the name of the file.
static void record_obsolete_type_name(TypeHandle type, std::string name, int before_major, int before_minor)
Registers the given type as having an older name in .bam files *before* the indicated version.
void write_handle(Datagram &packet, TypeHandle type)
Writes a TypeHandle to the file in such a way that the BamReader can read the same TypeHandle later v...
get_file_stdfloat_double
Returns true if the file will store all "standard" floats as 64-bit doubles, or false if they are 32-...
get_root_node
Returns the root node of the part of the scene graph we are currently writing out.
set_root_node
Sets the root node of the part of the scene graph we are currently writing out.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
static std::string get_obsolete_type_name(TypeHandle type, int major, int minor)
Returns the name that the given type had in an older .bam version.
get_target
Returns the current target of the BamWriter as set by set_target() or the constructor.
set_target
Changes the destination of future datagrams written by the BamWriter.
set_file_texture_mode
Changes the BamTextureMode preference for the Bam file currently being written.
This class defines the abstract interface to sending datagrams to any target, whether it be into a fi...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
The name of a file, such as a texture file or an Egg file.
A base class for all things that want to be reference-counted.
This class records a particular byte sub-range within an existing file on disk.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.