123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #include "Variablen.h"
- #include "Gegenstand.h"
- Variable::Variable( VariableTyp typ )
- {
- this->typ = typ;
- ref = 1;
- }
- Variable::~Variable()
- {}
- VariableTyp Variable::getVariableTyp() const
- {
- return typ;
- }
- Variable *Variable::getThis()
- {
- ref++;
- return this;
- }
- Variable *Variable::release()
- {
- if( !--ref )
- delete this;
- return 0;
- }
- bool isTrue( Variable *v )
- {
- if( !v )
- return 0;
- switch( v->getVariableTyp() )
- {
- case NICHTS:
- return 0;
- case INTEGER:
- return ( (Integer *)v )->getValue() != 0;
- case BOOLEAN:
- return ( (Boolean *)v )->getValue();
- case STRING:
- return ( (String *)v )->getValue().getLength();
- case FLOAT:
- return ( (Float *)v )->getValue() != 0;
- case TASTE:
- return ( (Integer *)v )->getValue() != 0;
- case GEGENSTAND_TYP:
- return ( (GegenstandTypVar *)v )->getValue() != KEIN_GEGENSTAND;
- default:
- return 1;
- }
- }
- Integer::Integer( int value, bool taste )
- : Variable( taste ? TASTE : INTEGER )
- {
- this->value = value;
- }
- void Integer::setValue( int value )
- {
- this->value = value;
- }
- int Integer::getValue() const
- {
- return value;
- }
- Boolean::Boolean( bool value )
- : Variable( BOOLEAN )
- {
- this->value = value;
- }
- void Boolean::setValue( bool value )
- {
- this->value = value;
- }
- bool Boolean::getValue() const
- {
- return value;
- }
- String::String( const char *value, bool richtung )
- : Variable( richtung ? RICHTUNG : STRING )
- {
- this->value = value;
- }
- void String::setValue( Text value )
- {
- this->value = value;
- }
- const Text &String::getValue() const
- {
- return value;
- }
- Float::Float( float value )
- : Variable( FLOAT )
- {
- this->value = value;
- }
- void Float::setValue( float value )
- {
- this->value = value;
- }
- float Float::getValue() const
- {
- return value;
- }
|