Panda3D
 All Classes Functions Variables Enumerations
dcSwitchParameter.h
1 // Filename: dcClassParameter.h
2 // Created by: drose (29Jun04)
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 DCSWITCHPARAMETER_H
16 #define DCSWITCHPARAMETER_H
17 
18 #include "dcbase.h"
19 #include "dcParameter.h"
20 
21 class DCSwitch;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : DCSwitchParameter
25 // Description : This represents a switch object used as a
26 // parameter itself, which packs the appropriate fields
27 // of the switch into the message.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_DIRECT DCSwitchParameter : public DCParameter {
30 public:
31  DCSwitchParameter(const DCSwitch *dswitch);
33 
34 PUBLISHED:
35  virtual DCSwitchParameter *as_switch_parameter();
36  virtual const DCSwitchParameter *as_switch_parameter() const;
37  virtual DCParameter *make_copy() const;
38  virtual bool is_valid() const;
39 
40  const DCSwitch *get_switch() const;
41 
42 public:
43  virtual DCPackerInterface *get_nested_field(int n) const;
44 
45  const DCPackerInterface *apply_switch(const char *value_data, size_t length) const;
46 
47  virtual void output_instance(ostream &out, bool brief, const string &prename,
48  const string &name, const string &postname) const;
49  virtual void write_instance(ostream &out, bool brief, int indent_level,
50  const string &prename, const string &name,
51  const string &postname) const;
52  virtual void generate_hash(HashGenerator &hashgen) const;
53  virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
54 
55 protected:
56  virtual bool do_check_match(const DCPackerInterface *other) const;
57  virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const;
58 
59 private:
60  const DCSwitch *_dswitch;
61 };
62 
63 #endif
This is a block of data that receives the results of DCPacker.
Definition: dcPackData.h:25
virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const
Packs the field's specified default value (or a sensible default if no value is specified) into the s...
Definition: dcField.cxx:548
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
virtual void write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const
Formats the parameter in the C++-like dc syntax as a typename and identifier.
virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
This represents a switch statement, which can appear inside a class body and represents two or more a...
Definition: dcSwitch.h:33
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 type into the hash.
Represents the type specification for a single parameter within a field specification.
Definition: dcParameter.h:39
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:26
This defines the internal interface for packing values into a DCField.