Panda3D
dcParameter.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 dcParameter.h
10  * @author drose
11  * @date 2004-06-15
12  */
13 
14 #ifndef DCPARAMETER_H
15 #define DCPARAMETER_H
16 
17 #include "dcbase.h"
18 #include "dcField.h"
19 #include "dcNumericRange.h"
20 
21 class DCSimpleParameter;
22 class DCClassParameter;
23 class DCArrayParameter;
24 class DCTypedef;
25 class HashGenerator;
26 
27 /**
28  * Represents the type specification for a single parameter within a field
29  * specification. This may be a simple type, or it may be a class or an array
30  * reference.
31  *
32  * This may also be a typedef reference to another type, which has the same
33  * properties as the referenced type, but a different name.
34  */
35 class EXPCL_DIRECT_DCPARSER DCParameter : public DCField {
36 protected:
37  DCParameter();
38  DCParameter(const DCParameter &copy);
39 public:
40  virtual ~DCParameter();
41 
42 PUBLISHED:
43  virtual DCParameter *as_parameter();
44  virtual const DCParameter *as_parameter() const;
45  virtual DCSimpleParameter *as_simple_parameter();
46  virtual const DCSimpleParameter *as_simple_parameter() const;
47  virtual DCClassParameter *as_class_parameter();
48  virtual const DCClassParameter *as_class_parameter() const;
49  virtual DCSwitchParameter *as_switch_parameter();
50  virtual const DCSwitchParameter *as_switch_parameter() const;
51  virtual DCArrayParameter *as_array_parameter();
52  virtual const DCArrayParameter *as_array_parameter() const;
53 
54  virtual DCParameter *make_copy() const=0;
55  virtual bool is_valid() const=0;
56 
57  const DCTypedef *get_typedef() const;
58 
59 public:
60  void set_typedef(const DCTypedef *dtypedef);
61  virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size);
62 
63  virtual void output(std::ostream &out, bool brief) const;
64  virtual void write(std::ostream &out, bool brief, int indent_level) const;
65  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
66  const std::string &name, const std::string &postname) const=0;
67  virtual void write_instance(std::ostream &out, bool brief, int indent_level,
68  const std::string &prename, const std::string &name,
69  const std::string &postname) const;
70  void output_typedef_name(std::ostream &out, bool brief, const std::string &prename,
71  const std::string &name, const std::string &postname) const;
72  void write_typedef_name(std::ostream &out, bool brief, int indent_level,
73  const std::string &prename, const std::string &name,
74  const std::string &postname) const;
75  virtual void generate_hash(HashGenerator &hashgen) const;
76 
77 private:
78  const DCTypedef *_typedef;
79 };
80 
81 #endif
This represents a single typedef declaration in the dc file.
Definition: dcTypedef.h:26
This represents a class (or struct) object used as a parameter itself.
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:37
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomi...
This represents a switch object used as a parameter itself, which packs the appropriate fields of the...
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition: dcField.I:141
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
Represents the type specification for a single parameter within a field specification.
Definition: dcParameter.h:35
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.