modelRoot.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Filename: modelRoot.h
  2. // Created by: drose (16Mar02)
  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. #ifndef MODELROOT_H
  15. #define MODELROOT_H
  16. #include "pandabase.h"
  17. #include "referenceCount.h"
  18. #include "modelNode.h"
  19. ////////////////////////////////////////////////////////////////////
  20. // Class : ModelRoot
  21. // Description : A node of this type is created automatically at the
  22. // root of each model file that is loaded. It may
  23. // eventually contain some information about the
  24. // contents of the model; at the moment, it contains no
  25. // special information, but can be used as a flag to
  26. // indicate the presence of a loaded model file.
  27. ////////////////////////////////////////////////////////////////////
  28. class EXPCL_PANDA_PGRAPH ModelRoot : public ModelNode {
  29. PUBLISHED:
  30. INLINE ModelRoot(const string &name);
  31. INLINE int get_model_ref_count() const;
  32. INLINE const Filename &get_fullpath() const;
  33. INLINE void set_fullpath(const Filename &fullpath);
  34. // This class is used to unify references to the same model.
  35. class ModelReference : public ReferenceCount {
  36. PUBLISHED:
  37. INLINE ModelReference();
  38. };
  39. INLINE ModelReference *get_reference() const;
  40. void set_reference(ModelReference *ref);
  41. protected:
  42. INLINE ModelRoot(const ModelRoot &copy);
  43. public:
  44. virtual PandaNode *make_copy() const;
  45. private:
  46. Filename _fullpath;
  47. PT(ModelReference) _reference;
  48. public:
  49. static void register_with_read_factory();
  50. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  51. protected:
  52. static TypedWritable *make_from_bam(const FactoryParams &params);
  53. void fillin(DatagramIterator &scan, BamReader *manager);
  54. public:
  55. static TypeHandle get_class_type() {
  56. return _type_handle;
  57. }
  58. static void init_type() {
  59. ModelNode::init_type();
  60. register_type(_type_handle, "ModelRoot",
  61. ModelNode::get_class_type());
  62. }
  63. virtual TypeHandle get_type() const {
  64. return get_class_type();
  65. }
  66. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  67. private:
  68. static TypeHandle _type_handle;
  69. };
  70. #include "modelRoot.I"
  71. #endif