BOOST_FOREACH(std::string k, order) { if (context_exists(k)) { get_logger()->debug("settings", __FILE__, __LINE__, "Activating: " + k); set_instance(k); return; } }
Pulsar::PhaseVsPlot::Interface::Interface (PhaseVsPlot* instance) { if (instance) set_instance (instance); // import the interface of the base class import( PhasePlot::Interface() ); add( &PhaseVsPlot::get_rows, &PhaseVsPlot::set_rows, "rows", "Select rows to be plotted"); import( "z", PlotScale::Interface(), &PhaseVsPlot::get_z_scale ); add( &PhaseVsPlot::get_style, &PhaseVsPlot::set_style, "style", "Plot style: image or line"); add( &PhaseVsPlot::get_crop, &PhaseVsPlot::set_crop, "crop", "Crop the data at this percentage of max" ); import("cmap", pgplot::ColourMap::Interface(), &PhaseVsPlot::get_colour_map); }
Pulsar::MultiPhase::Interface::Interface (MultiPhase* instance) { if (instance) set_instance (instance); import( "x", PhaseScale::Interface(), &MultiPhase::get_scale ); }
Pulsar::PlotLabel::Interface::Interface (PlotLabel* instance) { if (instance) set_instance (instance); add( &PlotLabel::get_left, &PlotLabel::set_left, "l", "Top left frame label" ); add( &PlotLabel::get_centre, &PlotLabel::set_centre, "c", "Top centre frame label" ); add( &PlotLabel::get_right, &PlotLabel::set_right, "r", "Top right frame label" ); add( &PlotLabel::get_offset, &PlotLabel::set_offset, "off", "Character height between label and frame" ); add( &PlotLabel::get_spacing, &PlotLabel::set_spacing, "sep", "Character height between label rows" ); }
Pulsar::StokesFluctPlot::Interface::Interface (StokesFluctPlot* instance) { if (instance) set_instance (instance); import ( FluctPlot::Interface() ); remove ("pol"); add( &StokesFluctPlot::get_plot_last_harmonic, &StokesFluctPlot::set_plot_last_harmonic, "last", "Plot the last harmonic marker" ); add( &StokesFluctPlot::get_plot_values, &StokesFluctPlot::set_plot_values, "val", "Values to be plotted (IQUVLpS)" ); add( &StokesFluctPlot::get_plot_colours, &StokesFluctPlot::set_plot_colours, "sci", "PGPLOT colour index for each value" ); add( &StokesFluctPlot::get_plot_lines, &StokesFluctPlot::set_plot_lines, "sls", "PGPLOT line style for each value" ); }
Pulsar::CalibratorSpectrum::Interface::Interface (CalibratorSpectrum* instance) { if (instance) set_instance (instance); add( &CalibratorSpectrum::get_subint, &CalibratorSpectrum::set_subint, "subint", "Sub-integration to plot" ); add( &CalibratorSpectrum::get_plot_Ip, &CalibratorSpectrum::set_plot_Ip, "Ip", "Plot total and polarized intensities" ); add( &CalibratorSpectrum::get_plot_total, &CalibratorSpectrum::set_plot_total, "sum", "Plot sum of on- and off-pulse fluxes" ); add( &CalibratorSpectrum::get_plot_low, &CalibratorSpectrum::set_plot_low, "off", "Plot off-pulse flux" ); add( &CalibratorSpectrum::get_norm_inv, &CalibratorSpectrum::set_norm_inv, "norm", "Normalize Stokes parameters by invariant" ); }
Pulsar::StokesPlot::Interface::Interface (StokesPlot* instance) { if (instance) set_instance (instance); import ( FluxPlot::Interface() ); remove ("pol"); add( &StokesPlot::get_plot_values, &StokesPlot::set_plot_values, "val", "Values to be plotted (IQUVLp)" ); add( &StokesPlot::get_plot_colours, &StokesPlot::set_plot_colours, "ci", "PGPLOT colour index for each value" ); add( &StokesPlot::get_plot_lines, &StokesPlot::set_plot_lines, "ls", "PGPLOT line style for each value" ); add( &StokesPlot::get_plot_widths, &StokesPlot::set_plot_widths, "lw", "PGPLOT line width for each value" ); add( &StokesPlot::get_pav_bias, &StokesPlot::set_pav_bias, "pav", "Handle bias as done in pav" ); }
void set_animation(AnimationInstance** animInst, int anim_type) { if ((*animInst) == NULL) { (*animInst) = malloc(sizeof(**animInst)); } switch(anim_type) { case ANM_NONE: break; case ANM_GAS_BALL: set_instance(anm_gas_ball, (*animInst)); break; case ANM_PUNCH: set_instance(anm_hand_punch, (*animInst)); break; } }
Pulsar::PlotEdge::Interface::Interface (PlotEdge* instance) { if (instance) set_instance (instance); add( &PlotEdge::get_viewport, &PlotEdge::set_viewport, "view", "Viewport (normalized device coordinates)" ); }
Pulsar::ProfilePlot::Interface::Interface (ProfilePlot* instance) { if (instance) set_instance (instance); import ( FluxPlot::Interface() ); add( &ProfilePlot::get_plot_cal_transitions, &ProfilePlot::set_plot_cal_transitions, "cal", "Plot cal transitions (when applicable)" ); }
Pulsar::ProfilePlot::Interface::Interface (ProfilePlot* instance) { if (instance) set_instance (instance); import ( FluxPlot::Interface() ); import ( "pen", PlotPen::Interface(), &ProfilePlot::get_pen ); add( &ProfilePlot::get_plot_cal_transitions, &ProfilePlot::set_plot_cal_transitions, "cal", "Plot cal transitions (when applicable)" ); add( &ProfilePlot::get_outlier_threshold, &ProfilePlot::set_outlier_threshold, "cut", "Threshold used to reject cal level outliers" ); }
static int py_ue_ffoliage_instance_set_rotation(ue_PyFFoliageInstance *self, PyObject *value, void *closure) { set_instance(self); if (value) { ue_PyFRotator *rot = py_ue_is_frotator(value); if (rot) { TArray<int32> instances; instances.Add(self->instance_id); FFoliageMeshInfo& info = self->foliage_actor->FoliageMeshes[self->foliage_type.Get()].Get(); info.PreMoveInstances(self->foliage_actor.Get(), instances); instance->Rotation = rot->rot; info.PostMoveInstances(self->foliage_actor.Get(), instances); return 0; } } PyErr_SetString(PyExc_TypeError, "value is not an FRotator"); return -1; }
/** * Creates new "main" branch by making copy of branch-failure branch. * Currently the following branch attributes are included: * request-uri, ruid, path, instance, and branch flags. */ static int w_t_reuse_branch(sip_msg_t* msg, char *p1, char *p2) { tm_cell_t *t; int branch; if (msg == NULL) return -1; /* first get the transaction */ if (_tmx_tmb.t_check(msg, 0) == -1) return -1; if ((t = _tmx_tmb.t_gett()) == 0) { LM_ERR("no transaction\n"); return -1; } switch (get_route_type()) { case BRANCH_FAILURE_ROUTE: /* use the reason of the winning reply */ if ((branch = _tmx_tmb.t_get_picked_branch()) < 0) { LM_CRIT("no picked branch (%d) for a final response" " in MODE_ONFAILURE\n", branch); return -1; } if(rewrite_uri(msg, &(t->uac[branch].uri))<0) { LM_WARN("failed to rewrite the r-uri\n"); } set_ruid(msg, &(t->uac[branch].ruid)); if (t->uac[branch].path.len) { if(set_path_vector(msg, &(t->uac[branch].path))<0) { LM_WARN("failed to set the path vector\n"); } } else { reset_path_vector(msg); } setbflagsval(0, t->uac[branch].branch_flags); set_instance(msg, &(t->uac[branch].instance)); return 1; default: LM_ERR("unsupported route_type %d\n", get_route_type()); return -1; } }
Pulsar::DynamicSpectrumPlot::Interface::Interface ( DynamicSpectrumPlot* instance) { if (instance) set_instance (instance); add( &DynamicSpectrumPlot::get_srange, &DynamicSpectrumPlot::set_srange, "srange", "Range of subints to plot" ); add( &DynamicSpectrumPlot::get_pol, &DynamicSpectrumPlot::set_pol, "pol", "Polarization to plot" ); add( &DynamicSpectrumPlot::get_method, &DynamicSpectrumPlot::set_method, "method", "Method to use" ); import("cmap", pgplot::ColourMap::Interface(), &DynamicSpectrumPlot::get_colour_map); }
pgplot::ColourMap::Interface::Interface (ColourMap* instance) { if (instance) set_instance (instance); add( &ColourMap::get_name, &ColourMap::set_name, "map", "Name of colour map" ); add( &ColourMap::get_brightness, &ColourMap::set_brightness, "bri", "Brightness" ); add( &ColourMap::get_contrast, &ColourMap::set_contrast, "con", "Contrast" ); add( &ColourMap::get_logarithmic, &ColourMap::set_logarithmic, "log", "Use logarithmic transfer function" ); }
int BEE::Room::add_instance(int index, Object* object, int x, int y) { InstanceData* new_instance = new InstanceData(game, index, object, x, y); if (index < 0) { index = next_instance_id++; new_instance->id = index; } set_instance(index, new_instance); object->game = game; object->add_instance(index, new_instance); int r = collision_tree->insert(new_instance); if (r == 1) { expand_collision_tree(x, y); } else if (r == 2) { collision_tree->set_capacity(collision_tree->max_capacity*2); collision_tree->combine(); } if (r != 0) { if (collision_tree->insert(new_instance) != 0) { std::cerr << "Failed to add " << new_instance->object->get_name() << " with id " << new_instance->id << " to the collision tree: error " << r << "\n"; //new_instance->print(); } } if (object->get_sprite() != NULL) { if (!object->get_sprite()->get_is_loaded()) { std::cerr << "Automatically loading the sprite for object " << object->get_name() << "\n"; object->get_sprite()->load(); //std::cerr << "An instance of " << object->get_name() << " has been created but its sprite has not been loaded\n"; } } if (game->get_is_ready()) { new_instance->object->create(new_instance); } return index; }
Pulsar::PlotScale::Interface::Interface (PlotScale* instance) { if (instance) set_instance (instance); import( PlotEdge::Interface() ); add( &PlotScale::get_world, &PlotScale::set_world, "win", "World coordinate range inside viewport" ); add( &PlotScale::get_world_external, &PlotScale::set_world_external, "wout", "World coordinate range outside viewport" ); add( &PlotScale::get_range_norm, &PlotScale::set_range_norm, "range", "World-normalized range inside viewport" ); add( &PlotScale::get_buf_norm, &PlotScale::set_buf_norm, "buf", "World-normalized buffer space" ); }
int main( int argc, char *argv[] ) { command_options options; bool ret = parse_arguments( argc, argv, &options ); if ( !ret ) { usage(); exit( EXIT_FAILURE ); } init_log( basename( argv[ 0 ] ), LOG_OUTPUT_STDOUT ); init_vxlan_ctrl_client(); uint8_t status = SUCCEEDED; ret = false; switch ( options.type ) { case ADD_INSTANCE_REQUEST: { ret = add_instance( options.vni, options.ip_addr, options.port, options.aging_time, &status ); } break; case SET_INSTANCE_REQUEST: { ret = set_instance( options.vni, options.set_bitmap, options.ip_addr, options.port, options.aging_time, &status ); } break; case INACTIVATE_INSTANCE_REQUEST: { ret = inactivate_instance( options.vni, &status ); } break; case ACTIVATE_INSTANCE_REQUEST: { ret = activate_instance( options.vni, &status ); } break; case DEL_INSTANCE_REQUEST: { ret = delete_instance( options.vni, &status ); } break; case SHOW_GLOBAL_REQUEST: { ret = show_global( options.set_bitmap, &status ); } break; case LIST_INSTANCES_REQUEST: { ret = list_instances( options.vni, options.set_bitmap, &status ); } break; case SHOW_FDB_REQUEST: { ret = show_fdb( options.vni, &status ); } break; case ADD_FDB_ENTRY_REQUEST: { ret = add_fdb_entry( options.vni, options.eth_addr, options.ip_addr, options.aging_time, &status ); } break; case DEL_FDB_ENTRY_REQUEST: { ret = delete_fdb_entry( options.vni, options.eth_addr, &status ); } break; default: { printf( "Undefined command ( %#x ).\n", options.type ); status = OTHER_ERROR; ret = false; } break; } if ( !ret ) { printf( "Failed to execute a command ( %u ).\n", status ); } finalize_vxlan_ctrl_client(); finalize_log(); return status; }
int sbranch_set_ruri(sip_msg_t *msg) { str sv; flag_t old_bflags; branch_t *br; int ret; ret = 0; br = &_pv_sbranch; if(br->len==0) return -1; sv.s = br->uri; sv.len = br->len; if (rewrite_uri(msg, &sv) < 0) { LM_ERR("unable to rewrite Request-URI\n"); ret = -3; goto error; } /* reset next hop address */ reset_dst_uri(msg); if(br->dst_uri_len>0) { sv.s = br->dst_uri; sv.len = br->dst_uri_len; if (set_dst_uri(msg, &sv) < 0) { ret = -3; goto error; } } reset_path_vector(msg); if(br->path_len==0) { sv.s = br->path; sv.len = br->path_len; if(set_path_vector(msg, &sv) < 0) { ret = -4; goto error; } } reset_instance(msg); if (br->instance_len) { sv.s = br->instance; sv.len = br->instance_len; if (set_instance(msg, &sv) < 0) { ret = -5; goto error; } } reset_ruid(msg); if (br->ruid_len) { sv.s = br->ruid; sv.len = br->ruid_len; if (set_ruid(msg, &sv) < 0) { ret = -6; goto error; } } reset_ua(msg); if (br->location_ua_len) { sv.s = br->location_ua; sv.len = br->location_ua_len; if (set_ua(msg, &sv) < 0) { ret = -7; goto error; } } if (br->force_send_socket) set_force_socket(msg, br->force_send_socket); msg->reg_id = br->reg_id; set_ruri_q(br->q); old_bflags = 0; getbflagsval(0, &old_bflags); setbflagsval(0, old_bflags|br->flags); return 0; error: return ret; }
/// Set the instance of this vote_id_type vote_id_type& operator =(uint32_t instance) { set_instance(instance); return *this; }
/*! \brief * Lookup contact in the database and rewrite Request-URI * \return: -1 : not found * -2 : found but method not allowed * -3 : error */ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri) { urecord_t* r; str aor, uri; sip_uri_t puri; ucontact_t* ptr = 0; int res; int ret; str path_dst; flag_t old_bflags; int i; str inst = {0}; unsigned int ahash = 0; sr_xavp_t *xavp=NULL; sr_xavp_t *list=NULL; str xname = {"ruid", 4}; sr_xval_t xval; ret = -1; if (_m->new_uri.s) uri = _m->new_uri; else uri = _m->first_line.u.request.uri; if (extract_aor((_uri)?_uri:&uri, &aor, &puri) < 0) { LM_ERR("failed to extract address of record\n"); return -3; } /* check if gruu */ if(puri.gr.s!=NULL) { if(puri.gr_val.len>0) { /* pub-gruu */ inst = puri.gr_val; LM_DBG("looking up pub gruu [%.*s]\n", inst.len, inst.s); } else { /* temp-gruu */ ahash = 0; inst = puri.user; for(i=inst.len-1; i>=0; i--) { if(inst.s[i]==REG_GRUU_SEP) break; ahash <<= 4; if(inst.s[i] >='0' && inst.s[i] <='9') ahash+=inst.s[i] -'0'; else if (inst.s[i] >='a' && inst.s[i] <='f') ahash+=inst.s[i] -'a'+10; else if (inst.s[i] >='A' && inst.s[i] <='F') ahash+=inst.s[i] -'A'+10; else { LM_ERR("failed to extract temp gruu - invalid hash\n"); return -3; } } if(i<0) { LM_ERR("failed to extract temp gruu - invalid format\n"); return -3; } inst.len = i; LM_DBG("looking up temp gruu [%u / %.*s]\n", ahash, inst.len, inst.s); } } get_act_time(); if(puri.gr.s==NULL || puri.gr_val.len>0) { /* aor or pub-gruu lookup */ ul.lock_udomain(_d, &aor); res = ul.get_urecord(_d, &aor, &r); if (res > 0) { LM_DBG("'%.*s' Not found in usrloc\n", aor.len, ZSW(aor.s)); ul.unlock_udomain(_d, &aor); return -1; } ptr = r->contacts; ret = -1; /* look first for an un-expired and suported contact */ while (ptr) { if(VALID_CONTACT(ptr,act_time)) { if(allowed_method(_m,ptr)) { /* match on instance, if pub-gruu */ if(inst.len>0) { if(reg_cmp_instances(&inst, &ptr->instance)==0) { /* pub-gruu - found by instance */ LM_DBG("contact for [%.*s] found by pub gruu [%.*s]\n", aor.len, ZSW(aor.s), inst.len, inst.s); break; } } else { /* no-gruu - found by address */ LM_DBG("contact for [%.*s] found by address\n", aor.len, ZSW(aor.s)); break; } } else { LM_DBG("contact for [%.*s] cannot handle the SIP method\n", aor.len, ZSW(aor.s)); ret = -2; } } ptr = ptr->next; } if (ptr==0) { /* nothing found */ LM_DBG("'%.*s' has no valid contact in usrloc\n", aor.len, ZSW(aor.s)); goto done; } } else { /* temp-gruu lookup */ res = ul.get_urecord_by_ruid(_d, ahash, &inst, &r, &ptr); if(res<0) { LM_DBG("temp gruu '%.*s' not found in usrloc\n", aor.len, ZSW(aor.s)); return -1; } aor = *ptr->aor; /* test if un-expired and suported contact */ if( (ptr) && !(VALID_CONTACT(ptr,act_time) && (ret=-2) && allowed_method(_m,ptr))) goto done; LM_DBG("contact for [%.*s] found by temp gruu [%.*s / %u]\n", aor.len, ZSW(aor.s), inst.len, inst.s, ahash); } ret = 1; if (ptr) { if (rewrite_uri(_m, &ptr->c) < 0) { LM_ERR("unable to rewrite Request-URI\n"); ret = -3; goto done; } /* reset next hop address */ reset_dst_uri(_m); /* add xavp with details of the record (ruid, ...) */ if(reg_xavp_rcd.s!=NULL) { list = xavp_get(®_xavp_rcd, NULL); xavp = list; memset(&xval, 0, sizeof(sr_xval_t)); xval.type = SR_XTYPE_STR; xval.v.s = ptr->ruid; xavp_add_value(&xname, &xval, &xavp); if(list==NULL) { /* no reg_xavp_rcd xavp in root list - add it */ xval.type = SR_XTYPE_XAVP; xval.v.xavp = xavp; xavp_add_value(®_xavp_rcd, &xval, NULL); } } /* If a Path is present, use first path-uri in favour of * received-uri because in that case the last hop towards the uac * has to handle NAT. - agranig */ if (ptr->path.s && ptr->path.len) { if (get_path_dst_uri(&ptr->path, &path_dst) < 0) { LM_ERR("failed to get dst_uri for Path\n"); ret = -3; goto done; } if (set_path_vector(_m, &ptr->path) < 0) { LM_ERR("failed to set path vector\n"); ret = -3; goto done; } if (set_dst_uri(_m, &path_dst) < 0) { LM_ERR("failed to set dst_uri of Path\n"); ret = -3; goto done; } } else if (ptr->received.s && ptr->received.len) { if (set_dst_uri(_m, &ptr->received) < 0) { ret = -3; goto done; } } if (ptr->instance.len) { if (set_instance(_m, &(ptr->instance)) < 0) { ret = -3; goto done; } } _m->reg_id = ptr->reg_id; if (ptr->ruid.len) { if (set_ruid(_m, &(ptr->ruid)) < 0) { ret = -3; goto done; } } if (ptr->user_agent.len) { if (set_ua(_m, &(ptr->user_agent)) < 0) { ret = -3; goto done; } } set_ruri_q(ptr->q); old_bflags = 0; getbflagsval(0, &old_bflags); setbflagsval(0, old_bflags|ptr->cflags); if (ptr->sock) set_force_socket(_m, ptr->sock); if(ptr->xavp!=NULL) { xavp = xavp_clone_level_nodata(ptr->xavp); if(xavp_add(xavp, NULL)<0) { ret = -3; goto done; } } ptr = ptr->next; } /* if was gruu, no more branches */ if(inst.len>0) goto done; /* Append branches if enabled */ if (!cfg_get(registrar, registrar_cfg, append_branches)) goto done; for( ; ptr ; ptr = ptr->next ) { if (VALID_CONTACT(ptr, act_time) && allowed_method(_m, ptr)) { path_dst.len = 0; if(ptr->path.s && ptr->path.len && get_path_dst_uri(&ptr->path, &path_dst) < 0) { LM_ERR("failed to get dst_uri for Path\n"); continue; } /* The same as for the first contact applies for branches * regarding path vs. received. */ LM_DBG("instance is %.*s\n", ptr->instance.len, ptr->instance.s); if (append_branch(_m, &ptr->c, path_dst.len?&path_dst:&ptr->received, &ptr->path, ptr->q, ptr->cflags, ptr->sock, ptr->instance.len?&(ptr->instance):0, ptr->instance.len?ptr->reg_id:0, &ptr->ruid, &ptr->user_agent) == -1) { LM_ERR("failed to append a branch\n"); /* Also give a chance to the next branches*/ continue; } if(ptr->xavp!=NULL) { xavp = xavp_clone_level_nodata(ptr->xavp); if(xavp_insert(xavp, nr_branches, NULL)<0) { ret = -3; goto done; } } } } done: ul.release_urecord(r); ul.unlock_udomain(_d, &aor); return ret; }