/** * Find a parameter by name, recursively going up the component tree * to higher parents. * @param comp :: The component to start the search with * @param name :: Parameter name * @param type :: An optional type string * @returns the first matching parameter. */ Parameter_sptr ParameterMap::getRecursive(const IComponent* comp,const std::string& name, const std::string & type) const { if( m_map.empty() ) return Parameter_sptr(); boost::shared_ptr<const IComponent> compInFocus(comp,NoDeleting()); while( compInFocus != NULL ) { Parameter_sptr param = get(compInFocus.get(), name, type); if (param) { return param; } compInFocus = compInFocus->getParent(); } //Nothing was found! return Parameter_sptr(); }
/** 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(); }
/** FASTER LOOKUP in multithreaded loops. Find a parameter by name, recursively going up * the component tree to higher parents. * @param comp :: The component to start the search with * @param name :: Parameter name * @returns the first matching parameter. */ Parameter_sptr ParameterMap::getRecursive(const IComponent* comp, const char * name) const { boost::shared_ptr<const IComponent> compInFocus(comp,NoDeleting()); while( compInFocus != NULL ) { Parameter_sptr param = get(compInFocus.get(), name); if (param) { return param; } compInFocus = compInFocus->getParent(); } //Nothing was found! return Parameter_sptr(); }
/** 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(); }
/** 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; }