Beispiel #1
0
//
// 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;
}
Beispiel #2
0
//
// 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);


}
//
// create_state_and_connect
//
void CBML_Connection_Generation_Handler::
create_state_and_connect (GAME::Mga::FCO_in action, const std::string & effect_type)
{
  // Update the connection routing information.
  GAME::Mga::Point position;
  action->registry_value (PREF_AUTOROUTER, PREF_AUTOROUTER_ALL);
  GAME::Mga::Model parent = action->parent_model ();

  if (!this->active_state_.is_nil ())
  {
    // Align newly created action with previous state.
    GAME::Mga::get_position ("Behavior", this->active_state_, position);
    position.shift (OFFSET_X, OFFSET_Y);
    GAME::Mga::set_position ("Behavior", position, action);

    // Create connection between active state and new action.
    std::string transition_metaname;
    GAME::Mga::Meta::FCO metafco = this->active_state_->meta ();

    int retval =
      this->state_transition_map_.find (metafco->name ().c_str (),
                                        transition_metaname);

    if (retval == 0)
    {
      GAME::Mga::Connection transition =
        GAME::Mga::Connection_Impl::_create (parent,
                                             transition_metaname,
                                             this->active_state_,
                                             action);
    }
  }

  // Create the new State element for the action.
  GAME::Mga::Atom state = GAME::Mga::Atom_Impl::_create (parent, "State");
  state->registry_value (PREF_AUTOROUTER, PREF_AUTOROUTER_ALL);

  // Create the effect connection from the action to the state.
  GAME::Mga::Connection effect =
    GAME::Mga::Connection_Impl::_create (parent,
                                         effect_type,
                                         action,
                                         state);

  // Use the action's position if there is no active state.
  if (this->active_state_.is_nil ())
    GAME::Mga::get_position ("Behavior", action, position);

  // Align the <state> to the right of the <action>.
  position.shift (OFFSET_X, -OFFSET_Y);
  GAME::Mga::set_position ("Behavior", position, state);
}
Beispiel #4
0
//
// list delete
//
bool Lesser_Expr::list_delete (GAME::Mga::Model & obj, 
                               size_t count, 
                               GAME::Mga::Meta::FCO & metatype, 
                               GAME::Mga::Meta::Role & metarole)
{
    std::vector <GAME::Mga::FCO> elements;
  GAME::Mga::FCO select;
  obj->children (elements);

   std::vector <GAME::Mga::FCO> qual_fcos;

  std::vector <GAME::Mga::FCO>::iterator
    it = elements.begin (), it_end = elements.end ();

  for (; it != it_end; ++it)
  {
    if ((*it)->meta ()->name () == metatype->name ())
      qual_fcos.push_back ((*it));
  }

  for (size_t i = 0; i < count; ++i)
  {
    AFX_MANAGE_STATE (::AfxGetStaticModuleState ());
    // Create the dialog and pass in the data
    using GAME::Dialogs::Selection_List_Dialog_T;
    Selection_List_Dialog_T <GAME::Mga::FCO> dlg (0, ::AfxGetMainWnd (), 0);
    dlg.title ("Please select the Model/Atom for deletion");
    dlg.directions ("Target evaluator");
    dlg.insert (qual_fcos);

    if (IDOK != dlg.DoModal ())
      return false;

    select = dlg.selection ();

    if (!select.is_nil ())
    {
      select->destroy ();
    }
  }
  return true;
}