Panda3D

xFileDataNodeTemplate.h

00001 // Filename: xFileDataNodeTemplate.h
00002 // Created by:  drose (03Oct04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef XFILEDATANODETEMPLATE_H
00016 #define XFILEDATANODETEMPLATE_H
00017 
00018 #include "pandatoolbase.h"
00019 #include "xFileDataNode.h"
00020 #include "xFileTemplate.h"
00021 #include "xFileParseData.h"
00022 #include "pointerTo.h"
00023 #include "pta_int.h"
00024 #include "pta_double.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : XFileDataNodeTemplate
00028 // Description : This is a node which contains all of the data
00029 //               elements defined by a template.  See XFileTemplate
00030 //               for the definition of the template; this class only
00031 //               contains the data members for a particular instance
00032 //               of a template.
00033 ////////////////////////////////////////////////////////////////////
00034 class XFileDataNodeTemplate : public XFileDataNode {
00035 public:
00036   XFileDataNodeTemplate(XFile *x_file, const string &name,
00037                         XFileTemplate *xtemplate);
00038 
00039   void zero_fill();
00040 
00041   virtual bool is_complex_object() const;
00042 
00043   void add_parse_double(PTA_double double_list);
00044   void add_parse_int(PTA_int int_list);
00045   void add_parse_string(const string &str);
00046   bool finalize_parse_data();
00047 
00048   virtual bool add_element(XFileDataObject *element);
00049 
00050   virtual void write_text(ostream &out, int indent_level) const;
00051   virtual void write_data(ostream &out, int indent_level,
00052                           const char *separator) const;
00053 
00054 protected:
00055   virtual int get_num_elements() const;
00056   virtual XFileDataObject *get_element(int n);
00057   virtual XFileDataObject *get_element(const string &name);
00058 
00059 private:
00060   XFileParseDataList _parse_data_list;
00061   
00062   typedef pvector< PT(XFileDataObject) > NestedElements;
00063   NestedElements _nested_elements;
00064 
00065 public:
00066   static TypeHandle get_class_type() {
00067     return _type_handle;
00068   }
00069   static void init_type() {
00070     XFileDataNode::init_type();
00071     register_type(_type_handle, "XFileDataNodeTemplate",
00072                   XFileDataNode::get_class_type());
00073   }
00074   virtual TypeHandle get_type() const {
00075     return get_class_type();
00076   }
00077   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00078 
00079 private:
00080   static TypeHandle _type_handle;
00081 };
00082 
00083 #include "xFileDataNodeTemplate.I"
00084 
00085 #endif
00086   
00087 
00088 
00089 
 All Classes Functions Variables Enumerations