NameTab Class Reference

NameTab Class Reference

#include <nametab.h>

Class 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.
+ Inheritance diagram for NameTab:

Public Member Functions

 NameTab ()
 Constructor. More...
 
UtilExport ~NameTab ()
 Destructor. More...
 
UtilExport void ZeroCount ()
 removes the items in the Tab by un-allocating memory. More...
 
UtilExport NameTaboperator= (const NameTab &n)
 Assignment operator. More...
 
void SetFlag (ULONG f, BOOL b=1)
 Sets the specified flag to the specified value. More...
 
BOOL TestFlag (ULONG f)
 Checks if a flag is set or not. More...
 
UtilExport int AddName (const MCHAR *n)
 Appends a copy of the specified name to the end of the list. More...
 
UtilExport void SetName (int i, const MCHAR *n)
 Sets a name in the list. More...
 
UtilExport void SetSize (int num)
 Sets the size of the list. More...
 
UtilExport void RemoveName (int i)
 Removes the 'i-th' name from the list. More...
 
UtilExport int FindName (const MCHAR *n)
 Finds the index of the name passed in. More...
 
UtilExport IOResult Load (ILoad *iload)
 Loads this NameTab from disk. More...
 
UtilExport IOResult Save (ISave *isave)
 Saves this NameTab to disk. More...
 
- Public Member Functions inherited from Tab< const MCHAR * >
 Tab ()
 Default constructor. More...
 
 Tab (const Tab &tb)
 Copy constructor. More...
 
 ~Tab ()
 Destructor. More...
 
void Init ()
 Initializes a Tab instance. More...
 
int Count () const
 Retrieves the number of items in the Tab. More...
 
void ZeroCount ()
 Resets the number of used items to zero. More...
 
void SetCount (int n, BOOL resize=TRUE)
 Sets the number of used items. More...
 
const MCHAR * * Addr (const INT_PTR i) const
 Returns the address of the i-th item. More...
 
int Insert (int at, int num, const MCHAR * *el)
 Inserts items in the Tab at a specified position. More...
 
int Append (int num, const MCHAR * *el, int allocExtra=0)
 Appends items at the end of the Tab. More...
 
int Delete (int start, int num)
 Deletes items from the Tab. More...
 
int Resize (int num)
 Changes the number of items allocated in memory. More...
 
void Shrink ()
 Frees unused Tab items to reduce memory footprint. More...
 
void Sort (CompareFnc cmp)
 Sorts the array using the compare function. More...
 
Taboperator= (const Tab &tb)
 Assignment operator. More...
 
const MCHAR * & operator[] (const INT_PTR i) const
 Accesses the i-th Tab item. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

NameTab ( )
inline

Constructor.

The 'include' flag is set to FALSE.

#define NT_AFFECT_SHADOWCAST
Definition: ExcludeListConstants.h:13
#define NT_AFFECT_ILLUM
Definition: ExcludeListConstants.h:12

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)

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
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.
b- The value to set.
54 { if (b) flags|=f; else flags &= ~f; }
BOOL TestFlag ( ULONG  f)
inline

Checks if a flag is set or not.

Parameters
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.
63 { 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
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
i- The position in the list for the name.
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
num- Specifies the size of the list.
UtilExport void RemoveName ( int  i)

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

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

Finds the index of the name passed in.

Parameters
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- Provides methods to load data from disk.
See also
I/O Results.
UtilExport IOResult Save ( ISave isave)

Saves this NameTab to disk.

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