Panda3D
Public Member Functions | Static Public Member Functions

EggNameUniquifier Class Reference

This is a handy class for guaranteeing unique node names in an egg hierarchy. More...

#include "eggNameUniquifier.h"

Inheritance diagram for EggNameUniquifier:
EggObject TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase EggGroupUniquifier EggPoolUniquifier

List of all members.

Public Member Functions

bool add_name (const string &category, const string &name, EggNode *node=NULL)
 Adds the name to the indicated category.
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.
virtual TypeHandle force_init_type ()
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.
virtual string get_category (EggNode *node)=0
EggNodeget_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.
virtual TypeHandle get_type () const
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.
void uniquify (EggNode *node)
 Begins the traversal from the indicated node.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.

Detailed Description

This is a handy class for guaranteeing unique node names in an egg hierarchy.

It is an abstract class; to use it you must subclass off of it. See the comment above.

Definition at line 88 of file eggNameUniquifier.h.


Member Function Documentation

bool EggNameUniquifier::add_name ( const string &  category,
const string &  name,
EggNode node = NULL 
)

Adds the name to the indicated category.

This name will not be used for any other egg node within this category. Returns true if the name was added, or false if it was already in use for the category.

Definition at line 165 of file eggNameUniquifier.cxx.

void EggNameUniquifier::clear ( )

Empties the table of used named and prepares the Uniquifier for a new tree.

Definition at line 52 of file eggNameUniquifier.cxx.

string EggNameUniquifier::filter_name ( EggNode node) [virtual]

Returns the name of the given node, or at least the name it should be.

This provides a hook to adjust the name before attempting to uniquify it, if desired, for instance to remove invalid characters.

Reimplemented in EggGroupUniquifier.

Definition at line 180 of file eggNameUniquifier.cxx.

Referenced by generate_name(), and uniquify().

string EggNameUniquifier::generate_name ( EggNode node,
const string &  category,
int  index 
) [virtual]

Generates a new name for the given node when its existing name clashes with some other node.

This function will be called repeatedly, if necessary, until it returns a name that actually is unique.

The category is the string returned by get_category(), and index is a uniquely-generated number that may be useful for synthesizing the name.

Reimplemented in EggGroupUniquifier.

Definition at line 197 of file eggNameUniquifier.cxx.

References filter_name().

Referenced by uniquify().

EggNode * EggNameUniquifier::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.

Definition at line 115 of file eggNameUniquifier.cxx.

bool EggNameUniquifier::has_name ( const string &  category,
const string &  name 
) const

Returns true if the name has been used for the indicated category already, false otherwise.

Definition at line 139 of file eggNameUniquifier.cxx.

static void EggNameUniquifier::init_type ( ) [inline, static]

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from EggObject.

Reimplemented in EggGroupUniquifier, and EggPoolUniquifier.

Definition at line 119 of file eggNameUniquifier.h.

References EggObject::init_type().

Referenced by EggPoolUniquifier::init_type(), and EggGroupUniquifier::init_type().

void EggNameUniquifier::uniquify ( EggNode node)

Begins the traversal from the indicated node.

Definition at line 63 of file eggNameUniquifier.cxx.

References filter_name(), generate_name(), and TypedObject::is_of_type().

Referenced by XFileToEggConverter::convert_file().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations