Exemplo n.º 1
0
//
//invoke ex
//
int PICML_MPCComponent_Impl::
invoke_ex (GAME::Mga::Project project,
           GAME::Mga::FCO_in focus,
           GAME::Mga::Collection_T <GAME::Mga::FCO> & selected,
           long flags)
{
  GAME::Mga::Readonly_Transaction t (project);

	std::string outputPath;
	std::string message = "Please specify the Output Directory";
	if (! Utils::getPath (message, outputPath))
		return -1;

	bool valid_interpretation = 0;

  if (focus || selected.count ())
  {
    PICML::MPC_Visitor visitor (outputPath);

    for (GAME::Mga::FCO target : selected)
    {
      // dfeiock: FIX - Original code put the selected and focus into a set then interated over them.
      //                Now I am doing selected first then the focus.
      //                not sure if the automatic sorting of the set is required
      if (target->meta ()->name () == PICML::MPC::impl_type::metaname)
      {
        target->accept (&visitor);
        valid_interpretation = 1;
      }
    }

    if (focus && (focus->meta ()->name () == PICML::MPC::impl_type::metaname))
    {
      focus->accept (&visitor);
      valid_interpretation = 1;
    }
  }

	if (!valid_interpretation)
	{
		PICML::RootFolder root_folder = project.root_folder ();

		for (PICML::ComponentBuild component : root_folder->get_ComponentBuild ())
		{
			for (PICML::MPC mpc : component->get_MPCs ())
			{
				PICML::MPC_Visitor visitor (outputPath);
        mpc->accept (&visitor);
				valid_interpretation = 1;
			}
		}
	}

	if (valid_interpretation)
		AfxMessageBox ("MPC Files successfully generated");
	else
		AfxMessageBox ("Interpretation Failure: Either there is no MPC paradigm present and/or \n Selected Object(s) are not MPC definitions");

  return 0;
}
//
// 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);
}
//
// initialize
//
int DeploymentStatusDecorator_Impl::
initialize (const GAME::Mga::Project & project,
            const GAME::Mga::Meta::Part_in part,
            const GAME::Mga::FCO_in fco,
            IMgaCommonDecoratorEvents * sink,
            ULONGLONG window)
{
  if (0 != GAME::Mga::Reference_Decorator::initialize (project, part, fco, sink, window))
    return -1;

  // Get the elements deployment information.

  GAME::Mga::Collection_T <GAME::Mga::Set> sets = fco->in_sets ();

  if (sets.is_empty ())
  {
    // Show the question mark on the image.
    using GAME::Mga::graphics::Image_Resource;
    this->question_.reset (Image_Resource::load (IDB_QUESTION, "PNG"));
  }
  else
  {
    // Save the name of the collocation group.
    GAME::Mga::Set group = sets.first ();
    this->deployment_ = group->name () + "@";

    // Trace the collocation group to its node.
    std::vector <GAME::Mga::Connection> conns;
    if (group->in_connections ("InstanceMapping", conns))
      this->deployment_ += conns[0]->dst ()->name ();
  }

  return 0;
}
Exemplo n.º 4
0
//
// build
//
void Reference_Class_Definition::build (GAME::Mga::FCO_in fco)
{
  // Pass control to the base class.
  FCO_Class_Definition::build (fco);

  std::vector <GAME::Mga::Connection> refers_to_coll;
  fco->in_connections ("ReferTo", refers_to_coll);

  RefersTo_Visitor refers_to_visitor (this);
  for (GAME::Mga::Connection refers_to : refers_to_coll)
    refers_to->accept (&refers_to_visitor);
}
Exemplo n.º 5
0
//
// get_actions
//
void CBML_MultiInput_Handler::
get_actions (GAME::Mga::FCO_in facet, std::vector<GAME::Mga::Object> & actions)
{
  // Get all the MultiInput connections
  std::vector <GAME::Mga::Connection> facet_connections;
  size_t connections = facet->in_connections ("MultiInput", facet_connections);
  std::vector <GAME::Mga::Connection>::iterator iter = facet_connections.begin (),
                                                end = facet_connections.end ();

  // Get each MultiInputAction
  for (; iter != end; ++iter)
  {
    actions.push_back ((*iter)->dst ());
  }
}