const AXmlElement *AXmlElement::findElement(const AString& xpath) const { LIST_AString xparts; xpath.split(xparts, '/'); if (xparts.size() > 0) { if ('/' == xpath.at(0)) { if (isNameEquals(xparts.front())) { xparts.pop_front(); if (xparts.size() > 0) return _get(xparts); else return this; } else return NULL; } else { if (xparts.size() > 0) return _get(xparts); else return NULL; } } else { return this; } }
static QVariant _get(const QObject* object, const QStringList &path, const QVariant& defaultValue) { QString key = path[0]; const QMetaObject* meta = object->metaObject(); if (meta->indexOfProperty(key.toUtf8().constData()) < 0) { return defaultValue; } QVariant value = object->property(key.toUtf8().constData()); if (path.size() == 1) { return value; } QStringList nextPath = path; nextPath.removeFirst(); if (value.canConvert<QObject*>()) { return _get(qvariant_cast<QObject*>(value), nextPath, defaultValue); } else if (value.type() == QVariant::Map) { return _get(value.toMap(), nextPath, defaultValue); } else { return defaultValue; } }
static QVariant _get(const QVariantMap& object, const QStringList &path, const QVariant& defaultValue) { QString key = path[0]; if (!object.contains(key)) { return defaultValue; } QVariant value = object[key]; if (path.size() == 1) { return value; } QStringList nextPath = path; nextPath.removeFirst(); if (value.canConvert<QObject*>()) { return _get(qvariant_cast<QObject*>(value), nextPath, defaultValue); } else if (value.type() == QVariant::Map) { return _get(value.toMap(), nextPath, defaultValue); } else { return defaultValue; } }
Vector2f getInputRange() const { Vector2f defaultValue( brion::MINIMUM_VOLTAGE, 0.f ); switch( getType( )) { case VolumeType::compartments: if( _get( "functor" ) == "lfp" ) defaultValue = Vector2f( -1.47e-05f, 2.25e-03f ); break; case VolumeType::somas: if( useTestData ) defaultValue = Vector2f( -15.f, 0.f ); break; case VolumeType::vsd: defaultValue = Vector2f( -100000.f, 300.f ); break; case VolumeType::spikes: defaultValue = Vector2f( 0.f, 2.f ); break; case VolumeType::synapses: defaultValue = FULLDATARANGE; break; default: defaultValue = Vector2f( 0.f, 10.f ); break; } return Vector2f( _get( "inputMin", defaultValue[0] ), _get( "inputMax", defaultValue[1] )); }
void MedianFilter::_onSet(const FilterParameterPtr &f) { if(f->name() == "stability") { if(!_get(f->name(), _stability)) { logger(LOG_WARNING) << "MedianFilter: Could not get the recently updated 'stability' parameter" << std::endl; } } else if(f->name() == "deadband") { if(!_get(f->name(), _deadband)) { logger(LOG_WARNING) << "MedianFilter: Could not get the recently updated 'deadband' parameter" << std::endl; } } else if(f->name() == "deadbandStep") { if(!_get(f->name(), _deadbandStep)) { logger(LOG_WARNING) << "MedianFilter: Could not get the recently updated 'deadbandStep' parameter" << std::endl; } } else if(f->name() == "halfKernelSize") { if(!_get(f->name(), _halfKernelSize)) { logger(LOG_WARNING) << "MedianFilter: Could not get the recently updated 'halfKernelSize' parameter" << std::endl; } } }
ssize_t driver_oss_write (struct roar_vio_calls * vio, void *buf, size_t count) { if ( _get(vio,fh) == -1 ) return -1; if ( _get(vio,need_config) ) { if ( driver_oss_config_device(vio->inst) == -1 ) { return -1; } } return write(_get(vio,fh), buf, count); }
static void TestBasic(void) { const char one[4] = {0x6F, 0x6E, 0x65, 0}; /* "one" */ const char one2[4] = {0x6F, 0x6E, 0x65, 0}; /* Get around compiler optimizations */ const char two[4] = {0x74, 0x77, 0x6F, 0}; /* "two" */ const char three[6] = {0x74, 0x68, 0x72, 0x65, 0x65, 0}; /* "three" */ const char omega[6] = {0x6F, 0x6D, 0x65, 0x67, 0x61, 0}; /* "omega" */ UErrorCode status = U_ZERO_ERROR; UHashtable *hash; hash = uhash_open(hashChars, isEqualChars, &status); if (U_FAILURE(status)) { log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n", u_errorName(status), hash); return; } if (hash == NULL) { log_err("FAIL: uhash_open returned NULL\n"); return; } log_verbose("Ok: uhash_open returned 0x%08X\n", hash); _put(hash, one, 1, 0); _put(hash, omega, 24, 0); _put(hash, two, 2, 0); _put(hash, three, 3, 0); _put(hash, one, -1, 1); _put(hash, two, -2, 2); _put(hash, omega, 48, 24); _put(hash, one, 100, -1); _get(hash, three, 3); _remove(hash, two, -2); _get(hash, two, 0); _get(hash, one, 100); _put(hash, two, 200, 0); _get(hash, omega, 48); _get(hash, two, 200); if(_compareChars((void*)one, (void*)three) == TRUE || _compareChars((void*)one, (void*)one2) != TRUE || _compareChars((void*)one, (void*)one) != TRUE || _compareChars((void*)one, NULL) == TRUE ) { log_err("FAIL: compareChars failed\n"); } if(_compareIChars((void*)one, (void*)three) == TRUE || _compareIChars((void*)one, (void*)one) != TRUE || _compareIChars((void*)one, (void*)one2) != TRUE || _compareIChars((void*)one, NULL) == TRUE ) { log_err("FAIL: compareIChars failed\n"); } uhash_close(hash); }
__MSLIB_CTOR Map::Portal::Portal(WZLib_SubProperty* parent):Object("__mslib_portal"){ WZLib_Object* obj=(WZLib_Object*)parent; this->pt=_get(obj,"pt").intVal; this->pn=NSH(_get(obj,"pn").strVal); this->tm=_get(obj,"tm").intVal; this->tn=NSH(_get(obj,"tn").strVal); this->hi=_get(obj,"horizontalImpact").intVal; this->vi=_get(obj,"verticalImpact").intVal; this->script=NSH(_get(obj,"script").strVal); this->onlyOnce=_get(obj,"onlyOnce").intVal; this->hideTooltip=_get(obj,"hideTooltip").intVal; this->uDelay=_get(obj,"delay").intVal; }
std::string getReport() const { const std::string& report( _get( "report" )); if( report.empty( )) { switch( getType( )) { case VolumeType::somas: return "somas"; default: return _get( "functor" ) == "lfp" ? "currents" : "voltages"; } } return report; }
// Return a value. // // If "row_id" is valid, returns the stored value. // If "row_id" is invalid, returns N/A. Int get(Int row_id) const { size_t value_id = row_id.raw(); if (value_id >= size_) { return Int::na(); } return _get(value_id); }
static void *_ssll_find (netsnmp_container * c, const void *data) { if ((NULL == c) || (NULL == data)) return NULL; return _get (c, data, 1); }
int driver_oss_sync(struct roar_vio_calls * vio) { #ifdef SNDCTL_DSP_SYNC return ioctl(_get(vio,fh), SNDCTL_DSP_SYNC, NULL); #else return 0; #endif }
FunctorType getFunctorType() const { const std::string& functor = _get( "functor" ); if( functor == "density" ) return FunctorType::density; if( functor == "lfp" ) return FunctorType::lfp; if( functor == "field" ) return FunctorType::field; if( functor == "frequency" ) return FunctorType::frequency; switch( getType( )) { case VolumeType::spikes: case VolumeType::synapses: LBTHROW( std::runtime_error( "No functor support for synapses and spikes. ")); case VolumeType::compartments: case VolumeType::somas: case VolumeType::vsd: case VolumeType::test: default: return FunctorType::field; } }
static void *_ssll_find_next (netsnmp_container * c, const void *data) { if (NULL == c) return NULL; return _get (c, data, 0); }
explicit Impl( const URI& parameters ) : uri( parameters ) , useTestData( false ) { if( getType() == VolumeType::test ) return; #ifdef FIVOX_USE_BBPTESTDATA useTestData = uri.getPath().empty( ); config.reset( new brion::BlueConfig( useTestData ? BBP_TEST_BLUECONFIG3 : uri.getPath( ))); #else config.reset( new brion::BlueConfig( uri.getPath( ))); #endif const brain::Circuit circuit( *config ); const std::string target = _get( "target", _get( "postTarget", useTestData ? "mini50" : config->getCircuitTarget( ))); const std::string preTarget = _get( "preTarget" ); const float gidFraction = getGIDFraction(); if( target == "*" ) { gids = gidFraction == 1.f ? circuit.getGIDs() : circuit.getRandomGIDs( gidFraction ); } else { gids = gidFraction == 1.f ? circuit.getGIDs( target ) : circuit.getRandomGIDs( gidFraction, target ); if( !preTarget.empty( )) { preGIDs = gidFraction == 1.f ? circuit.getGIDs( preTarget ) : circuit.getRandomGIDs( gidFraction, preTarget ); if( preGIDs.empty( )) LBTHROW( std::runtime_error( "No GIDs found for requested target '" + preTarget + "'" )); } } if( gids.empty( )) LBTHROW( std::runtime_error( "No GIDs found for requested target '" + target + "'" )); }
void TemporalMedianFilter::_onSet(const FilterParameterPtr &f) { if(f->name() == "order") { if(!_get(f->name(), _order)) { logger(LOG_WARNING) << "TemporalMedianFilter: Could not get the recently updated 'order' parameter" << std::endl; } } else if(f->name() == "deadband") { if(!_get(f->name(), _deadband)) { logger(LOG_WARNING) << "TemporalMedianFilter: Could not get the recently updated 'deadband' parameter" << std::endl; } } }
DWORD CBlockMem::_add(void *pdata, DWORD size, void **ppvoid,bool align) { void* pvoid; if (_get(size,&pvoid,align) != ERR_OK) return _LOG_AT; memcpy(pvoid,pdata,size); *ppvoid=pvoid; return ERR_OK; }
std::string CfgBase::getOptional(const std::string& name, XMLElement* elem) { std::string result; try { result = _get(name, elem); } catch (IllegalEntry ie) { } return result; }
bool StdFileInput::EndOfStream() const { if (_stream.eof()) return true; if (!_cp_ready) _get(); return _stream.eof(); }
char32_t StdFileInput::Peek() { if (EndOfStream()) return std::char_traits<char32_t>::eof(); if (!_cp_ready) _get(); return _cp; }
/** * qentry_t->getint(): Find integer object with given name. * * @param entry qentry_t pointer * @param name key name * * @return a integer value of the integer object, otherwise returns 0. */ static int _getint(qentry_t *entry, const char *name) { int n = 0; char *str = _get(entry, name, NULL, true); if (str != NULL) { n = atoi(str); free(str); } return n; }
/*! \param[in] lvl Уровень вейвлет преобразования \param[in] x_min Координата HH саббенда \param[in] y_min Координата HH саббенда \param[in] x_max Координата HH саббенда \param[in] y_max Координата HH саббенда */ void subbands::_mk_lvl(const sz_t lvl, const sz_t x_min, const sz_t y_min, const sz_t x_max, const sz_t y_max) { // количество коэффициентов в саббендах на этом уровне const sz_t count = x_min * y_min; // ссылки на HL, LH и HH саббенды этого уровня соответственно subband_t &sb_hl = get(lvl, SUBBAND_HL); subband_t &sb_lh = get(lvl, SUBBAND_LH); subband_t &sb_hh = get(lvl, SUBBAND_HH); // саббенд HL sb_hl.x_min = x_min; sb_hl.y_min = 0; sb_hl.x_max = x_max; sb_hl.y_max = y_min - 1; sb_hl.count = count; sb_hl.prnt = _get(lvl + LVL_PREV, SUBBAND_HL); sb_hl.lvl = lvl; sb_hl.i = SUBBAND_HL; // саббенд LH sb_lh.x_min = 0; sb_lh.y_min = y_min; sb_lh.x_max = x_min - 1; sb_lh.y_max = y_max; sb_lh.count = count; sb_lh.prnt = _get(lvl + LVL_PREV, SUBBAND_LH); sb_lh.lvl = lvl; sb_lh.i = SUBBAND_LH; // саббенд HH sb_hh.x_min = x_min; sb_hh.y_min = y_min; sb_hh.x_max = x_max; sb_hh.y_max = y_max; sb_hh.count = count; sb_hh.prnt = _get(lvl + LVL_PREV, SUBBAND_HH); sb_hh.lvl = lvl; sb_hh.i = SUBBAND_HH; }
double CfgBase::getDouble(const std::string& name, double def, XMLElement* elem) { std::string str; try { str = _get(name, elem); return atof(str.c_str()); } catch (IllegalEntry ie) { } // return default value return def; }
Selector::operator std::string() const { _traverse(); _get(); if (_functor != nullptr) { (*_functor)(1); _functor.reset(); } auto ret = detail::_pop(detail::_id<std::string>{}, _state._l); lua_settop(_state._l, 0); return ret; }
int driver_oss_nonblock(struct roar_vio_calls * vio, int state) { if ( roar_socket_nonblock(_get(vio,fh), state) == -1 ) return -1; if ( state == ROAR_SOCKET_NONBLOCK ) return 0; roar_vio_sync(vio); return 0; }
/** * qentry_t->_getstrf(): Find string object with given formatted name. * * @param entry qentry_t pointer * @param newmem whether or not to allocate memory for the data. * @param namefmt formatted name string * * @return a pointer of malloced data if key is found, otherwise returns NULL. */ static char *_getstrf(qentry_t *entry, bool newmem, const char *namefmt, ...) { char *name; DYNAMIC_VSPRINTF(name, namefmt); if (name == NULL) return NULL; char *data = (char *)_get(entry, name, NULL, newmem); free(name); return data; }
uint32_t CfgBase::getUInt32(const std::string& name, uint32_t def, XMLElement* elem) { std::string str; try { str = _get(name, elem); return strtoul(str.c_str(), NULL, 10); } catch (IllegalEntry ie) { } // return default value return def; }
int64_t CfgBase::getInt64(const std::string& name, int64_t def, XMLElement* elem) { std::string str; try { str = _get(name, elem); return atoll(str.c_str()); } catch (IllegalEntry ie) { } // return default value return def; }
void SmoothFilter::_onSet(const FilterParameterPtr &f) { if(f->name() == "sigma") { float s; if(!_get(f->name(), s)) { logger(LOG_WARNING) << "SmoothFilter: Could not get the recently updated 'sigma' parameter" << std::endl; } _discreteGaussian.setStandardDeviation(s); } }
void FlypixFilter::_onSet(const FilterParameterPtr &f) { if(f->name() == "threshold") { float s; if(!_get(f->name(), s)) { logger(LOG_WARNING) << "FlypixFilter: Could not get the recently updated 'threshold' parameter" << std::endl; } _thr = s; } }