Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

PropertyEntry.cpp

Go to the documentation of this file.
00001 // $Id: PropertyEntry.cpp,v 1.4 2007/05/24 14:41:21 hmd Exp $
00002 // ============================================================================
00003 // CVS tag $Name:  $, version $Revision: 1.4 $ 
00004 // ============================================================================
00005 // Include files
00006 // ============================================================================
00007 // STD & STL 
00008 // ============================================================================
00009 #include <algorithm>
00010 // ============================================================================
00011 // local 
00012 // ============================================================================
00013 #include "Catalogue.h"
00014 #include "ParserUtils.h"
00015 // ============================================================================
00016 
00017 // ============================================================================
00018 // Purpose:    Implementation of PropertyEntry::PropertyEntry()
00019 // Comment:    Constructor
00020 // Parameters:
00021 // - name Name of property
00022 // - value String value of property
00023 // Return: 
00024 // ============================================================================
00025 Gaudi::Parsers::PropertyEntry::PropertyEntry
00026 (  const std::string& name, 
00027    const std::string& value )
00028 {
00029    m_name = name;
00030    m_value.push_back(value);
00031    m_isVector = false;
00032 }
00033 // ============================================================================
00034 // Purpose:    Implementation of PropertyEntry::PropertyEntry()
00035 // Comment:    Constructor
00036 // Parameters:
00037 // - name Name of property
00038 // - value Vector value of property
00039 // Return: 
00040 // ============================================================================
00041 Gaudi::Parsers::PropertyEntry::PropertyEntry
00042 ( const std::string& name, 
00043   const std::vector<std::string>& value )
00044 {
00045    m_name = name;
00046    m_value = value;
00047    m_isVector = true;
00048    if ( 1 == m_value.size() && "" == m_value[0] ) { clear(); }
00049 }
00050 // ============================================================================
00051 // Purpose:    Implementation of PropertyEntry::PropertyEntry()
00052 // Comment:    Constructor
00053 // Parameters:
00054 // - name Name of property
00055 // - value String value of property
00056 // - position Property position in file
00057 // Return: 
00058 // ============================================================================
00059 Gaudi::Parsers::PropertyEntry::PropertyEntry
00060 (  const std::string& name, 
00061    const std::string& value,
00062    const Position& pos )
00063 {
00064    m_name = name;
00065    m_value.push_back(value);
00066    m_position = pos;
00067    m_isVector = false;
00068 }
00069 
00070 // ============================================================================
00071 // Purpose:    Implementation of PropertyEntry::PropertyEntry()
00072 // Comment:    Constructor
00073 // Parameters:
00074 // - name Name of property
00075 // - value Vector value of property
00076 // - position Property position in file
00077 // Return: 
00078 // ============================================================================
00079 Gaudi::Parsers::PropertyEntry::PropertyEntry
00080 ( const std::string& name, 
00081   const std::vector<std::string>& value,
00082   const Position& pos )
00083 {
00084    m_name = name;
00085    m_value = value;
00086    m_position = pos;
00087    m_isVector = true;
00088    if ( 1 == m_value.size() && "" == m_value[0] ) { clear(); }
00089 }
00090 
00091 // ============================================================================
00092 // Purpose:    Implementation of PropertyEntry::value()
00093 // Comment:    Value of property
00094 // Return: Value of property
00095 // ============================================================================
00096 std::string Gaudi::Parsers::PropertyEntry::value(void) const
00097 {
00098    std::string result="";
00099    if(m_isVector){
00100       result = "[";
00101       std::string delim="";
00102       for(std::vector<std::string>::const_iterator cur=m_value.begin();
00103          cur!=m_value.end();cur++){
00104             result+=delim+*cur;
00105             delim=",";
00106       }
00107       result+="]";
00108    }else{
00109       if(m_value.size()>0){
00110          result = m_value[0];
00111         }
00112    }
00113    return result;
00114 }
00115 
00116 // ============================================================================
00117 // Purpose:    Implementation of PropertyEntry::addValues()
00118 // Comment:    Add values to vector value
00119 // Parameters:
00120 // - values Values to add
00121 // Return: StatusCode::SUCCESS if property value is vector 
00122 //  (and we can add values)
00123 // ============================================================================
00124 StatusCode Gaudi::Parsers::PropertyEntry::addValues
00125 ( const std::vector<std::string>& values )
00126 {
00127    if(!m_isVector) return StatusCode::FAILURE;
00128    for(std::vector<std::string>::const_iterator cur = values.begin();
00129     cur!=values.end();cur++){
00130       m_value.push_back(*cur);
00131     }
00132    return StatusCode::SUCCESS;   
00133 }
00134 
00135 // ============================================================================
00136 // Purpose:    Implementation of PropertyEntry::removeValues()
00137 // Comment:    Remove values from property value
00138 // Parameters:
00139 // - values 
00140 // - count Count of removed items
00141 // Return: StatusCode::SUCCESS if property value is vector 
00142 //  (and we can remove values)
00143 // ============================================================================
00144 StatusCode Gaudi::Parsers::PropertyEntry::removeValues
00145 ( const std::vector<std::string>& values, 
00146   int& count )
00147 {
00148    if(!m_isVector) return StatusCode::FAILURE;
00149    for(std::vector<std::string>::const_iterator
00150       cur = values.begin();cur!=values.end();cur++){
00151       std::vector<std::string>::iterator item = std::find(m_value.begin(),
00152         m_value.end(),*cur);
00153       if(item!=m_value.end()){
00154          m_value.erase(item);
00155          count++;
00156       }
00157     }
00158     return StatusCode::SUCCESS;
00159 }
00160 
00161 // ============================================================================
00162 // Purpose:    Implementation of PropertyEntry::clear()
00163 // Comment:    Clear property vector value
00164 // Return: StatusCode::SUCCESS if property value is vector 
00165 // (and we can clear values)
00166 // ============================================================================
00167 StatusCode Gaudi::Parsers::PropertyEntry::clear(void)
00168 {
00169    if(!m_isVector) return StatusCode::FAILURE;
00170    m_value.clear();
00171    return StatusCode::SUCCESS;
00172 }
00173 // ============================================================================
00175 // ============================================================================
00176 StatusCode Gaudi::Parsers::PropertyEntry::removeEnv() 
00177 {
00178   for ( std::vector<std::string>::iterator item = 
00179           m_value.begin() ; m_value.end() != item ; ++item ) 
00180   { *item = Gaudi::Parsers::Utils::removeEnvironment ( *item ) ; }
00181   return StatusCode::SUCCESS ;
00182 }
00183 // ============================================================================
00184 
00185 // ============================================================================
00186 // The END 
00187 // ============================================================================
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Wed Feb 9 16:25:02 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004