Panda3D
|
00001 // Filename: dcKeyword.cxx 00002 // Created by: drose (22Jul05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "dcKeyword.h" 00016 #include "hashGenerator.h" 00017 #include "dcindent.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: DCKeyword::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 DCKeyword:: 00025 DCKeyword(const string &name, int historical_flag) : 00026 _name(name), 00027 _historical_flag(historical_flag) 00028 { 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: DCKeyword::Destructor 00033 // Access: Public, Virtual 00034 // Description: 00035 //////////////////////////////////////////////////////////////////// 00036 DCKeyword:: 00037 ~DCKeyword() { 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: DCKeyword::get_name 00042 // Access: Published 00043 // Description: Returns the name of this keyword. 00044 //////////////////////////////////////////////////////////////////// 00045 const string &DCKeyword:: 00046 get_name() const { 00047 return _name; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: DCKeyword::get_historical_flag 00052 // Access: Public 00053 // Description: Returns the bitmask associated with this keyword, if 00054 // any. This is the value that was historically 00055 // associated with this keyword, and was used to 00056 // generate a hash code before we had user-customizable 00057 // keywords. It will return ~0 if this is not an 00058 // historical keyword. 00059 //////////////////////////////////////////////////////////////////// 00060 int DCKeyword:: 00061 get_historical_flag() const { 00062 return _historical_flag; 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: DCKeyword::clear_historical_flag 00067 // Access: Public 00068 // Description: Resets the historical flag to ~0, as if the keyword 00069 // were not one of the historically defined keywords. 00070 //////////////////////////////////////////////////////////////////// 00071 void DCKeyword:: 00072 clear_historical_flag() { 00073 _historical_flag = ~0; 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function : DCKeyword::output 00078 // Access : Public, Virtual 00079 // Description : Write a string representation of this instance to 00080 // <out>. 00081 //////////////////////////////////////////////////////////////////// 00082 void DCKeyword:: 00083 output(ostream &out, bool brief) const { 00084 out << "keyword " << _name; 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: DCKeyword::write 00089 // Access: Public, Virtual 00090 // Description: 00091 //////////////////////////////////////////////////////////////////// 00092 void DCKeyword:: 00093 write(ostream &out, bool, int indent_level) const { 00094 indent(out, indent_level) 00095 << "keyword " << _name << ";\n"; 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: DCKeyword::generate_hash 00100 // Access: Public 00101 // Description: Accumulates the properties of this keyword into the 00102 // hash. 00103 //////////////////////////////////////////////////////////////////// 00104 void DCKeyword:: 00105 generate_hash(HashGenerator &hashgen) const { 00106 hashgen.add_string(_name); 00107 }