ContRap-Core
Public Types | Public Member Functions | Protected Attributes

crp::Class Class Reference

Class Class represents the memory layout the static members in a ContRap class. More...

#include <class.h>

Inheritance diagram for crp::Class:
crp::Scope crp::Object

Public Types

enum  ClassType { EXPORTED, NATIVE }
 

Enumerates the type of the class.

More...

Public Member Functions

 Class (ClassType type, const SPtr< Scope > &parent=0)
 Class constructor.
virtual ~Class ()
 Virtual destructor.
const DPtrget_init () const
 Returns the init code.
ClassType get_class_type () const
 Returns the class type.
virtual const DPtrget_value (const std::string &name) const
 Finds a value to the key within the current scope or in one of the parent scopes of the current scope or in the scopes of the super classes.
const DPtrassign (const std::string &name, const DPtr &value, bool declare=false)
 Reassigns a value to an identifier.
virtual const DPtrassign_local (const std::string &name, const DPtr &value)
 Reassigns a value to a key locally.
virtual std::string to_string () const
 Converts the object to a non-formatted string.
void add_super_class (const std::string &name, const SPtr< Class > &super_class)
 Adds a super class to this class.
const std::map< std::string,
SPtr< Class > > & 
get_super_classes () const
 Returns the collection of the super classes.
void add_init_command (const DPtr &command)
 Adds an init command.
virtual Object::Type get_type () const
 Returns the enumerated type of the object.

Protected Attributes

ClassType type
 Type of the class.
std::map< std::string, SPtr
< Class > > 
super_classes
 Classes from which this class is derived.
SPtr< Blockinit
 Holds the instantiation code.

Detailed Description

Class Class represents the memory layout the static members in a ContRap class.

There are two types of scopes in ContRap which care class members. A static class instance contains the functions of the class. These functions are shared among all the instances of this class. The same is true for the static variables. The Class instance holds the static functions and variables described above.

The other source are the locally defined functions by a class instance. The locally defined functions are only visible for a current instance. These objects can be found in the crp::Instance class.


Member Enumeration Documentation

Enumerates the type of the class.

Enumerator:
EXPORTED 
NATIVE 

Constructor & Destructor Documentation

crp::Class::Class ( ClassType  type,
const SPtr< Scope > &  parent = 0 
)

Class constructor.

Parameters:
scopeParent scope
virtual crp::Class::~Class ( ) [inline, virtual]

Virtual destructor.


Member Function Documentation

void crp::Class::add_init_command ( const DPtr command)

Adds an init command.

Parameters:
commandInit command
void crp::Class::add_super_class ( const std::string &  name,
const SPtr< Class > &  super_class 
)

Adds a super class to this class.

Parameters:
nameName of the superclass within this class
super_classSuper class to add
const DPtr& crp::Class::assign ( const std::string &  name,
const DPtr value,
bool  declare = false 
) [virtual]

Reassigns a value to an identifier.

If the name is not declared in the current scope, the super classes and then the parent scope are searched. Values are assigned in super classes only if they are declared there. If no parent scope exists the identifier is declared.

This method assigns the value in any case.

Parameters:
nameIdentifier name
valueValue to assign
declareIf set to true the identifier is declared within the local scope
Returns:
Value of the previous entry

Reimplemented from crp::Scope.

virtual const DPtr& crp::Class::assign_local ( const std::string &  name,
const DPtr value 
) [virtual]

Reassigns a value to a key locally.

Values of the super-classes are assumed local.

Parameters:
nameIdentifier name
valueValue to assign
Returns:
Value of the previous entry or an invalid pointer

Reimplemented from crp::Scope.

ClassType crp::Class::get_class_type ( ) const [inline]

Returns the class type.

Returns:
Class type
const DPtr& crp::Class::get_init ( ) const [inline]

Returns the init code.

Returns:
Init code
const std::map<std::string, SPtr<Class> >& crp::Class::get_super_classes ( ) const [inline]

Returns the collection of the super classes.

Returns:
Super classes
virtual Object::Type crp::Class::get_type ( ) const [inline, virtual]

Returns the enumerated type of the object.

Returns:
Type of the object

Reimplemented from crp::Scope.

virtual const DPtr& crp::Class::get_value ( const std::string &  name) const [virtual]

Finds a value to the key within the current scope or in one of the parent scopes of the current scope or in the scopes of the super classes.

Parameters:
nameIdentifier name
Returns:
Value of the name

Reimplemented from crp::Scope.

virtual std::string crp::Class::to_string ( ) const [inline, virtual]

Converts the object to a non-formatted string.

This method is thought to be used for debugging purposes only.

Returns:
String representation of the object

Reimplemented from crp::Scope.


Field Documentation

SPtr<Block> crp::Class::init [protected]

Holds the instantiation code.

std::map<std::string, SPtr<Class> > crp::Class::super_classes [protected]

Classes from which this class is derived.

Type of the class.


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