TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Type_info Class Reference

Models type information for Objet_U objects. More...

#include <Type_info.h>

Public Member Functions

 ~Type_info ()
 Type_info (const char *name, Objet_U *(*f)(), int nb_bases=0, const Type_info **bases=0)
 Constructor from a name, a factory function, and an array of base types.
 Type_info (const char *name, int nb_bases=0, const Type_info **bases=0)
 Constructor from a name and an array of base types.
const Nomname () const
int can_cast (const Type_info *p) const
 Traverses the type hierarchy. Returns 1 if p points to a subtype of the current type.
int same (const Type_info *p) const
 Returns 1 if this==p, 0 otherwise.
int same (const Nom &) const
 Comparison on the name of a type. Returns 1 if the name string of the considered type and the given name are identical.
int has_base (const Type_info *p, int direct=0) const
 Tests whether a type belongs to the base types of the considered type. If direct == 0,.
int has_base (const Nom &, int direct=0) const
 Tests whether a type belongs to the base types of the considered type. The type to search for is identified by its name.
Sortiebases (Sortie &) const
 Writes the base types of the current type to an output stream.
Objet_Uinstance () const
 Creates an instance of the class associated with the type_info.
int instanciable () const
 Returns 1 if the associated type is instantiable (cree_instance is non-null), 0 otherwise.

Static Public Member Functions

static Sortiehierarchie (Sortie &)
 Writes the full hierarchy of the considered type to an output stream.
static int est_un_type (const char *)
 Tests whether a class of the given type exists. If a class T whose Type_info has the name nom exists,.
static int les_sous_types (const Nom &, Noms &sous_types)
 Returns the names of the subtypes for a parent type identified by name.
static int les_sous_types (const Type_info &, Noms &sous_types)
 Returns the names of the subtypes for a given parent type.
static const Type_infotype_info_from_name (const char *type_name)
 Static method that returns a pointer to the Type_info whose name is "type_name".
static Objet_Uinstance (const char *typ)
 Instantiates an Objet_U of the given type. If a class T whose Type_info has the name typ exists,.

Detailed Description

Models type information for Objet_U objects.

See also
Objet_U Nom

Definition at line 29 of file Type_info.h.

Constructor & Destructor Documentation

◆ ~Type_info()

Type_info::~Type_info ( )

Definition at line 57 of file Type_info.cpp.

◆ Type_info() [1/2]

Type_info::Type_info ( const char * un_nom,
Objet_U *(* )(),
int nb_base = 0,
const Type_info ** the_bases = 0 )

Constructor from a name, a factory function, and an array of base types.

The function is used to create an instance of the appropriate type.

Parameters
un_nomThe name of the type to create.
fFactory function that creates an instance of this type.
nb_baseNumber of base types in the bases array.
the_basesArray specifying the base (parent) types of the type to create.
Exceptions
Exitswith an error if the name is null.

Definition at line 164 of file Type_info.cpp.

◆ Type_info() [2/2]

Type_info::Type_info ( const char * un_nom,
int nb_base = 0,
const Type_info ** the_bases = 0 )

Constructor from a name and an array of base types.

Parameters
un_nomThe name of the type to create.
nb_baseNumber of base types in the bases array.
the_basesArray specifying the base (parent) types of the type to create.
Exceptions
Exitswith an error if the name is null.

Definition at line 136 of file Type_info.cpp.

Member Function Documentation

◆ bases()

Sortie & Type_info::bases ( Sortie & os) const

Writes the base types of the current type to an output stream.

Parameters
osOutput stream.
Returns
Reference to the modified output stream.

Definition at line 302 of file Type_info.cpp.

◆ can_cast()

int Type_info::can_cast ( const Type_info * p) const
inline

Traverses the type hierarchy. Returns 1 if p points to a subtype of the current type.

Parameters
pPointer to the type to test.
Returns
1 if p points to a subtype of the current type, 0 otherwise.

Definition at line 100 of file Type_info.h.

◆ est_un_type()

int Type_info::est_un_type ( const char * nom)
static

Tests whether a class of the given type exists. If a class T whose Type_info has the name nom exists,.

