model_server/subsystem/src/Entity.cxx
//
// Given a particular relation and a symbolPtr, we find the symbol's
// entity and then create the reference.  (For historical reasons, the
// rels are "backwards" -- e.g., if entity A calls entity B, this
// routine will be called with A as "this", B as "sym", and
// AUS_FCALL_INV as the rel; the proper way to read this is
// "sym rel this", or "B is called by this".  This made more sense
// with the "relation" implementation; now that we use refs_and_weights,
// we use the inverse rel with "this" and the passed rel with "sym.")
Given a particular relation and a symbolPtr, we find the symbol's
entity and then create the reference.
Given a particular relation and a symbolPtr we find the symbol ' s entity and then create the reference .
void Entity::relate_to_symbol(size_t rel, const symbolPtr& sym) {
  Initialize(Entity::relate_to_symbol);
  Entity *ffar = allentities->item(sym);
  if (ffar && this!=ffar) {
     size_t inv_rel;
     bool outgoing = false;
     if (rel >= NWEIGHTS / 2) {
	inv_rel = rel - NWEIGHTS / 2;
	outgoing = true;
     }
     else inv_rel = rel + NWEIGHTS / 2;
     rw.add_ref(ffar->index(), inv_rel);
     ffar->rw.add_ref(index(), rel);
     if (outgoing) {
	EntityPtr e;
	for (e = ffar->get_preve(); e; e = e->get_preve()) {
	   rw.add_ref(e->index(), inv_rel);
	   e->rw.add_ref(index(), rel);
	}
	for (e = ffar->get_nexte(); e; e = e->get_nexte()) {
	   rw.add_ref(e->index(), inv_rel);
	   e->rw.add_ref(index(), rel);
	}
	if (rel == AUS_FCALL_INV || rel == AUS_DATAREF_INV) {
	   if (!ffar->parent_class && strstr(ffar->my_sym.get_name(), "::")) {
	      symbolPtr parent_sym = ffar->my_sym.get_parent_of(projects_to_search);
	      if (parent_sym.xrisnotnull()) {
		 ffar->parent_class = allentities->item(parent_sym);
	      }
	   }
	   if (ffar->parent_class) {
	      rw.add_ref(ffar->parent_class->index(), AUS_DATAREF);
	      ffar->parent_class->rw.add_ref(index(), AUS_DATAREF_INV);
	   }
	   if (ffar->my_sym.get_kind() == DD_TYPEDEF) {
	      if (!ffar->basetype) {
		 ffar->set_basetype();
	      }
	      if (ffar->basetype != &no_class) {
		 rw.add_ref(ffar->basetype->index(), inv_rel);
		 ffar->basetype->rw.add_ref(index(), rel);
	      }
	   }
	}
     }
  }
}
void Entity :: relate_to_symbol ( size_t rel , const symbolPtr & sym ) { Initialize ( Entity :: relate_to_symbol ) ; Entity * ffar = allentities -> item ( sym ) ; if ( ffar && this != ffar ) { size_t inv_rel ; bool outgoing = false ; if ( rel >= NWEIGHTS / 2 ) { inv_rel = rel - NWEIGHTS / 2 ; outgoing = true ; } else inv_rel = rel + NWEIGHTS / 2 ; rw . add_ref ( ffar -> index ( ) , inv_rel ) ; ffar -> rw . add_ref ( index ( ) , rel ) ; if ( outgoing ) { EntityPtr e ; for ( e = ffar -> get_preve ( ) ; e ; e = e -> get_preve ( ) ) { rw . add_ref ( e -> index ( ) , inv_rel ) ; e -> rw . add_ref ( index ( ) , rel ) ; } for ( e = ffar -> get_nexte ( ) ; e ; e = e -> get_nexte ( ) ) { rw . add_ref ( e -> index ( ) , inv_rel ) ; e -> rw . add_ref ( index ( ) , rel ) ; } if ( rel == AUS_FCALL_INV || rel == AUS_DATAREF_INV ) { if ( ! ffar -> parent_class && strstr ( ffar -> my_sym . get_name ( ) , " " ) ) { symbolPtr parent_sym = ffar -> my_sym . get_parent_of ( projects_to_search ) ; if ( parent_sym . xrisnotnull ( ) ) { ffar -> parent_class = allentities -> item ( parent_sym ) ; } } if ( ffar -> parent_class ) { rw . add_ref ( ffar -> parent_class -> index ( ) , AUS_DATAREF ) ; ffar -> parent_class -> rw . add_ref ( index ( ) , AUS_DATAREF_INV ) ; } if ( ffar -> my_sym . get_kind ( ) == DD_TYPEDEF ) { if ( ! ffar -> basetype ) { ffar -> set_basetype ( ) ; } if ( ffar -> basetype != & no_class ) { rw . add_ref ( ffar -> basetype -> index ( ) , inv_rel ) ; ffar -> basetype -> rw . add_ref ( index ( ) , rel ) ; } } } } } }
Given a particular relation and a symbolPtr, we find the symbol's
entity and then create the reference.
Given a particular relation and a symbolPtr we find the symbol ' s entity and then create the reference .
// Take care of model aliases -- if this calls foo(), for instance, // and there is more than one foo() in the model, we can't tell which // foo() is involved, so we'd better add relations with all of them. // (Aliased Entities were linked together in decomposer::additems().) // apply usage of member so that class is used, too