Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

iokernel/cast.h

This is the verbatim text of the cast.h include file.
#ifndef IOKERNEL__CAST_H
#define IOKERNEL__CAST_H

#include "object.h"
#include "iokernel_forwarders.h"







#ifndef MSVC
template< class T >
bool is_a( const Object* o ) {
  return ( (o) && o->isA( T::get_class_name() ) );
}
#else
template< class T >
bool is_a( const Object* o, T* t=NULL ) {
  return ( (o) && o->isA( T::get_class_name() ) );
}
#endif /* MSVC */






#ifndef MSVC
template< class T >
bool is_kind_of( const Object* o ) {
  return ( (o) && o->isKindOf( T::get_class_name() ) );
}
#else
template< class T >
bool is_kind_of( const Object* o, T* t=NULL ) {
  return ( (o) && o->isKindOf( T::get_class_name() ) );
}
#endif /* MSVC */



template< class T >
T* to( const Object* o ) {
  if (!o) return (T*)o;
  if((o) && o->isKindOf( T::get_class_name())) return (T*)o;
  kernel_assert_message( false, 
			 ("Can't cast object %s to %s\n", 
			  o->getClassName().c_str(),
			  T::get_class_name().c_str()));
  return 0;
}



template< class T >
const T* to_const( const Object* o ) {
  if (!o) return (T*)o;
  if((o) && o->isKindOf( T::get_class_name())) return (const T*)o;
  kernel_assert_message( false, 
			 ("Can't const cast object %s to const %s\n", 
			  o->getClassName().c_str(),
			  T::get_class_name().c_str()) );
  return 0;
}



#endif /* IOKERNEL__CAST_H */

Generated at Mon Nov 22 19:43:59 1999 for NCI SUIF by doxygen  written by Dimitri van Heesch, © 1997-1999