xFileDataNodeReference.cxx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Filename: xFileDataNodeReference.cxx
  2. // Created by: drose (08Oct04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #include "xFileDataNodeReference.h"
  19. #include "indent.h"
  20. TypeHandle XFileDataNodeReference::_type_handle;
  21. ////////////////////////////////////////////////////////////////////
  22. // Function: XFileDataNodeReference::Constructor
  23. // Access: Public
  24. // Description:
  25. ////////////////////////////////////////////////////////////////////
  26. XFileDataNodeReference::
  27. XFileDataNodeReference(XFileDataNodeTemplate *object) :
  28. XFileDataNode(object->get_x_file(), object->get_name(),
  29. object->get_template()),
  30. _object(object)
  31. {
  32. }
  33. ////////////////////////////////////////////////////////////////////
  34. // Function: XFileDataNodeReference::is_complex_object
  35. // Access: Public, Virtual
  36. // Description: Returns true if this kind of data object is a complex
  37. // object that can hold nested data elements, false
  38. // otherwise.
  39. ////////////////////////////////////////////////////////////////////
  40. bool XFileDataNodeReference::
  41. is_complex_object() const {
  42. return true;
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: XFileDataNodeReference::write_text
  46. // Access: Public, Virtual
  47. // Description: Writes a suitable representation of this node to an
  48. // .x file in text mode.
  49. ////////////////////////////////////////////////////////////////////
  50. void XFileDataNodeReference::
  51. write_text(ostream &out, int indent_level) const {
  52. indent(out, indent_level)
  53. << "{ " << _object->get_name() << " }\n";
  54. }
  55. ////////////////////////////////////////////////////////////////////
  56. // Function: XFileDataNodeReference::get_num_elements
  57. // Access: Protected, Virtual
  58. // Description: Returns the number of nested data elements within the
  59. // object. This may be, e.g. the size of the array, if
  60. // it is an array.
  61. ////////////////////////////////////////////////////////////////////
  62. int XFileDataNodeReference::
  63. get_num_elements() const {
  64. return _object->size();
  65. }
  66. ////////////////////////////////////////////////////////////////////
  67. // Function: XFileDataNodeReference::get_element
  68. // Access: Protected, Virtual
  69. // Description: Returns the nth nested data element within the
  70. // object.
  71. ////////////////////////////////////////////////////////////////////
  72. const XFileDataObject *XFileDataNodeReference::
  73. get_element(int n) const {
  74. return &((*_object)[n]);
  75. }
  76. ////////////////////////////////////////////////////////////////////
  77. // Function: XFileDataNodeReference::get_element
  78. // Access: Protected, Virtual
  79. // Description: Returns the nested data element within the
  80. // object that has the indicated name.
  81. ////////////////////////////////////////////////////////////////////
  82. const XFileDataObject *XFileDataNodeReference::
  83. get_element(const string &name) const {
  84. return &((*_object)[name]);
  85. }