Panda3D
dcAtomicField.h
1 // Filename: dcAtomicField.h
2 // Created by: drose (05Oct00)
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 
15 #ifndef DCATOMICFIELD_H
16 #define DCATOMICFIELD_H
17 
18 #include "dcbase.h"
19 #include "dcField.h"
20 #include "dcSubatomicType.h"
21 #include "dcParameter.h"
22 
23 // Must use math.h instead of cmath.h so this can compile outside of
24 // Panda.
25 #include <math.h>
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : DCAtomicField
29 // Description : A single atomic field of a Distributed Class, as read
30 // from a .dc file. This defines an interface to the
31 // Distributed Class, and is always implemented as a
32 // remote procedure method.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_DIRECT DCAtomicField : public DCField {
35 public:
36  DCAtomicField(const string &name, DCClass *dclass, bool bogus_field);
37  virtual ~DCAtomicField();
38 
39 PUBLISHED:
40  virtual DCAtomicField *as_atomic_field();
41  virtual const DCAtomicField *as_atomic_field() const;
42 
43  int get_num_elements() const;
44  DCParameter *get_element(int n) const;
45 
46  // These five methods are deprecated and will be removed soon.
47  string get_element_default(int n) const;
48  bool has_element_default(int n) const;
49  string get_element_name(int n) const;
50  DCSubatomicType get_element_type(int n) const;
51  int get_element_divisor(int n) const;
52 
53 public:
54  void add_element(DCParameter *element);
55 
56  virtual void output(ostream &out, bool brief) const;
57  virtual void write(ostream &out, bool brief, int indent_level) const;
58  virtual void generate_hash(HashGenerator &hashgen) const;
59 
60  virtual DCPackerInterface *get_nested_field(int n) const;
61 
62 protected:
63  virtual bool do_check_match(const DCPackerInterface *other) const;
64  virtual bool do_check_match_atomic_field(const DCAtomicField *other) const;
65 
66 private:
67  void output_element(ostream &out, bool brief, DCParameter *element) const;
68 
69  typedef pvector<DCParameter *> Elements;
70  Elements _elements;
71 };
72 
73 #include "dcAtomicField.I"
74 
75 #endif
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:40
virtual DCAtomicField * as_atomic_field()
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic fie...
Definition: dcField.cxx:124
Defines a particular DistributedClass as read from an input .dc file.
Definition: dcClass.h:47
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
A single atomic field of a Distributed Class, as read from a .dc file.
Definition: dcAtomicField.h:34
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
Definition: dcField.cxx:528
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
Represents the type specification for a single parameter within a field specification.
Definition: dcParameter.h:39
void output(ostream &out) const
Write a string representation of this instance to <out>.
Definition: dcField.I:187
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:26
virtual bool do_check_match_atomic_field(const DCAtomicField *other) const
Returns true if this field matches the indicated atomic field, false otherwise.
This defines the internal interface for packing values into a DCField.
void write(ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition: dcField.I:198