Panda3D
|
00001 // Filename: dcAtomicField.h 00002 // Created by: drose (05Oct00) 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 DCATOMICFIELD_H 00016 #define DCATOMICFIELD_H 00017 00018 #include "dcbase.h" 00019 #include "dcField.h" 00020 #include "dcSubatomicType.h" 00021 #include "dcParameter.h" 00022 00023 // Must use math.h instead of cmath.h so this can compile outside of 00024 // Panda. 00025 #include <math.h> 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : DCAtomicField 00029 // Description : A single atomic field of a Distributed Class, as read 00030 // from a .dc file. This defines an interface to the 00031 // Distributed Class, and is always implemented as a 00032 // remote procedure method. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_DIRECT DCAtomicField : public DCField { 00035 public: 00036 DCAtomicField(const string &name, DCClass *dclass, bool bogus_field); 00037 virtual ~DCAtomicField(); 00038 00039 PUBLISHED: 00040 virtual DCAtomicField *as_atomic_field(); 00041 virtual const DCAtomicField *as_atomic_field() const; 00042 00043 int get_num_elements() const; 00044 DCParameter *get_element(int n) const; 00045 00046 // These five methods are deprecated and will be removed soon. 00047 string get_element_default(int n) const; 00048 bool has_element_default(int n) const; 00049 string get_element_name(int n) const; 00050 DCSubatomicType get_element_type(int n) const; 00051 int get_element_divisor(int n) const; 00052 00053 public: 00054 void add_element(DCParameter *element); 00055 00056 virtual void output(ostream &out, bool brief) const; 00057 virtual void write(ostream &out, bool brief, int indent_level) const; 00058 virtual void generate_hash(HashGenerator &hashgen) const; 00059 00060 virtual DCPackerInterface *get_nested_field(int n) const; 00061 00062 protected: 00063 virtual bool do_check_match(const DCPackerInterface *other) const; 00064 virtual bool do_check_match_atomic_field(const DCAtomicField *other) const; 00065 00066 private: 00067 void output_element(ostream &out, bool brief, DCParameter *element) const; 00068 00069 typedef pvector<DCParameter *> Elements; 00070 Elements _elements; 00071 }; 00072 00073 #include "dcAtomicField.I" 00074 00075 #endif