Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

PolymorphBase< T > Class Template Reference

#include <polymorph.h>

Inheritance diagram for PolymorphBase< T >:

Inheritance graph
[legend]
Collaboration diagram for PolymorphBase< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class PolymorphBase< T >

Wrapper to hide the type of an enclosed variable.

This serves as a base type to Polymorph, to allow specializations of Polymorph to override some of this functionality.

Definition at line 40 of file polymorph.h.

Public Types

typedef T value_type
typedef PolymorphBase< value_type > self

Public Methods

 PolymorphBase (const value_type val)
 PolymorphBase (value_type *ptr)
virtual bool operator< (const Typeless &o) const
 Polymorphic comparison operator.

virtual bool operator> (const Typeless &o) const
 Polymorphic comparison operator.

bool operator< (const self &o) const
bool operator> (const self &o) const
bool operator< (const value_type &o) const
bool operator> (const value_type &o) const
selfoperator= (const value_type &o)
Typelessset (const Typeless &o)
 Polymorphic assignment operator.

const value_type & operator * () const
value_type * valueptr () const
 Returns a pointer to the underlying value; use with caution.

virtual string stringrep (String::StreamFormat format=String::StreamFormat()) const
 Returns a string representation of the current value of this object.

virtual string typestring () const
 Returns a string representation of the datatype of this object.

virtual Typelessparse (const StringParser &parser, const string &s) const
 Returns the result of parsing the given string with the given parser.

virtual Typelessclone () const
 Constructs an identical copy of self and returns it.

virtual Typelessduplicate () const
 Same as clone except that the result is guaranteed to have an independent copy of the underlying value.


Static Public Methods

void set_typestring (const char *str)
 By default, typestring() returns the value of typeid().name() for a given type, which is implementation-dependent; for templates such as strings it is often very ugly.


Protected Attributes

AllocatingPointer< value_type > p

Static Protected Attributes

const char * name_str = 0


Member Function Documentation

template<class T>
virtual Typeless* PolymorphBase< T >::clone   const [inline, virtual]
 

Constructs an identical copy of self and returns it.

Due to Cray C++'s variance from the C++ standard, cannot use actual type as the return value (or it wouldn't match the protype in Typeless.)

Implements Typeless.

Reimplemented in Polymorph< T >, and Polymorph< string >.

Definition at line 98 of file polymorph.h.

template<class T>
virtual Typeless* PolymorphBase< T >::parse const StringParser   parser,
const string &    s
const [inline, virtual]
 

Returns the result of parsing the given string with the given parser.

The actual type of the result is a Polymorph<value_type>, which is a derived type of this one. (Otherwise each derived specialization would need to replicate this routine, changing only the returned value's type.)

Implements Typeless.

Definition at line 87 of file polymorph.h.

template<class T>
Typeless & PolymorphBase< T >::set const Typeless   o [virtual]
 

Polymorphic assignment operator.

This version accepts identical types only. One could imagine supporting arbitrary types by printing the o value to a string and then parsing it into our type, but that would be pretty kludgy. In any case, the aborting assertion here should probably be eliminated somehow.

Implements Typeless.

Definition at line 162 of file polymorph.h.

References PolymorphBase< T >::p.

template<class T>
void PolymorphBase< T >::set_typestring const char *    str [inline, static]
 

By default, typestring() returns the value of typeid().name() for a given type, which is implementation-dependent; for templates such as strings it is often very ugly.

If the typestring is shown to the user, you can use this call to override the default with something prettier or possibly something domain-specific.

Definition at line 79 of file polymorph.h.

Referenced by cmdparam_init_hook().

template<class T>
virtual string PolymorphBase< T >::typestring   const [inline, virtual]
 

Returns a string representation of the datatype of this object.

The value is not guaranteed to be anything particularly useful, one cannot count on any implementation more specific than the one here.

Reimplemented from Typeless.

Definition at line 70 of file polymorph.h.


The documentation for this class was generated from the following file:
Generated on Mon Jan 20 02:37:12 2003 for RF-LISSOM by doxygen1.3-rc2