Puma Reference Manual Puma: Puma::CTemplateInstance Class Reference



Puma::CTemplateInstance Class Reference

#include <Puma/CTemplateInstance.h>

List of all members.


Detailed Description

Semantic information about a template instance.

Contains the point of instantiation, the instantiated template, the instantiation arguments, and the deduced template arguments.

The point of instantiation (POI) is the corresponding template-id.

 X<int> x;  // X<int> is the POI 

The instantiation arguments are the arguments of the template-id at the POI.

 Y<int,1> y;  // 'int' and '1' are the instantiation arguments 

The deduced template arguments are calculated from the instantiation arguments and the template default arguments.

  template<class T1, class T2 = float>
  struct Foo { 
    template<class T3, class T4>
    T1 foo(T2,T3,T4*);
  };

  void bar(bool b, char* s) {
    Foo<int> f;     // deduced arguments: T1=int,  T2=float
    f.foo(1,b,s);   // deduced arguments: T3=bool, T4=char
  }

If a template instance is not yet created (maybe because real template instantiation is disabled or due to late template instantiation), then this template instance is called a pseudo instance.

Public Member Functions

 CTemplateInstance ()
 Constructor.
 ~CTemplateInstance ()
 Destructor.
CObjectInfogetInstance (CStructure *scope)
 If this is a pseudo instance, instantiate the template and return the instance.
CTemplateInfoTemplate () const
 Get the semantic information about the instantiated template.
void Template (CTemplateInfo *info)
 Set the semantic information about the instantiated template.
CT_SimpleNamePointOfInstantiation () const
 Get the point of instantiation (the template-id).
CScopeInfoPointOfInstantiationScope () const
 Get the scope in which the template was instantiated.
void PointOfInstantiation (CT_SimpleName *tplid, CScopeInfo *scope)
 Set the point of instantiation (the template-id).
void TranslationUnit (CTranslationUnit *tu)
 Set the translation unit containing the code of the template instance.
CTranslationUnitTranslationUnit () const
 Get the translation unit containing the code of the template instance.
void canDelete ()
 Set that the translation unit containg the code of the template instance can be destroyed in the destructor of the template instance.
void isPseudoInstance (bool v)
 Set whether this is a pseudo template instance.
bool isPseudoInstance () const
 Check if this is a pseudo template instance.
unsigned InstantiationArgs () const
 Get the number of instantiation arguments.
DeducedArgumentInstantiationArg (unsigned n) const
 Get the n-th instantiation argument.
void addInstantiationArg (DeducedArgument *arg)
 Add an instantiation argument.
unsigned DeducedArgs () const
 Get the number of deduced arguments.
DeducedArgumentDeducedArg (unsigned n) const
 Get the n-th deduced template argument.
void addDeducedArg (DeducedArgument *arg)
 Add a deduced template argument.
void clearDeducedArgs ()
 Discard the deduced template arguments.

Protected Attributes

CTemplateInfo_TemplateInfo
 The semantic information about the template.
CT_SimpleName_PointOfInstantiation
 The point of instantiation.
CScopeInfo_PointOfInstantiationScope
 The scope in which the template was instantiated.
Array< DeducedArgument * > _DeducedArgs
 The list of deduced template arguments.
Array< DeducedArgument * > _InstantiationArgs
 The list of instantiation arguments.
CTranslationUnit_InstanceSrc
 The translation unit containing the template instance code.
bool _Pseudo
 True if this is not a real template instance.
bool _Delete
 True if the template instance translation unit can be destroyed in the destructor of this class.
CObjectInfo_Instance
 Pointer to the real instance.


Constructor & Destructor Documentation

Puma::CTemplateInstance::CTemplateInstance (  )  [inline]

Constructor.

Puma::CTemplateInstance::~CTemplateInstance (  )  [inline]

Destructor.

Destroys the instantiation and deduced arguments. Optionally destroys the translation unit of the instance code.


Member Function Documentation

CObjectInfo * Puma::CTemplateInstance::getInstance ( CStructure scope  )  [inline]

If this is a pseudo instance, instantiate the template and return the instance.

Otherwise return this.

Parameters:
scope The scope in which to instantiate the template.

CTemplateInfo * Puma::CTemplateInstance::Template (  )  const [inline]

Get the semantic information about the instantiated template.

void Puma::CTemplateInstance::Template ( CTemplateInfo info  )  [inline]

Set the semantic information about the instantiated template.

Parameters:
info The template that was instantiated.

CT_SimpleName * Puma::CTemplateInstance::PointOfInstantiation (  )  const [inline]

Get the point of instantiation (the template-id).

CScopeInfo * Puma::CTemplateInstance::PointOfInstantiationScope (  )  const [inline]

Get the scope in which the template was instantiated.

void Puma::CTemplateInstance::PointOfInstantiation ( CT_SimpleName tplid,
CScopeInfo scope 
) [inline]

Set the point of instantiation (the template-id).

Parameters:
tplid The template-id used to instantiate the template.
scope The scope in which the template was instantiated.

void Puma::CTemplateInstance::TranslationUnit ( CTranslationUnit tu  )  [inline]

Set the translation unit containing the code of the template instance.

Parameters:
tu The translation unit.

CTranslationUnit * Puma::CTemplateInstance::TranslationUnit (  )  const [inline]

Get the translation unit containing the code of the template instance.

void Puma::CTemplateInstance::canDelete (  )  [inline]

Set that the translation unit containg the code of the template instance can be destroyed in the destructor of the template instance.

void Puma::CTemplateInstance::isPseudoInstance ( bool  v  )  [inline]

Set whether this is a pseudo template instance.

Parameters:
v True for yes, false for no.

bool Puma::CTemplateInstance::isPseudoInstance (  )  const [inline]

Check if this is a pseudo template instance.

unsigned Puma::CTemplateInstance::InstantiationArgs (  )  const [inline]

Get the number of instantiation arguments.

DeducedArgument * Puma::CTemplateInstance::InstantiationArg ( unsigned  n  )  const [inline]

Get the n-th instantiation argument.

Parameters:
n The index of the instantiation argument.

void Puma::CTemplateInstance::addInstantiationArg ( DeducedArgument arg  )  [inline]

Add an instantiation argument.

Parameters:
arg The instantiation argument.

unsigned Puma::CTemplateInstance::DeducedArgs (  )  const [inline]

Get the number of deduced arguments.

DeducedArgument * Puma::CTemplateInstance::DeducedArg ( unsigned  n  )  const [inline]

Get the n-th deduced template argument.

Parameters:
n The index of the template argument.

void Puma::CTemplateInstance::addDeducedArg ( DeducedArgument arg  )  [inline]

Add a deduced template argument.

Parameters:
arg The deduced template argument.

void Puma::CTemplateInstance::clearDeducedArgs (  )  [inline]

Discard the deduced template arguments.


Member Data Documentation

The semantic information about the template.

The point of instantiation.

The scope in which the template was instantiated.

The list of deduced template arguments.

The list of instantiation arguments.

The translation unit containing the template instance code.

True if this is not a real template instance.

True if the template instance translation unit can be destroyed in the destructor of this class.

Pointer to the real instance.




Puma Reference Manual. Created on 5 Nov 2008.