Panda3D

typedWritableReferenceCount.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 typedWritableReferenceCount.cxx
10 * @author jason
11 * @date 2000-06-08
12 */
13
14 #include "typedWritableReferenceCount.h"
15 #include "dcast.h"
16
17 TypeHandle TypedWritableReferenceCount::_type_handle;
18
19 /**
20 * Returns the pointer cast to a ReferenceCount pointer, if it is in fact of
21 * that type.
22 */
23 ReferenceCount *TypedWritableReferenceCount::
24 as_reference_count() {
25 return this;
26 }
27
28 /**
29 * Reads the bytes created by a previous call to encode_to_bam_stream(), and
30 * extracts and returns the single object on those bytes. Returns NULL on
31 * error.
32 *
33 * This method is intended to replace decode_raw_from_bam_stream() when you
34 * know the stream in question returns an object of type
35 * TypedWritableReferenceCount, allowing for easier reference count
36 * management. Note that the caller is still responsible for maintaining the
37 * reference count on the return value.
38 */
39 PT(TypedWritableReferenceCount) TypedWritableReferenceCount::
40 decode_from_bam_stream(vector_uchar data, BamReader *reader) {
41 TypedWritable *object;
42 ReferenceCount *ref_ptr;
43
44 if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, std::move(data), reader)) {
45 return DCAST(TypedWritableReferenceCount, object);
46 } else {
47 return nullptr;
48 }
49 }
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
ReferenceCount
A base class for all things that want to be reference-counted.
Definition: referenceCount.h:38
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TypedWritableReferenceCount
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Definition: typedWritableReferenceCount.h:31
TypedWritableReferenceCount::as_reference_count
virtual ReferenceCount * as_reference_count()
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
Definition: typedWritableReferenceCount.cxx:24
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
TypedWritable::decode_raw_from_bam_stream
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 ...
Definition: typedWritable.cxx:190
dcast.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT
PT(TypedWritableReferenceCount) TypedWritableReferenceCount
Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts and returns the si...
Definition: typedWritableReferenceCount.cxx:39
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.