Panda3D
dcAtomicField.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 dcAtomicField.h
10  * @author drose
11  * @date 2000-10-05
12  */
13 
14 #ifndef DCATOMICFIELD_H
15 #define DCATOMICFIELD_H
16 
17 #include "dcbase.h"
18 #include "dcField.h"
19 #include "dcSubatomicType.h"
20 #include "dcParameter.h"
21 
22 // Must use math.h instead of cmath.h so this can compile outside of Panda.
23 #include <math.h>
24 
25 /**
26  * A single atomic field of a Distributed Class, as read from a .dc file.
27  * This defines an interface to the Distributed Class, and is always
28  * implemented as a remote procedure method.
29  */
30 class EXPCL_DIRECT_DCPARSER DCAtomicField : public DCField {
31 public:
32  DCAtomicField(const std::string &name, DCClass *dclass, bool bogus_field);
33  virtual ~DCAtomicField();
34 
35 PUBLISHED:
36  virtual DCAtomicField *as_atomic_field();
37  virtual const DCAtomicField *as_atomic_field() const;
38 
39  int get_num_elements() const;
40  DCParameter *get_element(int n) const;
41 
42  // These five methods are deprecated and will be removed soon.
43  vector_uchar get_element_default(int n) const;
44  bool has_element_default(int n) const;
45  std::string get_element_name(int n) const;
46  DCSubatomicType get_element_type(int n) const;
47  int get_element_divisor(int n) const;
48 
49 public:
50  void add_element(DCParameter *element);
51 
52  virtual void output(std::ostream &out, bool brief) const;
53  virtual void write(std::ostream &out, bool brief, int indent_level) const;
54  virtual void generate_hash(HashGenerator &hashgen) const;
55 
56  virtual DCPackerInterface *get_nested_field(int n) const;
57 
58 protected:
59  virtual bool do_check_match(const DCPackerInterface *other) const;
60  virtual bool do_check_match_atomic_field(const DCAtomicField *other) const;
61 
62 private:
63  void output_element(std::ostream &out, bool brief, DCParameter *element) const;
64 
65  typedef pvector<DCParameter *> Elements;
66  Elements _elements;
67 };
68 
69 #include "dcAtomicField.I"
70 
71 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DCSubatomicType
This defines the numeric type of each element of a DCAtomicField; that is, the particular values that...
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:37
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:112
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 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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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_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.