@ -48,7 +48,7 @@ public:
@@ -48,7 +48,7 @@ public:
///
/// See ::meta_type_id for a discussion of class type IDs.
///
typedef uint16_t AP_ Type_id;
typedef uint16_t Type_id ;
/// Obtain a value unique to all instances of a specific subclass.
///
@ -68,21 +68,21 @@ public:
@@ -68,21 +68,21 @@ public:
///
/// @return A type-unique value for this.
///
AP_ Type_id meta_type_id ( void ) const {
return * ( AP_ Type_id * ) this ;
Type_id meta_type_id ( void ) const {
return * ( Type_id * ) this ;
}
/// Obtain a value unique to all instances of a named subclass.
///
/// This is similar to ::meta_type_id, but is a template taking a class name.
/// Use this function to cache the AP_ Type_id for a class when you don't need
/// Use this function to cache the Type_id for a class when you don't need
/// or cannot afford the constructor cost associated with meta_cast.
///
/// @tparam T A subclass of AP_Meta_class.
/// @return The AP_ Type_id value for T.
/// @return The Type_id value for T.
///
template < typename T >
static AP_ Type_id meta_type_id ( void ) {
static Type_id meta_type_id ( void ) {
T tmp ;
return tmp . meta_type_id ( ) ;
}
@ -198,6 +198,22 @@ public:
@@ -198,6 +198,22 @@ public:
return NULL ;
}
/// Cast this to an expected class type.
///
/// This is equivalent to meta_cast<T>(this)
///
/// @tparam T The name of a type to which this is to be cast.
/// @return NULL if this is not of precisely type T, otherwise this cast to T.
///
template < typename T >
T * meta_cast ( void ) {
T tmp ;
if ( meta_type_equivalent ( this , & tmp ) ) {
return ( T * ) this ;
}
return NULL ;
}
/// Serialize the class.
///
/// Serialization stores the state of the class in an external buffer in such a