Panda3D
modelRoot.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 modelRoot.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef MODELROOT_H
15 #define MODELROOT_H
16 
17 #include "pandabase.h"
18 #include "referenceCount.h"
19 #include "modelNode.h"
20 
21 /**
22  * A node of this type is created automatically at the root of each model file
23  * that is loaded. It may eventually contain some information about the
24  * contents of the model; at the moment, it contains no special information,
25  * but can be used as a flag to indicate the presence of a loaded model file.
26  */
27 class EXPCL_PANDA_PGRAPH ModelRoot : public ModelNode {
28 PUBLISHED:
29  INLINE explicit ModelRoot(const std::string &name);
30  INLINE explicit ModelRoot(const Filename &fullpath, time_t timestamp);
31 
32  INLINE int get_model_ref_count() const;
33  MAKE_PROPERTY(model_ref_count, get_model_ref_count);
34 
35  INLINE const Filename &get_fullpath() const;
36  INLINE void set_fullpath(const Filename &fullpath);
37  MAKE_PROPERTY(fullpath, get_fullpath, set_fullpath);
38 
39  INLINE time_t get_timestamp() const;
40  INLINE void set_timestamp(time_t timestamp);
41  MAKE_PROPERTY(timestamp, get_timestamp, set_timestamp);
42 
43  // This class is used to unify references to the same model.
44  class ModelReference : public ReferenceCount {
45  PUBLISHED:
46  INLINE ModelReference();
47  };
48 
49  INLINE ModelReference *get_reference() const;
50  void set_reference(ModelReference *ref);
51  MAKE_PROPERTY(reference, get_reference, set_reference);
52 
53 protected:
54  INLINE ModelRoot(const ModelRoot &copy);
55 
56 public:
57  virtual PandaNode *make_copy() const;
58 
59 private:
60  Filename _fullpath;
61  time_t _timestamp;
62  PT(ModelReference) _reference;
63 
64 public:
65  static void register_with_read_factory();
66  virtual void write_datagram(BamWriter *manager, Datagram &dg);
67 
68 protected:
69  static TypedWritable *make_from_bam(const FactoryParams &params);
70  void fillin(DatagramIterator &scan, BamReader *manager);
71 
72 public:
73  static TypeHandle get_class_type() {
74  return _type_handle;
75  }
76  static void init_type() {
77  ModelNode::init_type();
78  register_type(_type_handle, "ModelRoot",
79  ModelNode::get_class_type());
80  }
81  virtual TypeHandle get_type() const {
82  return get_class_type();
83  }
84  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85 
86 private:
87  static TypeHandle _type_handle;
88 };
89 
90 #include "modelRoot.I"
91 
92 #endif
A node of this type is created automatically at the root of each model file that is loaded.
Definition: modelRoot.h:27
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
static void register_with_read_factory()
Tells the BamReader how to create objects of type ModelNode.
Definition: modelNode.cxx:133
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: modelNode.cxx:175
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
Definition: modelNode.h:31
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: modelNode.cxx:29
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38