ContRap-Core
|
Class Class represents the memory layout the static members in a ContRap class. More...
#include <class.h>
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 DPtr & | get_init () const |
Returns the init code. | |
ClassType | get_class_type () const |
Returns the class type. | |
virtual const DPtr & | get_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 DPtr & | assign (const std::string &name, const DPtr &value, bool declare=false) |
Reassigns a value to an identifier. | |
virtual const DPtr & | assign_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< Block > | init |
Holds the instantiation code. |
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.
Class constructor.
scope | Parent scope |
virtual crp::Class::~Class | ( | ) | [inline, virtual] |
Virtual destructor.
void crp::Class::add_init_command | ( | const DPtr & | command | ) |
Adds an init command.
command | Init command |
Adds a super class to this class.
name | Name of the superclass within this class |
super_class | Super 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.
name | Identifier name |
value | Value to assign |
declare | If set to true the identifier is declared within the local scope |
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.
name | Identifier name |
value | Value to assign |
Reimplemented from crp::Scope.
const DPtr& crp::Class::get_init | ( | ) | const [inline] |
Returns the init code.
Returns the collection of the super classes.
virtual Object::Type crp::Class::get_type | ( | ) | const [inline, virtual] |
Returns the enumerated 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.
name | Identifier 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.
Reimplemented from crp::Scope.
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.
ClassType crp::Class::type [protected] |
Type of the class.