Panda3D
dcParameter.h
1 // Filename: dcParameter.h
2 // Created by: drose (15Jun04)
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 DCPARAMETER_H
16 #define DCPARAMETER_H
17 
18 #include "dcbase.h"
19 #include "dcField.h"
20 #include "dcNumericRange.h"
21 
22 class DCSimpleParameter;
23 class DCClassParameter;
24 class DCArrayParameter;
25 class DCTypedef;
26 class HashGenerator;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : DCParameter
30 // Description : Represents the type specification for a single
31 // parameter within a field specification. This may be
32 // a simple type, or it may be a class or an array
33 // reference.
34 //
35 // This may also be a typedef reference to another type,
36 // which has the same properties as the referenced type,
37 // but a different name.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_DIRECT DCParameter : public DCField {
40 protected:
41  DCParameter();
42  DCParameter(const DCParameter &copy);
43 public:
44  virtual ~DCParameter();
45 
46 PUBLISHED:
47  virtual DCParameter *as_parameter();
48  virtual const DCParameter *as_parameter() const;
49  virtual DCSimpleParameter *as_simple_parameter();
50  virtual const DCSimpleParameter *as_simple_parameter() const;
51  virtual DCClassParameter *as_class_parameter();
52  virtual const DCClassParameter *as_class_parameter() const;
53  virtual DCSwitchParameter *as_switch_parameter();
54  virtual const DCSwitchParameter *as_switch_parameter() const;
55  virtual DCArrayParameter *as_array_parameter();
56  virtual const DCArrayParameter *as_array_parameter() const;
57 
58  virtual DCParameter *make_copy() const=0;
59  virtual bool is_valid() const=0;
60 
61  const DCTypedef *get_typedef() const;
62 
63 public:
64  void set_typedef(const DCTypedef *dtypedef);
65  virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size);
66 
67  virtual void output(ostream &out, bool brief) const;
68  virtual void write(ostream &out, bool brief, int indent_level) const;
69  virtual void output_instance(ostream &out, bool brief, const string &prename,
70  const string &name, const string &postname) const=0;
71  virtual void write_instance(ostream &out, bool brief, int indent_level,
72  const string &prename, const string &name,
73  const string &postname) const;
74  void output_typedef_name(ostream &out, bool brief, const string &prename,
75  const string &name, const string &postname) const;
76  void write_typedef_name(ostream &out, bool brief, int indent_level,
77  const string &prename, const string &name,
78  const string &postname) const;
79  virtual void generate_hash(HashGenerator &hashgen) const;
80 
81 private:
82  const DCTypedef *_typedef;
83 };
84 
85 #endif
This represents a single typedef declaration in the dc file.
Definition: dcTypedef.h:29
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:40
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...
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
Definition: dcField.cxx:528
Represents the type specification for a single parameter within a field specification.
Definition: dcParameter.h:39
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
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
void write(ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition: dcField.I:198