model_server/dd/src/dd_smt_util.cxx
//---------------------------------------------------------------------------
// The following routine returns the .C file associated with a given class,
// according to the following criteria:
//
// 1. The file in which is defined the first member not defined in the same
//    file as the declaration.
//
// 2. The first file that includes the file containing the declaration (this
//    should take care of the case in which a class is newly created by
//    alphaSET with no members)
//
// 3. If all else fails, just use the file in which the class is declared (it
//    may be local to that file)
//
// It is possible to return NULL under buggy conditions.
The following routine returns the .C file associated with a given class,
according to the following criteria.

1. The file in which is defined the first member not defined in the same
file as the declaration.

2. The first file that includes the file containing the declaration (this
should take care of the case in which a class is newly created by
alphaSET with no members)

3. If all else fails, just use the file in which the class is declared (it
may be local to that file)

It is possible to return NULL under buggy conditions.
The following routine returns the . C file associated with a given class according to the following criteria . 1 . The file in which is defined the first member not defined in the same file as the declaration . 2 . The first file that includes the file containing the declaration ( this should take care of the case in which a class is newly created by alphaSET with no members ) 3 . If all else fails just use the file in which the class is declared ( it may be local to that file ) It is possible to return NULL under buggy conditions .
smtHeaderPtr dd_smt_find_impl_file(ddElementPtr dd_class) {
   Initialize(dd_smt_find_impl_file);
   if (!dd_class)
      ReturnValue(NULL);
   smtTreePtr class_smt = dd_get_smt(dd_class);
   if (!class_smt)
      ReturnValue(NULL);
   smtHeaderPtr decl_hdr = checked_cast(smtHeader,class_smt->get_header());
   smtTreePtr mbr_smt = NULL;
   if (dd_class->get_kind() == DD_CLASS) {
      ddElementPtr mbr;
      objArr       ddArr;
      Obj         *ob;
      dd_class->class_get_members(ddArr);
      ForEach(ob, ddArr) {
         if (ob) {
            mbr = checked_cast(ddElement, ob);
            smtTreePtr mbr_smt;
            if (mbr) {
               mbr_smt = dd_get_smt(mbr);
	       if (mbr_smt) {
		  smtHeaderPtr mbr_hdr = checked_cast(smtHeader,
                        mbr_smt->get_header());
		  if (mbr_hdr && mbr_hdr != decl_hdr) {
		     return mbr_hdr;
		  }
	       }
            }
         }
      }
   }
   fsymbolPtr def_file =
           dd_class->get_xrefSymbol()->get_def_file().get_xrefSymbol();
   if (def_file.xrisnotnull()) {
      symbolArr files;
      if (def_file->get_link(included_by, files)) {
	 symbolPtr file;
	 ForEachS(file, files) {
	    symbolArr trash;
	    if (!file.get_xrefSymbol()->get_link(included_by, trash))
	       return checked_cast(smtHeader,
                     file.get_xrefSymbol().load_file());
	 }
      }
   }
   return decl_hdr;
}
smtHeaderPtr dd_smt_find_impl_file ( ddElementPtr dd_class ) { Initialize ( dd_smt_find_impl_file ) ; if ( ! dd_class ) ReturnValue ( NULL ) ; smtTreePtr class_smt = dd_get_smt ( dd_class ) ; if ( ! class_smt ) ReturnValue ( NULL ) ; smtHeaderPtr decl_hdr = checked_cast ( smtHeader , class_smt -> get_header ( ) ) ; smtTreePtr mbr_smt = NULL ; if ( dd_class -> get_kind ( ) == DD_CLASS ) { ddElementPtr mbr ; objArr ddArr ; Obj * ob ; dd_class -> class_get_members ( ddArr ) ; ForEach ( ob , ddArr ) { if ( ob ) { mbr = checked_cast ( ddElement , ob ) ; smtTreePtr mbr_smt ; if ( mbr ) { mbr_smt = dd_get_smt ( mbr ) ; if ( mbr_smt ) { smtHeaderPtr mbr_hdr = checked_cast ( smtHeader , mbr_smt -> get_header ( ) ) ; if ( mbr_hdr && mbr_hdr != decl_hdr ) { return mbr_hdr ; } } } } } } fsymbolPtr def_file = dd_class -> get_xrefSymbol ( ) -> get_def_file ( ) . get_xrefSymbol ( ) ; if ( def_file . xrisnotnull ( ) ) { symbolArr files ; if ( def_file -> get_link ( included_by , files ) ) { symbolPtr file ; ForEachS ( file , files ) { symbolArr trash ; if ( ! file . get_xrefSymbol ( ) -> get_link ( included_by , trash ) ) return checked_cast ( smtHeader , file . get_xrefSymbol ( ) . load_file ( ) ) ; } } } return decl_hdr ; }
The following routine returns the .C file associated with a given class,
according to the following criteria:
The following routine returns the . C file associated with a given class according to the following criteria :
// New way to get the members of a class (efreed 01/26/93)