Panda3D

typedWritableReferenceCount.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 typedWritableReferenceCount.h
10 * @author jason
11 * @date 2000-06-08
12 */
13
14 #ifndef TYPEDWRITABLEREFERENCECOUNT_H
15 #define TYPEDWRITABLEREFERENCECOUNT_H
16
17 #include "pandabase.h"
18
19 #include "typedWritable.h"
20 #include "referenceCount.h"
21
22 /**
23 * A base class for things which need to inherit from both TypedWritable and
24 * from ReferenceCount. It's convenient to define this intermediate base
25 * class instead of multiply inheriting from the two classes each time they
26 * are needed, so that we can sensibly pass around pointers to things which
27 * are both TypedWritables and ReferenceCounters.
28 *
29 * See also TypedObject for detailed instructions.
30 */
31 class EXPCL_PANDA_PUTIL TypedWritableReferenceCount : public TypedWritable, public ReferenceCount {
32 public:
33 INLINE TypedWritableReferenceCount();
34 INLINE TypedWritableReferenceCount(const TypedWritableReferenceCount &copy);
35 INLINE void operator = (const TypedWritableReferenceCount &copy);
36
37 virtual ReferenceCount *as_reference_count();
38
39 PUBLISHED:
40 static PT(TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data, BamReader *reader = nullptr);
41
42 public:
43 virtual TypeHandle get_type() const {
44 return get_class_type();
45 }
46 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
47 static TypeHandle get_class_type() {
48 return _type_handle;
49 }
50 static void init_type() {
51 TypedWritable::init_type();
52 ReferenceCount::init_type();
53 register_type(_type_handle, "TypedWritableReferenceCount",
54 TypedWritable::get_class_type(),
55 ReferenceCount::get_class_type());
56 TypeRegistry::ptr()->record_alternate_name(_type_handle,
57 "TypedWriteableReferenceCount");
58 }
59
60 private:
61 static TypeHandle _type_handle;
62 };
63
64 // We can safely redefine this as a no-op.
65 template<>
66 INLINE void PointerToBase<TypedWritableReferenceCount>::update_type(To *ptr) {}
67
68 #include "typedWritableReferenceCount.I"
69
70 #endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
PointerToBase
This is the base class for PointerTo and ConstPointerTo.
Definition: pointerToBase.h:29
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
TypeRegistry::record_alternate_name
void record_alternate_name(TypeHandle type, const std::string &name)
Indicates an alternate name for the same type.
Definition: typeRegistry.cxx:189
TypeRegistry::ptr
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
Definition: typeRegistry.I:30
TypedWritableReferenceCount
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Definition: typedWritableReferenceCount.h:31
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
TypedWritable::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: typedWritable.cxx:121
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
typedWritableReferenceCount.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedWritable.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.