Esempio n. 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;
}
Esempio n. 2
0
/** Look for a parameter in the given component by the type of the parameter.
* @param comp :: Component to which parameter is related
* @param type :: Parameter type
* @returns The typed parameter if it exists or a NULL shared pointer if not
*/
Parameter_sptr ParameterMap::getByType(const IComponent *comp,
                                       const std::string &type) const {
  Parameter_sptr result = Parameter_sptr();
  PARALLEL_CRITICAL(m_mapAccess) {
    if (!m_map.empty()) {
      const ComponentID id = comp->getComponentID();
      pmap_cit it_found = m_map.find(id);
      if (it_found != m_map.end()) {
        if (it_found->first) {
          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->type(), type)) {
              result = param;
              break;
            }
          }
        } // found->firdst
      }   // it_found != m_map.end()
    }     //!m_map.empty()
  }       // PARALLEL_CRITICAL(m_map_access)
  return result;
}
Esempio n. 3
0
    /** SLOWER LOOKUP in multithreaded loops. Return 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
     * @returns The named parameter of the given type if it exists or a NULL shared pointer if not
     */
    Parameter_sptr ParameterMap::get(const IComponent* comp, const std::string& name, 
                                     const std::string & type) 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);

      const bool anytype = type.empty();
      for( ; itr != itr_end; ++itr )
      {
        Parameter_sptr param = itr->second;
        if( param->name() == name && (anytype || param->type() == type) )
        {
          return param;
        }
      }
      return Parameter_sptr();
    }