Panda3D

Loading...
Searching...
No Matches
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
42PUBLISHED:
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
DCArrayParameter
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
Definition dcArrayParameter.h:26
DCClassParameter
This represents a class (or struct) object used as a parameter itself.
Definition dcClassParameter.h:26
DCField::write
void write(std::ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition dcField.I:149
DCField::generate_hash
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
Definition dcField.cxx:467
DCField::output
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition dcField.I:141
DCParameter::write_instance
virtual void write_instance(std::ostream &out, bool brief, int indent_level, const std::string &prename, const std::string &name, const std::string &postname) const
Formats the parameter in the C++-like dc syntax as a typename and identifier.
Definition dcParameter.cxx:187
DCParameter::write_typedef_name
void write_typedef_name(std::ostream &out, bool brief, int indent_level, const std::string &prename, const std::string &name, const std::string &postname) const
Formats the instance like write_instance, but uses the typedef name instead.
Definition dcParameter.cxx:218
DCParameter::get_typedef
const DCTypedef * get_typedef() const
If this type has been referenced from a typedef, returns the DCTypedef instance, or NULL if the type ...
Definition dcParameter.cxx:136
DCParameter::output_typedef_name
void output_typedef_name(std::ostream &out, bool brief, const std::string &prename, const std::string &name, const std::string &postname) const
Formats the instance like output_instance, but uses the typedef name instead.
Definition dcParameter.cxx:205
DCParameter::append_array_specification
virtual DCParameter * append_array_specification(const DCUnsignedIntRange &size)
Returns the type represented by this_type[size].
Definition dcParameter.cxx:156
DCParameter::set_typedef
void set_typedef(const DCTypedef *dtypedef)
Records the DCTypedef object that generated this parameter.
Definition dcParameter.cxx:145
DCSimpleParameter
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomi...
Definition dcSimpleParameter.h:28
DCSwitchParameter
This represents a switch object used as a parameter itself, which packs the appropriate fields of the...
Definition dcSwitchParameter.h:26
DCTypedef
This represents a single typedef declaration in the dc file.
Definition dcTypedef.h:26
HashGenerator
This class generates an arbitrary hash number from a sequence of ints.
Definition hashGenerator.h:23
dcField.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dcNumericRange.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dcbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.