ParameterGroupTable< T > Class Template Reference

template<class T>
class awSupport::ParameterGroupTable< T >

#include <ParameterGroupTable.h>

Inheritance diagram for ParameterGroupTable< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  ParameterGroupTable ()
bool  addGroup (aw::Reference< T > &group)
bool  deleteGroup (aw::Reference< T > &group)
aw::Reference< T >  getGroupByIndex (int) const
aw::Reference< T >  getGroup (const awString::IString &groupName)
awString::IString  generateUniqueName (const awString::IString &basis)
int  getGroupCount () const
int  getGroups (aw::vector< aw::Reference< T > > &groups) const
void  clear ()

Protected Member Functions

  ~ParameterGroupTable ()

Constructor & Destructor Documentation

~ParameterGroupTable ( ) [protected]
{
}

Member Function Documentation

bool addGroup ( aw::Reference< T > &  group )
{
    // Only add the given group if it is not NULL, and a group with the 
    // same name does not already exist
    if ( NULL != group.get() )
    {
        ParameterGroupMap::const_iterator iter = myGroups.find( group->getName() );
        if ( iter == myGroups.end() )
        {
            myGroups[group->getName()] = group;
            return true;
        }
    }
    return false;
}
bool deleteGroup ( aw::Reference< T > &  group )
{
    // Delete the given group if it exists
    if ( NULL != group.get() )
    {
        ParameterGroupMap::iterator iter = myGroups.find( group->getName() );
        if ( iter != myGroups.end() )
        {
            myGroups.erase( iter );
            return true;
        }
    }
    return false;
}
aw::Reference< T > getGroupByIndex ( int  index ) const
{
    aw::Reference<T> result;
    if ( index >= 0 && index < getGroupCount() )
    {
        ParameterGroupMap::const_iterator iter = myGroups.begin();
        for( ; index > 0 ; index-- ) 
        { 
            iter++; 
        }
        result = iter->second;
    }
    return result;

}
aw::Reference< T > getGroup ( const awString::IString &  groupName )
{
    aw::Reference<T>    group;

    // We could use the indexing (ie. []) operator, but using the find
    // method with an iterator allows us to return a success value.
    //
    ParameterGroupMap::const_iterator iter = myGroups.find( groupName );
    if ( iter != myGroups.end() )
    {
        group = (*iter).second;
        return group;
    }
    return group;
}
awString::IString generateUniqueName ( const awString::IString &  basis )
{
    awSupport::Id newId( basisId );

    while( NULL != getGroup( newId ).get() )
    {
        newId = awSupport::Id::incrementCopyId( newId );
    }

    return newId;
}
int getGroupCount ( ) const
{
    return myGroups.size();
}
int getGroups ( aw::vector< aw::Reference< T > > &  groups ) const
{
    ParameterGroupMap::const_iterator g;
    int i = 0;

    groups.clear();
    for( g = myGroups.begin();  g != myGroups.end();  ++g )
    {
        groups.push_back(g->second);
        ++i;
    }
    return i;
}
void clear ( )
{
    myGroups.clear();
}