15 #include "eggNameUniquifier.h" 17 #include "eggGroupNode.h" 18 #include "config_egg.h" 42 ~EggNameUniquifier() {
64 string category = get_category(node);
65 if (egg_cat.is_debug()) {
67 <<
"Uniquifying " << node->get_name() <<
", category = " << category
71 if (!category.empty()) {
75 bool inserted =
false;
77 inserted = names.insert(UsedNames::value_type(name, node)).second;
83 inserted = names.insert(UsedNames::value_type(name, node)).second;
86 if (egg_cat.is_debug()) {
88 <<
"Uniquifying " << node->get_name() <<
" to " 95 if (node->
is_of_type(EggGroupNode::get_class_type())) {
97 DCAST_INTO_V(group, node);
99 EggGroupNode::iterator ci;
100 for (ci = group->begin(); ci != group->end(); ++ci) {
102 nassertv(child != (
EggNode *)NULL);
115 get_node(
const string &category,
const string &name)
const {
116 Categories::const_iterator ci;
117 ci = _categories.find(category);
118 if (ci == _categories.end()) {
123 UsedNames::const_iterator ni;
124 ni = names.find(name);
125 if (ni == names.end()) {
139 has_name(
const string &category,
const string &name)
const {
140 Categories::const_iterator ci;
141 ci = _categories.find(category);
142 if (ci == _categories.end()) {
147 UsedNames::const_iterator ni;
148 ni = names.find(name);
149 if (ni == names.end()) {
166 UsedNames &names = _categories[category];
167 bool inserted = names.insert(UsedNames::value_type(name, node)).second;
181 return node->get_name();
202 str << category << index;
204 str << name <<
"." << category << index;
This is our own Panda specialization on the default STL map.
A base class for nodes in the hierarchy that are not leaf nodes.
void clear()
Empties the table of used named and prepares the Uniquifier for a new tree.
virtual string filter_name(EggNode *node)
Returns the name of the given node, or at least the name it should be.
void uniquify(EggNode *node)
Begins the traversal from the indicated node.
virtual string generate_name(EggNode *node, const string &category, int index)
Generates a new name for the given node when its existing name clashes with some other node...
bool add_name(const string &category, const string &name, EggNode *node=NULL)
Adds the name to the indicated category.
EggNode * get_node(const string &category, const string &name) const
Returns the node associated with the given category and name, or NULL if the name has not been used...
bool has_name(const string &category, const string &name) const
Returns true if the name has been used for the indicated category already, false otherwise.
A base class for things that may be directly added into the egg hierarchy.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
TypeHandle is the identifier used to differentiate C++ class types.