Beispiel #1
0
//
// evaluate
//
Value * RoleName_Method::evaluate (Ocl_Context & res, 
                                   GAME::Mga::Object caller)
{
	GAME::Mga::FCO nar = GAME::Mga::FCO::_narrow (caller);
	std::string name = nar->role ()->name ();
	return new String_Value (name);
}
Beispiel #2
0
//
// evaluate
//
Value * IsType_Method::evaluate (Ocl_Context & res, GAME::Mga::Object caller)
{
  GAME::Mga::FCO obj = GAME::Mga::FCO::_narrow (caller);

  // Checking if the invoking object is a subtype
  bool type = obj->is_subtype ();
  return new Boolean_Value (type);
}
Beispiel #3
0
//
// evaluate
//
Value * IsInstance_Method::evaluate (Ocl_Context & res, 
                                     GAME::Mga::Object caller)
{
  GAME::Mga::FCO obj = GAME::Mga::FCO::_narrow (caller);

  bool type = obj->is_instance ();
  
  return new Boolean_Value (type);
	
}
Beispiel #4
0
//
// evaluate
//
Value * ConnectedFCOs_Method::evaluate (Ocl_Context & res,
                                        Value * caller)
{
  Object_Value * iv = dynamic_cast <Object_Value *> (caller);

  if (iv != 0)
  {
    GAME::Mga::Object obj = iv->value ();
    GAME::Mga::FCO fco = GAME::Mga::FCO::_narrow (obj);

    std::vector <GAME::Mga::Connection> conns;

    // Filtering out the connections based on "kind" value
    if (flag == 1 || flag == 3)
      fco->in_connections (conns);
    else if (flag == 2 || flag == 4)
      fco->in_connections (this->kind_, conns);

    std::vector <GAME::Mga::FCO> fcos;
    std::vector <GAME::Mga::Connection>::iterator
      cit = conns.begin (), cit_end = conns.end ();

    // Get all the connected fcos on the other end of this fco
    // based on the "role" values
    for (; cit != cit_end; ++cit)
    {
      if (flag == 1 || flag == 2)
      {
        if ((*cit)->src ()->name () == fco->name ())
          fcos.push_back ((*cit)->dst ());
        else if ((*cit)->dst ()->name () == fco->name ())
          fcos.push_back ((*cit)->src ());
      }
      else if (flag == 3 || flag == 4)
      {
        if (this->role_ == "src")
          fcos.push_back ((*cit)->src ());
        else if (this->role_ == "dst")
          fcos.push_back ((*cit)->dst ());
      }
    }
    return new Collection_Value_T <GAME::Mga::FCO> (fcos);
  }
  else
  {
    std::vector <GAME::Mga::FCO> fcos;
    return new Collection_Value_T <GAME::Mga::FCO> (fcos);
  }
}
Beispiel #5
0
//
// evaluate
//
Value * RoleName_Method::evaluate (Ocl_Context & res, 
                                   Value * caller)
{
	Object_Value * iv = dynamic_cast <Object_Value *> (caller);
	std::string name = "";

	if (iv != 0)
	{
		GAME::Mga::Object obj = iv->value ();
		GAME::Mga::FCO nar = GAME::Mga::FCO::_narrow (obj);
		name = nar->role ()->name ();
	}

	return new String_Value (name);
}
Beispiel #6
0
//
// evaluate
//
Value * IsType_Method::evaluate (Ocl_Context & res, Value * caller)
{
  Object_Value * iv = dynamic_cast <Object_Value *> (caller);
  bool type = false;

  if (iv != 0)
  {
    GAME::Mga::Object val = iv->value ();
    GAME::Mga::FCO obj = GAME::Mga::FCO::_narrow (caller);

    // Checking if the invoking object is a subtype
    type = obj->is_subtype ();
  }

  return new Boolean_Value (type);
}
Beispiel #7
0
//
// evaluate
//
Value * IsInstance_Method::evaluate (Ocl_Context & res, 
                                     Value * caller)
{
  Object_Value * iv = dynamic_cast <Object_Value *> (caller);

  bool type = false;
  
	if (iv != 0)
	{
		GAME::Mga::Object val = iv->value ();
    GAME::Mga::FCO obj = GAME::Mga::FCO::_narrow (caller);

    type = obj->is_instance ();
  }
 
  return new Boolean_Value (type);
}
Beispiel #8
0
  GAME::Mga::Connection get_opposite_end (GAME::Mga::Connection_in conn)
  {
    const std::string provided_role = conn->meta ()->name ();
    const std::string desired_role = (provided_role == "SourceToConnector" ? "ConnectorToDestination" : "SourceToConnector");

    // Get the connector from the provided connection
    GAME::Mga::FCO connector;
    if (provided_role == "SourceToConnector")
      connector = conn->dst ();
    else
      connector = conn->src ();

    // Get the opposite side of the connector
    std::vector <GAME::Mga::Connection> opposite_end;
    connector->in_connections (desired_role, opposite_end);

    return opposite_end.front ();
  }
