Panda3D
dcSwitchParameter.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 dcSwitchParameter.h
10  * @author drose
11  * @date 2004-06-29
12  */
13 
14 #ifndef DCSWITCHPARAMETER_H
15 #define DCSWITCHPARAMETER_H
16 
17 #include "dcbase.h"
18 #include "dcParameter.h"
19 
20 class DCSwitch;
21 
22 /**
23  * This represents a switch object used as a parameter itself, which packs the
24  * appropriate fields of the switch into the message.
25  */
26 class EXPCL_DIRECT_DCPARSER DCSwitchParameter : public DCParameter {
27 public:
28  DCSwitchParameter(const DCSwitch *dswitch);
30 
31 PUBLISHED:
32  virtual DCSwitchParameter *as_switch_parameter();
33  virtual const DCSwitchParameter *as_switch_parameter() const;
34  virtual DCParameter *make_copy() const;
35  virtual bool is_valid() const;
36 
37  const DCSwitch *get_switch() const;
38 
39 public:
40  virtual DCPackerInterface *get_nested_field(int n) const;
41 
42  const DCPackerInterface *apply_switch(const char *value_data, size_t length) const;
43 
44  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
45  const std::string &name, const std::string &postname) const;
46  virtual void write_instance(std::ostream &out, bool brief, int indent_level,
47  const std::string &prename, const std::string &name,
48  const std::string &postname) const;
49  virtual void generate_hash(HashGenerator &hashgen) const;
50  virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
51 
52 protected:
53  virtual bool do_check_match(const DCPackerInterface *other) const;
54  virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const;
55 
56 private:
57  const DCSwitch *_dswitch;
58 };
59 
60 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
This is a block of data that receives the results of DCPacker.
Definition: dcPackData.h:22
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:487
This represents a switch statement, which can appear inside a class body and represents two or more a...
Definition: dcSwitch.h:30
This represents a switch object used as a parameter itself, which packs the appropriate fields of the...
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
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.
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 class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:24
virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
This defines the internal interface for packing values into a DCField.