39 ~EggNameUniquifier() {
56 string category = get_category(node);
57 if (egg_cat.is_debug()) {
59 <<
"Uniquifying " << node->get_name() <<
", category = " << category
63 if (!category.empty()) {
67 bool inserted =
false;
69 inserted = names.insert(UsedNames::value_type(name, node)).second;
75 inserted = names.insert(UsedNames::value_type(name, node)).second;
78 if (egg_cat.is_debug()) {
80 <<
"Uniquifying " << node->get_name() <<
" to "
87 if (node->
is_of_type(EggGroupNode::get_class_type())) {
89 DCAST_INTO_V(group, node);
91 EggGroupNode::iterator ci;
92 for (ci = group->begin(); ci != group->end(); ++ci) {
94 nassertv(child !=
nullptr);
105 get_node(
const string &category,
const string &name)
const {
106 Categories::const_iterator ci;
107 ci = _categories.find(category);
108 if (ci == _categories.end()) {
113 UsedNames::const_iterator ni;
114 ni = names.find(name);
115 if (ni == names.end()) {
127 has_name(
const string &category,
const string &name)
const {
128 Categories::const_iterator ci;
129 ci = _categories.find(category);
130 if (ci == _categories.end()) {
135 UsedNames::const_iterator ni;
136 ni = names.find(name);
137 if (ni == names.end()) {
151 UsedNames &names = _categories[category];
152 bool inserted = names.insert(UsedNames::value_type(name, node)).second;
163 return node->get_name();
178 std::ostringstream str;
180 str << category << index;
182 str << name <<
"." << category << index;
A base class for nodes in the hierarchy that are not leaf nodes.
bool add_name(const std::string &category, const std::string &name, EggNode *node=nullptr)
Adds the name to the indicated category.
virtual std::string filter_name(EggNode *node)
Returns the name of the given node, or at least the name it should be.
EggNode * get_node(const std::string &category, const std::string &name) const
Returns the node associated with the given category and name, or NULL if the name has not been used.
virtual std::string generate_name(EggNode *node, const std::string &category, int index)
Generates a new name for the given node when its existing name clashes with some other node.
void clear()
Empties the table of used named and prepares the Uniquifier for a new tree.
void uniquify(EggNode *node)
Begins the traversal from the indicated node.
bool has_name(const std::string &category, const std::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.
TypeHandle is the identifier used to differentiate C++ class types.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This is our own Panda specialization on the default STL map.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.