void operator()(boost::ptr_vector<Variable>& target, Tag tag) { target.push_back( new ValueVariable<Tag>() ); if (localization::MetaInfo<Tag>::has_range) { target.push_back( new MinVariable<Tag>() ); target.push_back( new MaxVariable<Tag>() ); } }
const Value MessageSelectorEnv::specialValue(const string& id) const { Value v; // TODO: Just use a simple if chain for now - improve this later if ( id=="delivery_mode" ) { v = msg.getEncoding().isPersistent() ? PERSISTENT : NON_PERSISTENT; } else if ( id=="redelivered" ) { v = msg.getDeliveryCount()>0 ? true : false; } else if ( id=="priority" ) { v = int64_t(msg.getPriority()); } else if ( id=="correlation_id" ) { MessageId cId = msg.getEncoding().getCorrelationId(); if (cId) { returnedStrings.push_back(new string(cId.str())); v = returnedStrings[returnedStrings.size()-1]; } } else if ( id=="message_id" ) { MessageId mId = msg.getEncoding().getMessageId(); if (mId) { returnedStrings.push_back(new string(mId.str())); v = returnedStrings[returnedStrings.size()-1]; } } else if ( id=="to" ) { v = EMPTY; // Hard to get this correct for both 1.0 and 0-10 } else if ( id=="reply_to" ) { v = EMPTY; // Hard to get this correct for both 1.0 and 0-10 } else if ( id=="absolute_expiry_time" ) { qpid::sys::AbsTime expiry = msg.getExpiration(); // Java property has value of 0 for no expiry v = (expiry==qpid::sys::FAR_FUTURE) ? 0 : qpid::sys::Duration(qpid::sys::AbsTime::Epoch(), expiry) / qpid::sys::TIME_MSEC; } else if ( id=="creation_time" ) { // Use the time put on queue (if it is enabled) as 0-10 has no standard way to get message // creation time and we're not paying attention to the 1.0 creation time yet. v = int64_t(msg.getTimestamp() * 1000); // getTimestamp() returns time in seconds we need milliseconds } else if ( id=="jms_type" ) { // Currently we can't distinguish between an empty JMSType and no JMSType // We'll assume for now that setting an empty JMSType doesn't make a lot of sense const string jmsType = msg.getAnnotation("jms-type").asString(); if ( !jmsType.empty() ) { returnedStrings.push_back(new string(jmsType)); v = returnedStrings[returnedStrings.size()-1]; } } else { v = Value(); } return v; }
void Projector::compute_projections(boost::ptr_vector<Projection>& projections, int image_size) const { // get coordinates IMP::algebra::Vector3Ds points(particles_.size()); for (unsigned int i = 0; i < particles_.size(); i++) { points[i] = core::XYZ(particles_[i]).get_coordinates(); } int axis_size = estimate_image_size(points); if (axis_size <= image_size) axis_size = image_size; // storage for rotated points IMP::algebra::Vector3Ds rotated_points(points.size()); IMP::algebra::Rotation3Ds rotations; IMP::algebra::Vector3Ds axes; projection_sphere_.get_all_rotations_and_axes(rotations, axes); for (unsigned int i = 0; i<rotations.size(); i++) { // rotate points for (unsigned int point_index = 0; point_index < points.size(); point_index++) { rotated_points[point_index] = rotations[i] * points[point_index]; } // project IMP_UNIQUE_PTR<Projection> p(new Projection(rotated_points, mass_, pixel_size_, resolution_, axis_size)); p->set_rotation(rotations[i]); p->set_axis(axes[i]); p->set_id(i); projections.push_back(p.release()); } }
Layout(float s0_snr,float mean_dif_,unsigned char odf_fold = 8,float discrete_scale_ = 0.5,float spin_density_ = 2000.0) :mean_dif(mean_dif_),discrete_scale(discrete_scale_),spin_density(spin_density_) { ti.init(odf_fold); for (unsigned int index = 0; index * discrete_scale <= spin_density+1.0; ++index) rician_gen.push_back(new RacianNoise((float)index * discrete_scale,spin_density/s0_snr)); }
void AotGraphan::analyzeString( const std::string & str, boost::ptr_vector<Unit> & units ) { setupRml(); try { CGraphmatFile file; if( !file.LoadDicts() ) { // Загружаем словари throw std::logic_error( file.GetLastError() ); } if( !file.LoadStringToGraphan( str ) ) { // Загружаем файл throw std::logic_error( file.GetLastError() ); } for( const CGraLine & line : file.GetUnits() ) { units.push_back( new Unit( line.GetToken(), line.GetTokenLength(), line.GetInputOffset(), line.IsWordOrNumberOrAbbr() ? Unit::WORD : line.IsPunct() ? Unit::PUNCT : Unit::UNKNOWN ) ); } } catch ( const std::exception & e ) { throw e; } catch ( const CExpc & e ) { throw std::logic_error( "Couldn't init morphology: " + e.m_strCause ); } catch (...) { throw std::logic_error( "Couldn't init morphology due to unknown error" ); } }
/** * Function FindRescues * Grab all possible RESCUE_CACHE_CANDIDATEs into a vector. * @param aRescuer - the working RESCUER instance. * @param aCandidates - the vector the will hold the candidates. */ static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates ) { typedef std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map_t; candidate_map_t candidate_map; wxString part_name_suffix = aRescuer.GetPartNameSuffix(); for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) ) { wxString part_name( each_component->GetPartName() ); LIB_PART* cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true ); LIB_PART* lib_match = aRescuer.GetLibs()->FindLibPart( part_name ); // Test whether there is a conflict if( !cache_match || !lib_match ) continue; if( !cache_match->PinsConflictWith( *lib_match, /* aTestNums */ true, /* aTestNames */ true, /* aTestType */ true, /* aTestOrientation */ true, /* aTestLength */ false )) continue; RESCUE_CACHE_CANDIDATE candidate( part_name, part_name + part_name_suffix, cache_match, lib_match ); candidate_map[part_name] = candidate; } // Now, dump the map into aCandidates for( const candidate_map_t::value_type& each_pair : candidate_map ) { aCandidates.push_back( new RESCUE_CACHE_CANDIDATE( each_pair.second ) ); } }
/** * Function FindRescues * Grab all possible RESCUE_CASE_CANDIDATES into a vector. * @param aRescuer - the working RESCUER instance. * @param aCandidates - the vector the will hold the candidates. */ static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates ) { typedef std::map<wxString, RESCUE_CASE_CANDIDATE> candidate_map_t; candidate_map_t candidate_map; for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) ) { wxString part_name( each_component->GetPartName() ); LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( part_name ); std::vector<LIB_ALIAS*> case_insensitive_matches; aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name ); if( case_sensitive_match || !( case_insensitive_matches.size() ) ) continue; RESCUE_CASE_CANDIDATE candidate( part_name, case_insensitive_matches[0]->GetName(), case_insensitive_matches[0]->GetPart() ); candidate_map[part_name] = candidate; } // Now, dump the map into aCandidates for( const candidate_map_t::value_type& each_pair : candidate_map ) { aCandidates.push_back( new RESCUE_CASE_CANDIDATE( each_pair.second ) ); } }
void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths) { int num_rings = read_integer(); if (num_rings > 0) { std::unique_ptr<geometry_type> poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); if (num_points > 0) { CoordinateArray ar(num_points); read_coords_xyz(ar); poly->move_to(ar[0].x, ar[0].y); for (int j = 1; j < num_points; ++j) { poly->line_to(ar[j].x, ar[j].y); } poly->close_path(); } } if (poly->size() > 2) // ignore if polygon has less than 3 vertices paths.push_back(poly.release()); } }
void AddNormalizationRestrictionImpl::operator()( boost::ptr_vector<Restriction> & restrictions ) const { AgreementRestriction *agrRestr = new AgreementRestriction(); agrRestr->addArgument(new AttributeExpression(new CurrentAnnotationExpression(), lspl::text::attributes::AttributeKey::BASE)); agrRestr->addArgument(new ConstantExpression("1")); Restriction * restriction = agrRestr; restrictions.push_back( restriction ); }
static void grid2utf(T const& grid_type, boost::ptr_vector<uint16_t> & lines, std::vector<typename T::lookup_type>& key_order, unsigned int resolution) { typedef std::map< typename T::lookup_type, typename T::value_type> keys_type; typedef typename keys_type::const_iterator keys_iterator; typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys(); typename T::feature_key_type::const_iterator feature_pos; keys_type keys; // start counting at utf8 codepoint 32, aka space character uint16_t codepoint = 32; unsigned array_size = std::ceil(grid_type.width()/static_cast<float>(resolution)); for (unsigned y = 0; y < grid_type.height(); y=y+resolution) { uint16_t idx = 0; uint16_t* line = new uint16_t[array_size]; typename T::value_type const* row = grid_type.getRow(y); for (unsigned x = 0; x < grid_type.width(); x=x+resolution) { // todo - this lookup is expensive typename T::value_type feature_id = row[x]; feature_pos = feature_keys.find(feature_id); if (feature_pos != feature_keys.end()) { typename T::lookup_type const& val = feature_pos->second; keys_iterator key_pos = keys.find(val); if (key_pos == keys.end()) { // Create a new entry for this key. Skip the codepoints that // can't be encoded directly in JSON. if (codepoint == 34) ++codepoint; // Skip " else if (codepoint == 92) ++codepoint; // Skip backslash if (feature_id == mapnik::grid::base_mask) { keys[""] = codepoint; key_order.push_back(""); } else { keys[val] = codepoint; key_order.push_back(val); } line[idx++] = static_cast<uint16_t>(codepoint); ++codepoint; } else { line[idx++] = static_cast<uint16_t>(key_pos->second); } } // else, shouldn't get here... } lines.push_back(line); } }
void AddWordMatcherImpl::operator()( boost::ptr_vector<Matcher> & matchers, const std::string & base, SpeechPart speechPart, uint index, boost::ptr_vector< Restriction > & restrictions ) const { Matcher * matcher = new WordMatcher( base, speechPart ); matcher->variable = Variable( speechPart, index ); matcher->addRestrictions( restrictions ); matchers.push_back( matcher ); }
void read_point(boost::ptr_vector<geometry_type> & paths) { double x = read_double(); double y = read_double(); std::unique_ptr<geometry_type> pt(new geometry_type(geometry_type::types::Point)); pt->move_to(x, y); paths.push_back(pt.release()); }
void read_point(boost::ptr_vector<geometry_type> & paths) { geometry_type* pt = new geometry_type(Point); double x = read_double(); double y = read_double(); pt->move_to(x, y); paths.push_back(pt); }
void set(const string& id, const qb::Value& value) { if (value.type==qb::Value::T_STRING) { strings.push_back(new string(*value.s)); values[id] = strings[strings.size()-1]; } else { values[id] = value; } }
void MultiDispatch::parseParameters( const std::vector<std::string>& input, boost::ptr_vector<ExpressionPiece>& output) { for (vector<string>::const_iterator it = input.begin(); it != input.end(); ++it) { const char* src = it->c_str(); output.push_back(get_complex_param(src)); } }
void AddAlternativeDefinitionImpl::operator()( boost::ptr_vector<Alternative> & alts, boost::ptr_vector<Matcher> & matchers, boost::ptr_map<AttributeKey,Expression> & bindings, const std::string & source, const std::string & transformSource ) const { Alternative * alternative = new Alternative( source, transformSource ); // Добавляем новую альтернативу к шаблону alternative->addMatchers( matchers ); // Добавляем сопоставители alternative->addBindings( bindings ); // Добавляем связывания alternative->updateDependencies(); // Обновляем зависимости альтернативы alts.push_back( alternative ); }
void AddPatternMatcherImpl::operator()( boost::ptr_vector<Matcher> & matchers, const std::string & name, uint index, boost::ptr_vector< Restriction > & restrictions ) const { PatternRef pattern = getPattern( name ); PatternMatcher * matcher = new PatternMatcher( *pattern ); matcher->variable = Variable( *pattern, index ); matcher->addRestrictions( restrictions ); matchers.push_back( matcher ); }
void read_linestring_xyz(boost::ptr_vector<geometry_type> & paths) { geometry_type* line = new geometry_type(LineString); int num_points = read_integer(); CoordinateArray ar(num_points); read_coords_xyz(ar); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } paths.push_back(line); }
void AddLoopMatcherImpl::operator()( boost::ptr_vector<Matcher> & matchers, uint min, uint max, std::vector<uint> & alternativesCount ) const { LoopMatcher * matcher = new LoopMatcher( min, max ); for ( int i = alternativesCount.size() - 1; i >= 0 ; -- i ) { // Важно!! Здесь перебираем в обратном порядке! MatcherContainer * matcherGroup = new MatcherContainer(); // Создаем контейнер для альтернативы matcherGroup->addMatchers( matchers.end() - alternativesCount[ i ], matchers.end(), matchers ); matcher->addAlternative( matcherGroup ); } matchers.push_back( matcher ); }
void Parser::parseFile ( ProgramOptions &options, boost::ptr_vector<File> &fileList ) { std::string output = options.getFileName(); std::ifstream stream ( output, std::ios::in ); std::string line, path, name; std::uintmax_t file_size; if ( stream.is_open() ) { while ( stream.good() ) { std::getline ( stream, line ); std::stringstream lineStream ( line ); lineStream >> file_size >> path >> name; File *newFile = new File ( file_size, path, name ); fileList.push_back ( newFile ); } } else
void read_linestring_xyz(boost::ptr_vector<geometry_type> & paths) { int num_points = read_integer(); if (num_points > 0) { CoordinateArray ar(num_points); read_coords_xyz(ar); std::unique_ptr<geometry_type> line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } paths.push_back(line.release()); } }
inline std::vector<std::string> command::columns() { using namespace std; using namespace brig::unicode; vector<string> cols; if (0 == m_hnd.stmt) return cols; m_cols.clear(); ub4 count(0); m_hnd.check(lib::singleton().p_OCIAttrGet(m_hnd.stmt, OCI_HTYPE_STMT, &count, 0, OCI_ATTR_PARAM_COUNT, m_hnd.err)); for (ub4 i(0); i < count; ++i) { OCIParam *dsc(0); m_hnd.check(lib::singleton().p_OCIParamGet(m_hnd.stmt, OCI_HTYPE_STMT, m_hnd.err, (void**)&dsc, i + 1)); try { ub2 data_type(0), size(0); sb2 precision(0); sb1 scale(-1); ub1 charset_form(SQLCS_NCHAR); utext *name(0), *nty_schema(0), *nty(0); ub4 name_len(0), nty_schema_len(0), nty_len(0); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &name, &name_len, OCI_ATTR_NAME, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &data_type, 0, OCI_ATTR_DATA_TYPE, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &size, 0, OCI_ATTR_DATA_SIZE, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &precision, 0, OCI_ATTR_PRECISION, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &scale, 0, OCI_ATTR_SCALE, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &charset_form, 0, OCI_ATTR_CHARSET_FORM, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &nty_schema, &nty_schema_len, OCI_ATTR_SCHEMA_NAME, m_hnd.err)); m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &nty, &nty_len, OCI_ATTR_TYPE_NAME, m_hnd.err)); identifier nty_lcase = { transform<char>(nty_schema, lower_case), transform<char>(nty, lower_case), "" }; m_cols.push_back(define_factory(&m_hnd, i + 1, data_type, size, precision, scale, charset_form, nty_lcase)); cols.push_back(transform<char>(name)); } catch (const exception&) { handles::free_descriptor((void**)&dsc, OCI_DTYPE_PARAM); throw; } handles::free_descriptor((void**)&dsc, OCI_DTYPE_PARAM); } ub4 rows = ub4(PageSize); m_hnd.check(lib::singleton().p_OCIAttrSet(m_hnd.stmt, OCI_HTYPE_STMT, &rows, 0, OCI_ATTR_PREFETCH_ROWS, m_hnd.err)); return cols; }
void GetAll(boost::ptr_vector<acl::Group>& groups) { groups.clear(); QueryResults results; mongo::Query query; boost::unique_future<bool> future; TaskPtr task(new db::Select("groups", query, results, future)); Pool::Queue(task); future.wait(); if (results.size() == 0) return; for (auto& obj: results) groups.push_back(bson::Group::Unserialize(obj)); }
SharedIO(const std::string &type1, const std::string &type2, const std::string &type3_1, const std::string &type3_2, const std::string &type4_1, const std::string &type4_2, const CharString &input1, const CharString &input2) : n(0), type1_n(0), type2_n(0), type3_n(0), type4_n(0), Stream_1(type1.c_str(), SequenceStream::WRITE), Stream_2(type2.c_str(), SequenceStream::WRITE), Stream_3_1(type3_1.c_str(), SequenceStream::WRITE), Stream_3_2(type3_2.c_str(), SequenceStream::WRITE), Stream_4_1(type4_1.c_str(), SequenceStream::WRITE), Stream_4_2(type4_2.c_str(), SequenceStream::WRITE), seqStream1(toCString(input1)), seqStream2(toCString(input2)), mutTypes(4) { for (int i = 0; i < 4; i++) { mutTypes.push_back(new boost::mutex()); } }
inline std::vector<std::string> command::columns() { std::vector<std::string> cols; if (lib::error(m_req)) return cols; m_cols.clear(); T_CCI_SQLX_CMD cmd_type; int col_count(0); T_CCI_COL_INFO* col_info(lib::singleton().p_cci_get_result_info(m_req, &cmd_type, &col_count)); if (!col_info) throw std::runtime_error("CUBRID error"); for (int i(1); i <= col_count; ++i) { m_cols.push_back(get_data_factory(CCI_GET_RESULT_INFO_TYPE(col_info, i))); cols.push_back(CCI_GET_RESULT_INFO_NAME(col_info, i)); } return cols; }
void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths) { geometry_type* poly = new geometry_type(Polygon); int num_rings = read_integer(); unsigned capacity = 0; for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); capacity += num_points; CoordinateArray ar(num_points); read_coords_xyz(ar); poly->move_to(ar[0].x, ar[0].y); for (int j = 1; j < num_points; ++j) { poly->line_to(ar[j].x, ar[j].y); } } paths.push_back(poly); }
void AotMorphology::appendWordForms( const std::string & token, boost::ptr_vector<WordForm> & forms ) { std::string tokenCopy = token; std::vector<CFormInfo> aotForms; lemmatizer->CreateParadigmCollection(false, tokenCopy, is_russian_upper( (BYTE)token[0] ), true, aotForms); for ( uint i = 0; i < aotForms.size(); ++ i) { const CFormInfo & f = aotForms[i]; std::string srcAncode = f.GetSrcAncode(); const char * gramCodes = srcAncode.c_str(); uint attributeSetCount = srcAncode.length() / 2; uint64 * attributeSets = new uint64[ attributeSetCount ]; for ( uint i = 0; i < attributeSetCount; ++i ) attributeSets[i] = getAttributes( gramCodes + 2*i ); forms.push_back( new WordForm( getSpeechPart( gramCodes ), f.GetWordForm( 0 ), getStem( f ), attributeSets, attributeSetCount ) ); } }
inline std::vector<std::string> command::columns() { std::vector<std::string> cols; if (!m_stmt) return cols; m_binds.clear(); m_cols.clear(); MYSQL_RES* res(lib::singleton().p_mysql_stmt_result_metadata(m_stmt)); check(res != 0); const unsigned int count(lib::singleton().p_mysql_num_fields(res)); m_binds.resize(count); memset(m_binds.data(), 0, m_binds.size() * sizeof(MYSQL_BIND)); for (unsigned int i(0); i < count; ++i) { MYSQL_FIELD* field(lib::singleton().p_mysql_fetch_field_direct(res, i)); m_cols.push_back(bind_result_factory(field, m_binds[i])); cols.push_back(field->name); } lib::singleton().p_mysql_free_result(res); check(lib::singleton().p_mysql_stmt_bind_result(m_stmt, m_binds.data()) == 0); return cols; }
bool load_dicom_multi_frame(const char* file_name,boost::ptr_vector<DwiHeader>& dwi_files) { image::io::dicom dicom_header;// multiple frame image if(!dicom_header.load_from_file(file_name)) return false; { // Philips multiframe unsigned int slice_num = dicom_header.get_int(0x2001,0x102D); if(!slice_num) slice_num = 1; image::basic_image<unsigned short,3> buf_image; dicom_header >> buf_image; unsigned short num_gradient = buf_image.depth()/slice_num; unsigned int plane_size = buf_image.width()*buf_image.height(); for(unsigned int index = 0;check_prog(index,num_gradient);++index) { std::auto_ptr<DwiHeader> new_file(new DwiHeader); if(index == 0) get_report_from_dicom(dicom_header,new_file->report); new_file->image.resize(image::geometry<3>(buf_image.width(),buf_image.height(),slice_num)); for(unsigned int j = 0;j < slice_num;++j) std::copy(buf_image.begin()+(j*num_gradient + index)*plane_size, buf_image.begin()+(j*num_gradient + index+1)*plane_size, new_file->image.begin()+j*plane_size); // Philips use neurology convention. Now changes it to radiology image::flip_x(new_file->image); new_file->file_name = file_name; std::ostringstream out; out << index; new_file->file_name += out.str(); dicom_header.get_voxel_size(new_file->voxel_size); dwi_files.push_back(new_file.release()); } } return true; }
void set(const string& id, const char* value) { strings.push_back(new string(value)); values[id] = strings[strings.size()-1]; }