Panda3D
dcMolecularField.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file dcMolecularField.h
10  * @author drose
11  * @date 2000-10-05
12  */
13 
14 #ifndef DCMOLECULARFIELD_H
15 #define DCMOLECULARFIELD_H
16 
17 #include "dcbase.h"
18 #include "dcField.h"
19 
20 class DCAtomicField;
21 class DCParameter;
22 
23 /**
24  * A single molecular field of a Distributed Class, as read from a .dc file.
25  * This represents a combination of two or more related atomic fields, that
26  * will often be treated as a unit.
27  */
28 class EXPCL_DIRECT_DCPARSER DCMolecularField : public DCField {
29 public:
30  DCMolecularField(const std::string &name, DCClass *dclass);
31 
32 PUBLISHED:
34  virtual const DCMolecularField *as_molecular_field() const;
35 
36  int get_num_atomics() const;
37  DCAtomicField *get_atomic(int n) const;
38 
39 public:
40  void add_atomic(DCAtomicField *atomic);
41 
42  virtual void output(std::ostream &out, bool brief) const;
43  virtual void write(std::ostream &out, bool brief, int indent_level) const;
44  virtual void generate_hash(HashGenerator &hashgen) const;
45 
46  virtual DCPackerInterface *get_nested_field(int n) const;
47 
48 protected:
49  virtual bool do_check_match(const DCPackerInterface *other) const;
50  virtual bool do_check_match_molecular_field(const DCMolecularField *other) const;
51 
52 private:
53  // These members define the primary interface to the molecular field
54  // definition as read from the file.
55  typedef pvector<DCAtomicField *> Fields;
56  Fields _fields;
57  bool _got_keywords;
58 
59  DCParameter *get_next_pack_element();
60 
61  typedef pvector<DCPackerInterface *> NestedFields;
62  NestedFields _nested_fields;
63 };
64 
65 #endif
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:37
Defines a particular DistributedClass as read from an input .dc file.
Definition: dcClass.h:44
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition: dcField.I:141
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single atomic field of a Distributed Class, as read from a .dc file.
Definition: dcAtomicField.h:30
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:130
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
Definition: dcField.cxx:467
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
Represents the type specification for a single parameter within a field specification.
Definition: dcParameter.h:35
void write(std::ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition: dcField.I:149
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:24
virtual bool do_check_match_molecular_field(const DCMolecularField *other) const
Returns true if this field matches the indicated molecular field, false otherwise.
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.