Beispiel #9
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;
}
//
// handle_object_created
//
int CBML_Connection_Generation_Handler::
handle_object_created (GAME::Mga::Object_in obj)
{
  if (this->is_importing_)
    return 0;

  GAME::Mga::FCO fco = GAME::Mga::FCO::_narrow (obj);

  // This event handler only works with non-instance elements.
  if (fco->is_instance ())
    return 0;

  const std::string metaname = obj->meta ()->name ();

  if (metaname == meta::Action ||
      metaname == meta::RequestAction ||
      metaname == meta::OutputAction ||
      metaname == meta::QueryAction ||
      metaname == meta::CallAction)
  {
    this->create_state_and_connect (fco, "Effect");
  }
  else if (metaname == meta::InputAction ||
           metaname == meta::MultiInputAction)
  {
    // We need to make sure there is not an active state selected
    // before continuing. This is because we are starting a new
    // workflow in the behavior.
    if (!this->active_state_.is_nil ())
      this->active_state_ = 0;

    this->create_state_and_connect (fco, "InputEffect");
  }
  else if (0 == this->state_transition_map_.find (metaname.c_str ()))
  {
    this->active_state_ = fco;
  }

  return 0;
}
Beispiel #11
0
//
// handle_object_created
//
int Containment_Check_Handler::handle_object_select (GAME::Mga::Object_in obj)
{
  if (this->is_importing_)
    return 0;

  // Make sure that we are timing the model creation process. We do it
  // here and not in Timer_Handler since this handler is called before
  // the Timer_Handler.
  Model_Stats * stats = MODEL_STATS::instance ();

  if (!stats->is_timing ())
    stats->start_timing ();

  GAME::Mga::FCO fco = GAME::Mga::FCO::_narrow (obj);

  Ocl_Context res;

  // Setting the model and current working object
  // in Model_Intelligence_Features
  res.self = fco->parent_model ();
  res.model_object = fco->parent_model ();
  res.checker = true;
  res.model_constraint = false;
  res.model_attributes = false;

  // Collecting all constraints on the parent model of entered object
  std::vector <GAME::Mga::Meta::Constraint> cs;
  res.model_object->meta ()->constraints (cs);

  std::vector <std::string> all_cardinalities;

  for (const auto & item : cs)
    all_cardinalities.push_back (item->expression ());

  // Iterating over all the cardinalities one by one so as to
  // parse and evaluate them to generate a list of actions
  std::vector <std::string>::const_iterator
    iter = all_cardinalities.begin (), iter_end = all_cardinalities.end ();

  for (; iter != iter_end; ++ iter)
  {
    //reseting the constraint specific variables
    res.target_metaroles.clear ();
    res.locals.clear ();

    std::vector <Boolean_Expr *> ocl;
    OCL_Expr_Parser parser;

    // Checking if the constraint exists in cache
    bool exists = false;

    for (const auto & cached_item : this->cache_)
    {
      if ((*iter) == cached_item.first)
      {
        ocl = cached_item.second;
        exists = true;
        break;
      }
    }

    if (!exists)
    {
      // Parsing the constraint string
      parser.parse_string ((*iter), ocl);
      this->cache_[*iter] = ocl;
    }

    std::vector <Boolean_Expr *>::iterator
      cont = ocl.begin (), cont_end = ocl.end ();

    int counter = 0;

    // Checking if the constraint is containment constraint
    for (; cont != cont_end; ++cont)
    {
      if ((*cont)->is_containment ())
        counter++;
    }

    if (counter == ocl.size ())
    {
      std::vector <Boolean_Expr *>::iterator
        c = ocl.begin (), c_end = ocl.end ();

      for (; c != c_end; ++c)
        (*c)->evaluate (res);
    }
  }

  return 0;

}
 bool operator () (const GAME::Mga::FCO & fco) const
 {
   GAME::Mga::Model parent = fco->parent ();
   return parent->name () == "Connector_T";
 }
Beispiel #13
0
  //
  // visit_Connection
  //
  void visit_Connection (GAME::Mga::Connection_in item)
  {
    const std::string metaname = item->meta ()->name ();

    if (metaname == "SourceToConnector")
    {
      // Store the role name, then visit the connector.
      this->role_name_ = item->attribute ("srcRolename")->string_value ();
      GAME::Mga::Connection opposite_end = this->get_opposite_end (item);
      this->get_cardinality (opposite_end);
      item->dst ()->accept (this);
    }
    else if (metaname == "ConnectorToDestination")
    {
      // Store the role name, then visit the connector.
      this->role_name_ = item->attribute ("dstRolename")->string_value ();
      GAME::Mga::Connection opposite_end = this->get_opposite_end (item);
      this->get_cardinality (opposite_end);
      item->src ()->accept (this);
    }
    else if (metaname == "AssociationClass")
    {
      GAME::Mga::FCO src = item->src ();
      while (src->type () == OBJTYPE_REFERENCE)
        src = GAME::Mga::Reference::_narrow (src)->refers_to ();

      const std::string src_metaname = src->meta ()->name ();

      if (src_metaname == "Connector")
      {
        GAME::Mga::FCO dst = item->dst ();

        while (dst->type () == OBJTYPE_REFERENCE)
          dst = GAME::Mga::Reference::_narrow (dst)->refers_to ();

        Object_Class_Definition * definition =
          OBJECT_MANAGER->get (GAME::Mga::Atom::_narrow (dst));

        FCO_Class_Definition  * fco_definition =
          dynamic_cast <FCO_Class_Definition *> (definition);

        assert (0 != fco_definition);
        this->points_.insert (ConnPoint_Info (this->role_name_,
                                              fco_definition,
                                              this->min_cardinality_,
                                              this->max_cardinality_));

        this->includes_.insert (fco_definition);
      }
      else
      {
        Object_Class_Definition * definition =
          OBJECT_MANAGER->get (GAME::Mga::Atom::_narrow (src));

        FCO_Class_Definition  * fco_definition =
          dynamic_cast <FCO_Class_Definition *> (definition);

        assert (0 != fco_definition);
        this->points_.insert (ConnPoint_Info (this->role_name_,
                                              fco_definition,
                                              this->min_cardinality_,
                                              this->max_cardinality_));

        this->includes_.insert (fco_definition);
      }
    }
  }