Panda3D
typedWritableReferenceCount.h
1 // Filename: typedWritableReferenceCount.h
2 // Created by: jason (08Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef TYPEDWRITABLEREFERENCECOUNT_H
16 #define TYPEDWRITABLEREFERENCECOUNT_H
17 
18 #include "pandabase.h"
19 
20 #include "typedWritable.h"
21 #include "referenceCount.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : TypedWritableReferenceCount
25 // Description : A base class for things which need to inherit from
26 // both TypedWritable and from ReferenceCount. It's
27 // convenient to define this intermediate base class
28 // instead of multiply inheriting from the two classes
29 // each time they are needed, so that we can sensibly
30 // pass around pointers to things which are both
31 // TypedWritables and ReferenceCounters.
32 //
33 // See also TypedObject for detailed instructions.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_PUTIL TypedWritableReferenceCount : public TypedWritable, public ReferenceCount {
36 public:
38  INLINE TypedWritableReferenceCount(const TypedWritableReferenceCount &copy);
39  INLINE void operator = (const TypedWritableReferenceCount &copy);
40 
42 
43 PUBLISHED:
44  static PT(TypedWritableReferenceCount) decode_from_bam_stream(const string &data, BamReader *reader = NULL);
45 
46 public:
47  virtual TypeHandle get_type() const {
48  return get_class_type();
49  }
50  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
51  static TypeHandle get_class_type() {
52  return _type_handle;
53  }
54  static void init_type() {
55  TypedWritable::init_type();
56  ReferenceCount::init_type();
57  register_type(_type_handle, "TypedWritableReferenceCount",
58  TypedWritable::get_class_type(),
59  ReferenceCount::get_class_type());
61  "TypedWriteableReferenceCount");
62  }
63 
64 private:
65  static TypeHandle _type_handle;
66 };
67 
68 #include "typedWritableReferenceCount.I"
69 
70 #endif
virtual ReferenceCount * as_reference_count()
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
void record_alternate_name(TypeHandle type, const string &name)
Indicates an alternate name for the same type.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
A base class for all things that want to be reference-counted.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85