Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

direct/src/dcparser/dcAtomicField.h

Go to the documentation of this file.
00001 // Filename: dcAtomicField.h
00002 // Created by:  drose (05Oct00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef DCATOMICFIELD_H
00020 #define DCATOMICFIELD_H
00021 
00022 #include <cmath.h>
00023 #include "dcbase.h"
00024 #include "dcField.h"
00025 #include "dcSubatomicType.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 PUBLISHED:
00036   virtual DCAtomicField *as_atomic_field();
00037 
00038   int get_num_elements() const;
00039   DCSubatomicType get_element_type(int n) const;
00040   string get_element_name(int n) const;
00041   int get_element_divisor(int n) const;
00042   string get_element_default(int n) const;
00043   bool has_element_default(int n) const;
00044 
00045   bool is_required() const;
00046   bool is_broadcast() const;
00047   bool is_p2p() const;
00048   bool is_ram() const;
00049   bool is_db() const;
00050   bool is_clsend() const;
00051   bool is_clrecv() const;
00052   bool is_ownsend() const;
00053 
00054 public:
00055   DCAtomicField();
00056   virtual void write(ostream &out, int indent_level = 0) const;
00057   virtual void generate_hash(HashGenerator &hash) const;
00058 
00059 public:
00060   // These members define the primary interface to the atomic field
00061   // definition as read from the file.
00062   class ElementType {
00063   public:
00064     ElementType();
00065     bool set_default_value(double num);
00066     bool set_default_value(const string &str);
00067     bool set_default_value_literal(const string &str);
00068 
00069     bool add_default_value(double num);
00070     bool add_default_value(const string &str);
00071     bool add_default_value_literal(const string &str);
00072     bool end_array();
00073 
00074     DCSubatomicType _type;
00075     string _name;
00076     int _divisor;
00077     string _default_value;
00078     bool _has_default_value;
00079 
00080   private:
00081     bool format_default_value(double num, string &formatted) const;
00082     bool format_default_value(const string &str, string &formatted) const;
00083   };
00084 
00085   typedef pvector<ElementType> Elements;
00086   Elements _elements;
00087 
00088   enum Flags {
00089     F_required        = 0x0001,
00090     F_broadcast       = 0x0002,
00091     F_p2p             = 0x0004,
00092     F_ram             = 0x0008,
00093     F_db              = 0x0010,
00094     F_clsend          = 0x0020,
00095     F_clrecv          = 0x0040,
00096     F_ownsend         = 0x0080,
00097   };
00098 
00099   int _flags;  // A bitmask union of any of the above values.
00100 };
00101 
00102 #endif

Generated on Fri May 2 01:36:59 2003 for Direct by doxygen1.3