Public Member Functions

NameTab Class Reference

Search for all occurrences

Detailed Description

This class is used to store a table of names.

See also:
Class Tab.
For example, this class is used by lights for their "Inclusion" and "Exclusion" lists.
This class maintains an 'include' flag that specifies whether the list of names is things to be included, or things to be excluded. There is no reason the NameTab class can't be used for other things where inclusion/exclusion is not relevant: in that case one can just ignore the 'include' flag. All methods are implemented by the system.

#include <nametab.h>

Inheritance diagram for NameTab:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  NameTab ()
  Constructor.
UtilExport  ~NameTab ()
  Destructor.
UtilExport void  ZeroCount ()
  removes the items in the Tab by un-allocating memory.
UtilExport NameTab operator= (const NameTab &n)
  Assignment operator.
void  SetFlag (ULONG f, BOOL b=1)
  Sets the specified flag to the specified value.
BOOL  TestFlag (ULONG f)
  Checks if a flag is set or not.
UtilExport int  AddName (const MCHAR *n)
  Appends a copy of the specified name to the end of the list.
UtilExport void  SetName (int i, const MCHAR *n)
  Sets a name in the list.
UtilExport void  SetSize (int num)
  Sets the size of the list.
UtilExport void  RemoveName (int i)
  Removes the 'i-th' name from the list.
UtilExport int  FindName (const MCHAR *n)
  Finds the index of the name passed in.
UtilExport IOResult  Load (ILoad *iload)
  Loads this NameTab from disk.
UtilExport IOResult  Save (ISave *isave)
  Saves this NameTab to disk.

Constructor & Destructor Documentation

NameTab ( ) [inline]

Constructor.

The 'include' flag is set to FALSE.

{ flags = NT_AFFECT_ILLUM|NT_AFFECT_SHADOWCAST; }
UtilExport ~NameTab ( )

Destructor.


Member Function Documentation

UtilExport void ZeroCount ( )

removes the items in the Tab by un-allocating memory.

Overrides the base class method. The Tab implementation of ZeroCount only sents the count value to zero and does not free any memory. This behavior basically guarantees a memory leak, especially with strings. To many developers have assumed that NameTab free's it's strings, by using this method, thus it's implementation is getting overridden in this class and altered. This method simply calls SetSize(0)

Reimplemented from Tab< MCHAR * >.

UtilExport NameTab& operator= ( const NameTab n )

Assignment operator.

void SetFlag ( ULONG  f,
BOOL  b = 1 
) [inline]

Sets the specified flag to the specified value.

Parameters:
ULONG f - The flag(s) to set. One or more of the following values:
  • NT_INCLUDE - This bit is used to indicate "Include" mode.
  • NT_AFFECT_ILLUM - This bit is used to indicate the "Illumination" check box in the exclusion list dialog.
  • NT_AFFECT_SHADOWCAST - This bit is used to indicate the "Shadow Casting" check box in the exclusion list dialog.
BOOL b=1 - The value to set.
{ if (b) flags|=f; else flags &= ~f; }
BOOL TestFlag ( ULONG  f ) [inline]

Checks if a flag is set or not.

Parameters:
ULONG f - The flag(s) to set. One or more of the following values:
  • NT_INCLUDE - This bit is used to indicate "Include" mode.
  • NT_AFFECT_ILLUM - This bit is used to indicate the "Illumination" check box in the exclusion list dialog.
  • NT_AFFECT_SHADOWCAST - This bit is used to indicate the "Shadow Casting" check box in the exclusion list dialog.
Returns:
- Returns TRUE if the specified flag(s) are set; otherwise FALSE.
{ return (flags&f)?1:0; }
UtilExport int AddName ( const MCHAR *  n )

Appends a copy of the specified name to the end of the list.

Parameters:
MCHAR* n - The name to add.
Returns:
- Returns the number of items in the list prior to appending.
UtilExport void SetName ( int  i,
const MCHAR *  n 
)

Sets a name in the list.

Stores the specified name at the specified position in the list.

Parameters:
int i - The position in the list for the name.
MCHAR *n - The name to store. If the name is NULL, the 'i-th' entry is set to NULL.
UtilExport void SetSize ( int  num )

Sets the size of the list.

If the new size is smaller than the current size, the entries are deleted.

Parameters:
int num - Specifies the size of the list.
UtilExport void RemoveName ( int  i )

Removes the 'i-th' name from the list.

Parameters:
int i - Specifies the index of the name to remove.
UtilExport int FindName ( const MCHAR *  n )

Finds the index of the name passed in.

Parameters:
MCHAR* n - The name to find.
Returns:
- Returns the index of the name passed; otherwise returns -1.
UtilExport IOResult Load ( ILoad iload )

Loads this NameTab from disk.

Parameters:
ILoad *iload - Provides methods to load data from disk.
See also:
I/O Results.
UtilExport IOResult Save ( ISave isave )

Saves this NameTab to disk.

Parameters:
ISave *isave - Provides methods to save data to disk.
See also:
I/O Results.

NameTab NameTab NameTab NameTab NameTab NameTab NameTab NameTab NameTab NameTab
NameTab NameTab NameTab NameTab NameTab NameTab NameTab NameTab NameTab NameTab