Panda3D
 All Classes Functions Variables Enumerations
dcMolecularField.h
1 // Filename: dcMolecularField.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 DCMOLECULARFIELD_H
16 #define DCMOLECULARFIELD_H
17 
18 #include "dcbase.h"
19 #include "dcField.h"
20 
21 class DCAtomicField;
22 class DCParameter;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : DCMolecularField
26 // Description : A single molecular field of a Distributed Class, as
27 // read from a .dc file. This represents a combination
28 // of two or more related atomic fields, that will often
29 // be treated as a unit.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_DIRECT DCMolecularField : public DCField {
32 public:
33  DCMolecularField(const string &name, DCClass *dclass);
34 
35 PUBLISHED:
37  virtual const DCMolecularField *as_molecular_field() const;
38 
39  int get_num_atomics() const;
40  DCAtomicField *get_atomic(int n) const;
41 
42 public:
43  void add_atomic(DCAtomicField *atomic);
44 
45  virtual void output(ostream &out, bool brief) const;
46  virtual void write(ostream &out, bool brief, int indent_level) const;
47  virtual void generate_hash(HashGenerator &hashgen) const;
48 
49  virtual DCPackerInterface *get_nested_field(int n) const;
50 
51 protected:
52  virtual bool do_check_match(const DCPackerInterface *other) const;
53  virtual bool do_check_match_molecular_field(const DCMolecularField *other) const;
54 
55 private:
56  // These members define the primary interface to the molecular field
57  // definition as read from the file.
58  typedef pvector<DCAtomicField *> Fields;
59  Fields _fields;
60  bool _got_keywords;
61 
62  DCParameter *get_next_pack_element();
63 
64  typedef pvector<DCPackerInterface *> NestedFields;
65  NestedFields _nested_fields;
66 };
67 
68 #endif
69 
70 
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
Definition: dcField.cxx:524
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:40
Defines a particular DistributedClass as read from an input .dc file.
Definition: dcClass.h:47
A single atomic field of a Distributed Class, as read from a .dc file.
Definition: dcAtomicField.h:34
virtual DCMolecularField * as_molecular_field()
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular...
Definition: dcField.cxx:144
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
virtual bool do_check_match_molecular_field(const DCMolecularField *other) const
Returns true if this field matches the indicated molecular field, false otherwise.
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:26
A single molecular field of a Distributed Class, as read from a .dc file.
This defines the internal interface for packing values into a DCField.