Go to the documentation of this file.
33 if (link ==
nullptr) {
37 link = (BamWriterLink *)(((uintptr_t)link) & ~(uintptr_t)0x1);
39 compare_and_exchange_ptr(_bam_writers, (
void *)link,
nullptr));
41 while (link !=
nullptr) {
42 BamWriterLink *next_link = link->_next;
43 link->_writer->object_destructs(
this);
140 if (writer ==
nullptr) {
148 if (!writer.
init()) {
195 if (reader ==
nullptr) {
198 if (!buffer.
read_header(head, _bam_header.size())) {
202 if (head != _bam_header) {
207 if (!reader.
init()) {
219 if (ref_ptr ==
nullptr) {
241 if (ref_ptr ==
nullptr) {
268 nassertv(writer !=
nullptr);
270 BamWriterLink *begin;
271 BamWriterLink *new_link =
new BamWriterLink;
272 new_link->_writer = writer;
275 nassertv(((uintptr_t)new_link & (uintptr_t)0x1) == 0);
280 begin = (BamWriterLink *)(((uintptr_t)begin) & ~(uintptr_t)0x1);
281 new_link->_next = begin;
283 compare_and_exchange_ptr(_bam_writers, (
void *)begin, (
void *)new_link));
292 nassertv(writer !=
nullptr);
294 BamWriterLink *begin;
300 begin = (BamWriterLink *)(((uintptr_t)begin) & ~(uintptr_t)0x1);
301 if (begin ==
nullptr) {
306 compare_and_exchange_ptr(_bam_writers, (
void *)begin,
307 (
void *)((uintptr_t)begin | (uintptr_t)0x1)));
310 BamWriterLink *prev_link =
nullptr;
311 BamWriterLink *link = begin;
313 while (link !=
nullptr && link->_writer != writer) {
318 if (link ==
nullptr) {
320 _bam_writers = (
void *)begin;
324 if (prev_link ==
nullptr) {
326 _bam_writers = (
void *)link->_next;
328 prev_link->_next = link->_next;
329 _bam_writers = (
void *)begin;
set_source
Changes the source of future datagrams for this BamReader.
set_target
Changes the destination of future datagrams written by the BamWriter.
A base class for all things that want to be reference-counted.
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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().
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
vector_uchar encode_to_bam_stream() const
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that da...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
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...
TypeHandle is the identifier used to differentiate C++ class types.
virtual bool require_fully_complete() const
Some objects require all of their nested pointers to have been completed before the objects themselve...
bool init()
Initializes the BamReader prior to reading any objects from its source.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypedWritable * read_object()
Reads a single object from the Bam file.
bool write_object(const TypedWritable *obj)
Writes a single object to the Bam file, so that the BamReader::read_object() can later correctly rest...
void swap_data(vector_uchar &other)
Swaps the data in the internal buffer with that of the other buffer.
This class can be used to write a series of datagrams into a memory buffer.
static Pointer get_ptr(const Pointer &var)
Atomically retrieves the snapshot value of the indicated variable.
virtual ReferenceCount * as_reference_count()
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
bool write_header(const std::string &header)
Writes a sequence of bytes to the beginning of the datagram file.
void ref() const
Explicitly increments the reference count.
bool resolve()
This may be called at any time during processing of the Bam file to resolve all the known pointers so...
A trivial implementation for atomic adjustments for systems that don't require multiprogramming,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool init()
Initializes the BamWriter prior to writing any objects to its output stream.
virtual bool unref() const
Explicitly decrements the reference count.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool read_header(std::string &header, size_t num_bytes)
Reads a sequence of bytes from the beginning of the datagram file.
static bool decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object ...