Panda3D
Loading...
Searching...
No Matches
dcAtomicField.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 dcAtomicField.h
10 * @author drose
11 * @date 2000-10-05
12 */
13
14#ifndef DCATOMICFIELD_H
15#define DCATOMICFIELD_H
16
17#include "dcbase.h"
18#include "dcField.h"
19#include "dcSubatomicType.h"
20#include "dcParameter.h"
21
22// Must use math.h instead of cmath.h so this can compile outside of Panda.
23#include <math.h>
24
25/**
26 * A single atomic field of a Distributed Class, as read from a .dc file.
27 * This defines an interface to the Distributed Class, and is always
28 * implemented as a remote procedure method.
29 */
30class EXPCL_DIRECT_DCPARSER DCAtomicField : public DCField {
31public:
32 DCAtomicField(const std::string &name, DCClass *dclass, bool bogus_field);
33 virtual ~DCAtomicField();
34
35PUBLISHED:
36 virtual DCAtomicField *as_atomic_field();
37 virtual const DCAtomicField *as_atomic_field() const;
38
39 int get_num_elements() const;
40 DCParameter *get_element(int n) const;
41
42 // These five methods are deprecated and will be removed soon.
43 vector_uchar get_element_default(int n) const;
44 bool has_element_default(int n) const;
45 std::string get_element_name(int n) const;
47 int get_element_divisor(int n) const;
48
49public:
50 void add_element(DCParameter *element);
51
52 virtual void output(std::ostream &out, bool brief) const;
53 virtual void write(std::ostream &out, bool brief, int indent_level) const;
54 virtual void generate_hash(HashGenerator &hashgen) const;
55
56 virtual DCPackerInterface *get_nested_field(int n) const;
57
58protected:
59 virtual bool do_check_match(const DCPackerInterface *other) const;
60 virtual bool do_check_match_atomic_field(const DCAtomicField *other) const;
61
62private:
63 void output_element(std::ostream &out, bool brief, DCParameter *element) const;
64
65 typedef pvector<DCParameter *> Elements;
66 Elements _elements;
67};
68
69#include "dcAtomicField.I"
70
71#endif
bool has_element_default(int n) const
Returns true if the nth element of the field has a default value specified, false otherwise.
int get_element_divisor(int n) const
Returns the divisor associated with the nth element of the field.
void add_element(DCParameter *element)
Adds a new element (parameter) to the field.
int get_num_elements() const
Returns the number of elements (parameters) of the atomic field.
std::string get_element_name(int n) const
Returns the name of the nth element of the field.
DCSubatomicType get_element_type(int n) const
Returns the numeric type of the nth element of the field.
DCParameter * get_element(int n) const
Returns the parameter object describing the nth element.
std::vector< unsigned char > get_element_default(int n) const
Returns the pre-formatted default value associated with the nth element of the field.
Defines a particular DistributedClass as read from an input .dc file.
Definition dcClass.h:44
void write(std::ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition dcField.I:149
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
Definition dcField.cxx:467
virtual DCAtomicField * as_atomic_field()
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic fie...
Definition dcField.cxx:112
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition dcField.I:141
virtual bool do_check_match_atomic_field(const DCAtomicField *other) const
Returns true if this field matches the indicated atomic field, false otherwise.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DCSubatomicType
This defines the numeric type of each element of a DCAtomicField; that is, the particular values that...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.