Panda3D
dcKeyword.cxx
1 // Filename: dcKeyword.cxx
2 // Created by: drose (22Jul05)
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 #include "dcKeyword.h"
16 #include "hashGenerator.h"
17 #include "dcindent.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: DCKeyword::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 DCKeyword::
25 DCKeyword(const string &name, int historical_flag) :
26  _name(name),
27  _historical_flag(historical_flag)
28 {
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: DCKeyword::Destructor
33 // Access: Public, Virtual
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 DCKeyword::
37 ~DCKeyword() {
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: DCKeyword::get_name
42 // Access: Published
43 // Description: Returns the name of this keyword.
44 ////////////////////////////////////////////////////////////////////
45 const string &DCKeyword::
46 get_name() const {
47  return _name;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: DCKeyword::get_historical_flag
52 // Access: Public
53 // Description: Returns the bitmask associated with this keyword, if
54 // any. This is the value that was historically
55 // associated with this keyword, and was used to
56 // generate a hash code before we had user-customizable
57 // keywords. It will return ~0 if this is not an
58 // historical keyword.
59 ////////////////////////////////////////////////////////////////////
60 int DCKeyword::
62  return _historical_flag;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: DCKeyword::clear_historical_flag
67 // Access: Public
68 // Description: Resets the historical flag to ~0, as if the keyword
69 // were not one of the historically defined keywords.
70 ////////////////////////////////////////////////////////////////////
71 void DCKeyword::
73  _historical_flag = ~0;
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function : DCKeyword::output
78 // Access : Public, Virtual
79 // Description : Write a string representation of this instance to
80 // <out>.
81 ////////////////////////////////////////////////////////////////////
82 void DCKeyword::
83 output(ostream &out, bool brief) const {
84  out << "keyword " << _name;
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: DCKeyword::write
89 // Access: Public, Virtual
90 // Description:
91 ////////////////////////////////////////////////////////////////////
92 void DCKeyword::
93 write(ostream &out, bool, int indent_level) const {
94  indent(out, indent_level)
95  << "keyword " << _name << ";\n";
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: DCKeyword::generate_hash
100 // Access: Public
101 // Description: Accumulates the properties of this keyword into the
102 // hash.
103 ////////////////////////////////////////////////////////////////////
104 void DCKeyword::
105 generate_hash(HashGenerator &hashgen) const {
106  hashgen.add_string(_name);
107 }
void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this keyword into the hash.
Definition: dcKeyword.cxx:105
void add_string(const string &str)
Adds a string to the hash, by breaking it down into a sequence of integers.
virtual void output(ostream &out, bool brief) const
Write a string representation of this instance to <out>.
Definition: dcKeyword.cxx:83
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:26
void clear_historical_flag()
Resets the historical flag to ~0, as if the keyword were not one of the historically defined keywords...
Definition: dcKeyword.cxx:72
const string & get_name() const
Returns the name of this keyword.
Definition: dcKeyword.cxx:46
int get_historical_flag() const
Returns the bitmask associated with this keyword, if any.
Definition: dcKeyword.cxx:61