FieldRegistry.cpp

Go to the documentation of this file.
00001 #include "FieldRegistry.h"
00002 
00003 FieldRegistry::FieldRegistry(void)
00004 {
00005     fields.clear();
00006     name_to_id_map.clear();
00007 }
00008 
00009 FieldRegistry::~FieldRegistry(void)
00010 {
00011     for( size_t i=0; i<fields.size(); i++ ) {
00012         delete fields[ i ];
00013     }
00014 }
00015 
00017 void FieldRegistry::registerField( Field const& f )
00018 {
00019     if( name_to_id_map.find( f.name ) == name_to_id_map.end() ) {
00020         name_to_id_map[ f.name ] = fields.size();
00021         fields.push_back( f.clone() );
00022     }
00023 }
00024 
00026 Field const& FieldRegistry::getField(size_t id) const
00027 {
00028     return *(fields.at( id ));
00029 }
00030 
00032 Field const* FieldRegistry::findField( string const& name ) const
00033 {
00034     if( name_to_id_map.find( name ) != name_to_id_map.end() ) {
00035         size_t id = name_to_id_map.find( name )->second;
00036         return fields[ id ];
00037     } else {
00038         return NULL;
00039     }
00040 }

Generated on Wed Jul 9 16:34:37 2008 for PCSIM by  doxygen 1.5.5