Panda3D
Loading...
Searching...
No Matches
dcKeyword.cxx
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 dcKeyword.cxx
10 * @author drose
11 * @date 2005-07-22
12 */
13
14#include "dcKeyword.h"
15#include "hashGenerator.h"
16#include "dcindent.h"
17
18/**
19 *
20 */
21DCKeyword::
22DCKeyword(const std::string &name, int historical_flag) :
23 _name(name),
24 _historical_flag(historical_flag)
25{
26}
27
28/**
29 *
30 */
31DCKeyword::
32~DCKeyword() {
33}
34
35/**
36 * Returns the name of this keyword.
37 */
38const std::string &DCKeyword::
39get_name() const {
40 return _name;
41}
42
43/**
44 * Returns the bitmask associated with this keyword, if any. This is the
45 * value that was historically associated with this keyword, and was used to
46 * generate a hash code before we had user-customizable keywords. It will
47 * return ~0 if this is not an historical keyword.
48 */
50get_historical_flag() const {
51 return _historical_flag;
52}
53
54/**
55 * Resets the historical flag to ~0, as if the keyword were not one of the
56 * historically defined keywords.
57 */
60 _historical_flag = ~0;
61}
62
63/**
64 * Write a string representation of this instance to <out>.
65 */
67output(std::ostream &out, bool brief) const {
68 out << "keyword " << _name;
69}
70
71/**
72 *
73 */
74void DCKeyword::
75write(std::ostream &out, bool, int indent_level) const {
76 indent(out, indent_level)
77 << "keyword " << _name << ";\n";
78}
79
80/**
81 * Accumulates the properties of this keyword into the hash.
82 */
84generate_hash(HashGenerator &hashgen) const {
85 hashgen.add_string(_name);
86}
void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this keyword into the hash.
Definition dcKeyword.cxx:84
virtual void output(std::ostream &out, bool brief) const
Write a string representation of this instance to <out>.
Definition dcKeyword.cxx:67
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:59
const std::string & get_name() const
Returns the name of this keyword.
Definition dcKeyword.cxx:39
int get_historical_flag() const
Returns the bitmask associated with this keyword, if any.
Definition dcKeyword.cxx:50
This class generates an arbitrary hash number from a sequence of ints.
void add_string(const std::string &str)
Adds a string to the hash, by breaking it down into a sequence of integers.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20