コード例 #1
0
ファイル: Lesser_Expr.cpp プロジェクト: SEDS/GAME
//
// list_add
//
bool Lesser_Expr::list_add (GAME::Mga::Model & obj,
                            size_t count, 
                            GAME::Mga::Meta::FCO & metatype, 
                            GAME::Mga::Meta::Role & metarole)
{
  if (metatype->type () == OBJTYPE_MODEL)
    {
      for (; count != 0; -- count)
        {
          GAME::Mga::Model new_model = GAME::Mga::Model_Impl::_create (obj, metarole);
          char c = '0' + count;
          new_model->name (metarole->name () + c);
        }
    }
  else if (metatype->type () == OBJTYPE_ATOM)
    {
      for (; count != 0; -- count)
        {
          GAME::Mga::Atom new_atom = GAME::Mga::Atom_Impl::_create (obj, metarole);
          char c = '0' + count;
          new_atom->name (metarole->name () + c);
        }
    }

  return true;
}
コード例 #2
0
ファイル: ConnectionParts_Method.cpp プロジェクト: SEDS/GAME
//
// evaluate
//
Value * ConnectionParts_Method::evaluate (Ocl_Context &res, GAME::Mga::Object caller)
{
  GAME::Mga::Model mod = GAME::Mga::Model::_narrow (caller);

  std::vector <GAME::Mga::Connection> parts;
  std::vector <std::string> rolenames;
  bool flag = false;

  // Verifying if role_ is a valid containment role
  std::vector <GAME::Mga::Meta::Role> all;
  mod->meta ()->roles (all);
  std::vector <GAME::Mga::Meta::Role>::iterator
    it = all.begin (), ite = all.end ();

  for (; it != ite; ++it)
    rolenames.push_back ((*it)->name ());

  std::vector <std::string>::iterator
    st = rolenames.begin (), ste = rolenames.end ();

  for (; st != ste; ++st)
  {
    if ((*st) == this->role_)
      flag = true;
  }

  // Continue if the role is valid
  if (flag)
  {
    GAME::Mga::Meta::Role target_metarole = mod->meta ()->role (this->role_);

    // Setting the target metarole in the model intelligence context
    // only if it doesn't already exist in the list
    std::vector <GAME::Mga::Meta::Role>::iterator
      roleit = res.target_metaroles.begin (), roleit_end = res.target_metaroles.end ();

    bool exists = false;

    for (; roleit != roleit_end; ++ roleit)
    {
      if ((*roleit)->name () == target_metarole->name ())
        exists = true;
    }

    if (!exists)
      res.target_metaroles.push_back (target_metarole);
  
    GAME::Mga::Meta::FCO temp = target_metarole->kind ();

    // Collecting children only if the type of element is Connection
    if (temp->type () == OBJTYPE_CONNECTION)
      mod->children (temp->name (), parts);
  }

  return new Collection_Value_T <GAME::Mga::Connection> (parts);


}