IM: imAttribTable Class Reference

IM - An Imaging Tool

imAttribTable Class Reference
[Utilities]


Detailed Description

All the attributes have a name, a type, a count and the data.
Names are usually strings with less that 30 chars.
Attributes are stored in a hash table for fast access.
We use the hash function described in "The Pratice of Programming" of Kernighan & Pike.


Public Member Functions

 imAttribTable (int hash_size)
 ~imAttribTable ()
int Count () const
void RemoveAll ()
void CopyFrom (const imAttribTable &table)
void Set (const char *name, int data_type, int count, const void *data)
void UnSet (const char *name)
const void * Get (const char *name, int *data_type=0, int *count=0) const
void ForEach (void *user_data, imAttribTableCallback attrib_func) const

Constructor & Destructor Documentation

imAttribTable::imAttribTable int  hash_size  )  [inline]
 

Creates an empty table. If size is zero the default size of 101 is used. Size must be a prime number. Other common values are 67, 599 and 1499.

00031     { ptable = imAttribTableCreate(hash_size); }

imAttribTable::~imAttribTable  )  [inline]
 

Destroys the table and all the attributes.

00035     { imAttribTableDestroy(ptable); ptable = 0; }


Member Function Documentation

int imAttribTable::Count  )  const [inline]
 

Returns the number of elements in the table.

00039     { return imAttribTableCount(ptable); }

void imAttribTable::RemoveAll  )  [inline]
 

Removes all the attributes in the table

00043     { imAttribTableRemoveAll(ptable); }

void imAttribTable::CopyFrom const imAttribTable table  )  [inline]
 

Copies the contents of the given table into this table.

00047     { imAttribTableCopyFrom(ptable, table.ptable); }

void imAttribTable::Set const char *  name,
int  data_type,
int  count,
const void *  data
[inline]
 

Inserts an attribute into the table.
Data is duplicated if not NULL, else data is initialized with zeros. See also imDataType.

00053     { imAttribTableSet(ptable, name, data_type, count, data); }

void imAttribTable::UnSet const char *  name  )  [inline]
 

Removes an attribute from the table given its name.

00057     { imAttribTableUnSet(ptable, name); }

const void* imAttribTable::Get const char *  name,
int *  data_type = 0,
int *  count = 0
const [inline]
 

Finds an attribute in the table. Returns the attribute if found, NULL otherwise. See also imDataType.

00063     { return imAttribTableGet(ptable, name, data_type, count); }

void imAttribTable::ForEach void *  user_data,
imAttribTableCallback  attrib_func
const [inline]
 

For each attribute calls the user callback. If the callback returns 0 the function returns.

00067     { imAttribTableForEach(ptable, user_data, attrib_func); }


The documentation for this class was generated from the following file: