OBTConfigurationItem.cpp

Go to the documentation of this file.
00001 #include "OBTConfigurationItem.h"
00002 
00003 using namespace OBT ;
00004 
00005 //-------------------------------------------------------------------------
00006 // ConfigurationItem()
00007 //-------------------------------------------------------------------------
00008 ConfigurationItem::ConfigurationItem( const char* name )
00009 :
00010 _name( name )
00011 {
00012    
00013 }
00014 
00015 //-------------------------------------------------------------------------
00016 // ~ConfigurationItem()
00017 //-------------------------------------------------------------------------
00018 ConfigurationItem::~ConfigurationItem()
00019 {  
00020 }
00021 
00022 //-------------------------------------------------------------------------
00023 // getChildren()
00024 //-------------------------------------------------------------------------
00025 std::vector<const ConfigurationItem*> 
00026 ConfigurationItem::getChildren( const char* name ) const
00027 {
00028         std::vector<const ConfigurationItem*> configItems ;
00029         if ( name == _name )
00030         {
00031                 configItems.push_back( this ) ;
00032         }
00033         std::vector<const ConfigurationItem*> returnedItems ;
00034         std::string str( name ) ;
00035         std::vector<ConfigurationItem>::const_iterator ite( _children.begin() ) ;
00036         std::vector<ConfigurationItem>::const_iterator iteE( _children.end() ) ;
00037         for ( ; ite != iteE ; ++ite )
00038         {
00039                 returnedItems = ite->getChildren( name ) ;
00040                 if ( returnedItems.size() != 0 )
00041                 {
00042                         configItems.insert( configItems.end(), returnedItems.begin(), returnedItems.end() ) ;
00043                 }
00044         }
00045         return configItems ;
00046 }
00047 
00048 //-------------------------------------------------------------------------
00049 // touchChildren()
00050 //-------------------------------------------------------------------------
00051 std::vector<ConfigurationItem*> 
00052 ConfigurationItem::touchChildren( const char* name )
00053 {
00054         std::vector< ConfigurationItem*> configItems ;
00055         if ( name == _name )
00056         {
00057                 configItems.push_back( this ) ;
00058         }
00059         std::vector< ConfigurationItem*> returnedItems ;
00060         std::string str( name ) ;
00061         std::vector<ConfigurationItem>::iterator ite( _children.begin() ) ;
00062         std::vector<ConfigurationItem>::iterator iteE( _children.end() ) ;
00063         for ( ; ite != iteE ; ++ite )
00064         {
00065                 returnedItems = ite->touchChildren( name ) ;
00066                 if ( returnedItems.size() != 0 )
00067                 {
00068                         configItems.insert( configItems.end(), returnedItems.begin(), returnedItems.end() ) ;
00069                 }
00070         }
00071         return configItems ;
00072 }
00073 
00074 //-------------------------------------------------------------------------
00075 // traceConfigurationItems()
00076 //-------------------------------------------------------------------------
00077 std::string 
00078 ConfigurationItem::traceConfigurationItems( ) const 
00079 {
00080         static std::string tabString ;
00081         std::string result ;
00082         result += tabString ;
00083         result += getName() ;
00084 
00085         std::pair< const char*, const char* > argument ;
00086         unsigned int nArguments = getArgumentsCount() ;
00087         for ( unsigned int i = 0 ; i < nArguments ; ++i )
00088         {
00089                 argument = getArgument( i ) ;
00090                 result += " " ;
00091                 result += argument.first ;
00092                 result += "=" ;
00093                 result += argument.second ;
00094         }
00095 
00096         result += "\n" ;
00097 
00098         unsigned int nChildren = getChildrenCount() ;
00099         for ( unsigned int i = 0 ; i < nChildren ; ++i )
00100         {
00101                 tabString += "   " ;
00102                 result += getChild( i ).traceConfigurationItems() ;
00103                 tabString = tabString.substr( 0, tabString.size() - 3 ) ;
00104         }
00105         return result ;
00106 }
00107 
00108 

Generated on Wed Oct 1 11:34:04 2008 for OBT by  doxygen 1.5.3