int vsx_engine_param_list::order(vsx_string param, vsx_string new_order)
{
  vsx_engine_param* my_param = get_by_name(param);

  if (!my_param)
    return -2;

  // 0. parse the new_order string that our nice client sent us
  vsx_string deli = ",";
  std::vector<int> order_list;
  std::vector<vsx_string> order_source;
  explode(new_order, deli, order_source);

  // 1. Re-order our own little connection list
  std::vector<vsx_engine_param_connection*> new_connection_list;
  for (std::vector<vsx_string>::iterator it = order_source.begin(); it != order_source.end(); ++it)
  {
    new_connection_list.push_back(my_param->connections[ vsx_string_helper::s2i(*it) ]);
  }
  my_param->connections = new_connection_list;

  // 2. recurse to find the new connection id order
  std::vector<int> new_channel_order;
  my_param->alias_owner->rebuild_orders(&new_channel_order);

  // 3. tell channel to rebuild with new list
  my_param->alias_owner->channel->connections_order(&new_channel_order);
  return 1;

}
Example #2
0
bool Row::get_string_by_name(const StringRef& name, std::string* out) const {
  const Value* value = get_by_name(name);
  if (value == NULL ||
      value->size() < 0) {
    return false;
  }
  out->assign(value->data(), value->size());
  return true;
}
Example #3
0
bool join_point_base::remove(const char* name)
{
    auto e0 = get_by_name(name);
    if (e0 == nullptr)
    {
        dassert (false, "cannot find advice with name '%s' in '%s'", name, _name.c_str());
        return false;
    }

    e0->next->prev = e0->prev;
    e0->prev->next = e0->next;

    return true;
}
bool vsx_engine_param_list::unalias(vsx_string name)
{
  vsx_engine_param* param = get_by_name(name);
  if (param) {
    if (param->alias)
    if (param->alias_parent != param)
    param->alias_parent->delete_conn(param->alias_parent->get_conn_by_dest(param));

    param->disconnect();
    param->unalias();

    delete_param(param);
  } else return false;
  return true;
}
action * action_list::get_by_name_label (const char *name, const char *label)
{
  // gets all the actions whose name is "name"
  action_list *al = get_by_name(name);
  // search between them wich one has label "label"
  iterator i=al->find(label);
  // return value
  action * a=NULL;
  if (i!=al->end())
    // found
    a=(*i).second;
  //frees memory
  delete al;
  return a;
}
Example #6
0
bool join_point_base::put_replace(const char* base, void* fn, const char* name)
{
    auto e0 = get_by_name(base);
    if (e0 == nullptr)
    {
        dassert (false, "cannot find advice with name '%s' in '%s'", base, _name.c_str());
        return false;
    }
    else
    {
        e0->func = fn;
        e0->name = name;
        return true;
    }
}
fuzzy_data * fuzzy_data_list::get_by_name_label (const char *name, const char *label)
{
  // gets all the fuzzy_data whose name is "name"
  fuzzy_data_list *fdl = get_by_name(name);
  // search between them wich one has label "label"
  iterator i=fdl->find(label);
  // return value
  fuzzy_data *f=NULL;
  if (i!=fdl->end())
    // found
    f=(*i).second;
  // frees memory
  //Added by mr:030422
  fdl->clear();
  delete fdl;
  return f;
}
Example #8
0
bool join_point_base::put_after(const char* base, void* fn, const char* name, bool is_native)
{
    auto e0 = get_by_name(base);
    if (e0 == nullptr)
    {
        dassert (false, "cannot find advice with name '%s' in '%s'", base, _name.c_str());
        return false;
    }

    auto e = new_entry(fn, name, is_native);

    auto e1 = e0->next;
    e1->prev = e;
    e->prev = e0;
    e0->next = e;
    e->next = e1;
    
    return true;
}
Example #9
0
/* AddBranch
 * Adds a New Branch to the mix. 
 */
int Branches::AddBranch(Branch *B)
{
	if ((*this)[B->ID]) /* ID already exists */
		return -1;
	if (get_by_name(B->Name)) {
		printf("A branch with that name already exists.\n");
		return -1;
	}
	/* Make sure parameters make sense */
	if (!((0 <= B->FreeDecisions)
			&& (B->FreeDecisions <= B->TargetDecisions)
			&& (B->TargetDecisions <= B->MaxDecisions)))
	{
		printf("Free/Target/Max Decisions must be non-negative and increasing\n");
		return -2;
	}
	if (B->BallotTime + B->UnsealTime >= B->VotingPeriod) {
		printf("Irregular overlap in voting periods. Provide longer inter-consensus time, or shorten Ballot / Unseal times.\n");
		return -3;
	}
	ID_to_Branch[B->ID] = B;
	return 0;
}
Example #10
0
 const Object* GetObject(const utf8_string& name) const override{
   return get_by_name(m_image.GetObjects(), name);
 }