// // 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); } }
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 (); }