Пример #1
0
/**Return a const iterator pointing to a named parameter of a given type.
 * @param comp :: Component to which parameter is related
 * @param name :: Parameter name
 * @param type :: An optional type string. If empty, any type is returned
 * @returns The iterator parameter of the given type if it exists or a NULL
 * shared pointer if not
*/
component_map_cit ParameterMap::positionOf(const IComponent *comp,
                                           const char *name,
                                           const char *type) const {
  pmap_cit result = m_map.end();
  if (!comp)
    return result;
  const bool anytype = (strlen(type) == 0);
  if (!m_map.empty()) {
    const ComponentID id = comp->getComponentID();
    pmap_cit it_found = m_map.find(id);
    if (it_found != m_map.end()) {
      pmap_cit itr = m_map.lower_bound(id);
      pmap_cit itr_end = m_map.upper_bound(id);
      for (; itr != itr_end; ++itr) {
        Parameter_sptr param = itr->second;
        if (boost::iequals(param->nameAsCString(), name) &&
            (anytype || param->type() == type)) {
          result = itr;
          break;
        }
      }
    }
  }
  return result;
}
Пример #2
0
 /** FASTER LOOKUP in multithreaded loops. Return a named parameter
  * @param comp :: Component to which parameter is related
  * @param name :: Parameter name
  * @returns The named parameter if it exists or a NULL shared pointer if not
  */
 Parameter_sptr ParameterMap::get(const IComponent* comp, const char* name) const
 {
   if( m_map.empty() ) return Parameter_sptr();
   const ComponentID id = comp->getComponentID();
   pmap_cit it_found = m_map.find(id);
   if (it_found == m_map.end())
   {
     return Parameter_sptr();
   }
   pmap_cit itr = m_map.lower_bound(id);
   pmap_cit itr_end = m_map.upper_bound(id);
   for( ; itr != itr_end; ++itr )
   {
     Parameter_sptr param = itr->second;
     if( strcmp(param->nameAsCString(), name) == 0 )
     {
       return param;
     }
   }
   return Parameter_sptr();
 }