est_un_type returns 1, null pointer otherwise.
Parameters
(constchar* nom) string associated with a type
Returns
(int) return code (0 or 1)

Definition at line 369 of file Type_info.cpp.

◆ has_base() [1/2]

int Type_info::has_base ( const Nom & aname,
int direct = 0 ) const

Tests whether a type belongs to the base types of the considered type. The type to search for is identified by its name.

If direct == 0, returns 1 if the type named name is among the bases of (*this), 0 otherwise.
If direct != 0, returns 1 if the type named name is among the bases of (*this)
or any direct or indirect parent of (*this), 0 otherwise.
Parameters
(constNom& name) the name of the type to search for
(intdirect) 0 to search the entire base hierarchy, non-zero for a direct search
Returns
(int) return code (0 or 1)

Definition at line 429 of file Type_info.cpp.

◆ has_base() [2/2]

int Type_info::has_base ( const Type_info * p,
int direct = 0 ) const

Tests whether a type belongs to the base types of the considered type. If direct == 0,.

returns 1 if (*p) is among the bases of (*this), 0 otherwise.
If direct != 0, returns 1 if (*p) is among the bases of (*this)
or any direct or indirect parent of (*this), 0 otherwise.
Parameters
(constType_info* p) pointer to the type to search for
(intdirect) 0 to search the entire base hierarchy, non-zero for a direct search
Returns
(int) return code (0 or 1)

Definition at line 385 of file Type_info.cpp.

◆ hierarchie()

Sortie & Type_info::hierarchie ( Sortie & os)
static

Writes the full hierarchy of the considered type to an output stream.

Parameters
(Sortie&os) output stream
Returns
(Sortie&) the modified output stream

Definition at line 315 of file Type_info.cpp.

◆ instance() [1/2]

Objet_U * Type_info::instance ( ) const

Creates an instance of the class associated with the type_info.

Definition at line 349 of file Type_info.cpp.

◆ instance() [2/2]

Objet_U * Type_info::instance ( const char * typ)
static

Instantiates an Objet_U of the given type. If a class T whose Type_info has the name typ exists,.

instance returns a pointer to a new instance of T.
Returns the null pointer otherwise.
Parameters
(constchar* typ) string associated with a type
Returns
(Objet_U*) pointer to a new Objet_U of type typ

Definition at line 335 of file Type_info.cpp.

◆ instanciable()

int Type_info::instanciable ( ) const

Returns 1 if the associated type is instantiable (cree_instance is non-null), 0 otherwise.

Definition at line 558 of file Type_info.cpp.

◆ les_sous_types() [1/2]

int Type_info::les_sous_types ( const Nom & type,
Noms & sous_types )
static

Returns the names of the subtypes for a parent type identified by name.

Parameters
(constNom& type) the name of the parent type to search subtypes of
(Noms&les_sous_types) the names of the subtypes
Returns
(int) number of subtypes returned
Exceptions
Exitswith an error if the given name does not correspond to a type known to TRUST

Definition at line 505 of file Type_info.cpp.

◆ les_sous_types() [2/2]

int Type_info::les_sous_types ( const Type_info & mere,
Noms & les_sous_types )
static

Returns the names of the subtypes for a given parent type.

Parameters
(constType_info& mere) the parent type to search subtypes of
(Noms&les_sous_types) the names of the subtypes
Returns
(int) number of subtypes returned

Definition at line 467 of file Type_info.cpp.

◆ name()

const Nom & Type_info::name ( ) const
inline

Definition at line 36 of file Type_info.h.

◆ same() [1/2]

int Type_info::same ( const Nom & other_name) const

Comparison on the name of a type. Returns 1 if the name string of the considered type and the given name are identical.

Returns 0 otherwise.

Definition at line 448 of file Type_info.cpp.

◆ same() [2/2]

int Type_info::same ( const Type_info * p) const

Returns 1 if this==p, 0 otherwise.

Definition at line 456 of file Type_info.cpp.

◆ type_info_from_name()

const Type_info * Type_info::type_info_from_name ( const char * type_name)
static

Static method that returns a pointer to the Type_info whose name is "type_name".

If type_name is not a known type, returns a null pointer.

Definition at line 530 of file Type_info.cpp.


The documentation for this class was generated from the following files: