Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Attributes
soar_module::sym_set_param Class Reference

#include <soar_module.h>

Inherits soar_module::param.

Public Member Functions

virtual char * get_string ()
virtual bool in_set (Symbol *test_sym)
virtual bool set_string (const char *new_string)
virtual void set_value (const char *new_value)
 sym_set_param (const char *new_name, predicate< const char * > *new_prot_pred, agent *new_agent)
virtual bool validate_string (const char *)
virtual ~sym_set_param ()
- Public Member Functions inherited from soar_module::param
 param (const char *new_name)
virtual ~param ()
- Public Member Functions inherited from soar_module::named_object
const char * get_name ()
 named_object (const char *new_name)
virtual ~named_object ()

Protected Attributes

agentmy_agent
std::set< Symbol * > * my_set
predicate< const char * > * prot_pred
std::string * value

Detailed Description

Definition at line 491 of file soar_module.h.

Constructor & Destructor Documentation

soar_module::sym_set_param::sym_set_param ( const char *  new_name,
predicate< const char * > *  new_prot_pred,
agent new_agent 
)
inline

Definition at line 501 of file soar_module.h.

: param( new_name ), my_set( new std::set<Symbol *>() ), value( new std::string ), prot_pred( new_prot_pred ), my_agent( new_agent ) {}
virtual soar_module::sym_set_param::~sym_set_param ( )
inlinevirtual

Definition at line 503 of file soar_module.h.

References my_agent, my_set, prot_pred, symbol_remove_ref(), and value.

{
for ( std::set<Symbol *>::iterator p=my_set->begin(); p!=my_set->end(); p++ )
delete my_set;
delete value;
delete prot_pred;
}

Member Function Documentation

virtual char* soar_module::sym_set_param::get_string ( )
inlinevirtual

Implements soar_module::named_object.

Definition at line 515 of file soar_module.h.

References value.

{
char *return_val = new char[ value->length() + 1 ];
strcpy( return_val, value->c_str() );
return_val[ value->length() ] = '\0';
return return_val;
}
virtual bool soar_module::sym_set_param::in_set ( Symbol test_sym)
inlinevirtual

Definition at line 544 of file soar_module.h.

References symbol_union::fc, FLOAT_CONSTANT_SYMBOL_TYPE, symbol_union::ic, INT_CONSTANT_SYMBOL_TYPE, make_sym_constant(), my_agent, my_set, SYM_CONSTANT_SYMBOL_TYPE, symbol_remove_ref(), int_constant_struct::value, and float_constant_struct::value.

Referenced by _epmem_store_level().

{
bool return_val = false;
if ( ( test_sym->common.symbol_type == SYM_CONSTANT_SYMBOL_TYPE ) ||
( test_sym->common.symbol_type == INT_CONSTANT_SYMBOL_TYPE ) ||
( test_sym->common.symbol_type == FLOAT_CONSTANT_SYMBOL_TYPE ) )
{
Symbol *my_sym = test_sym;
if ( my_sym->common.symbol_type != SYM_CONSTANT_SYMBOL_TYPE )
{
std::string temp_str;
if ( my_sym->common.symbol_type == INT_CONSTANT_SYMBOL_TYPE )
{
to_string( my_sym->ic.value, temp_str );
}
else
{
to_string( my_sym->fc.value, temp_str );
}
my_sym = make_sym_constant( my_agent, temp_str.c_str() );
}
std::set<Symbol *>::iterator p = my_set->find( my_sym );
return_val = ( p != my_set->end() );
if ( test_sym != my_sym )
{
}
}
return return_val;
}
virtual bool soar_module::sym_set_param::set_string ( const char *  new_string)
inlinevirtual

Implements soar_module::param.

Definition at line 524 of file soar_module.h.

References prot_pred, and set_value().

{
if ( (*prot_pred)( new_string ) )
{
return false;
}
else
{
set_value( new_string );
return true;
}
}
virtual void soar_module::sym_set_param::set_value ( const char *  new_value)
inlinevirtual

Definition at line 582 of file soar_module.h.

References make_sym_constant(), my_agent, my_set, sym_constant_struct::name, symbol_union::sc, symbol_remove_ref(), and value.

Referenced by init_soar_agent(), and set_string().

{
Symbol *my_sym = make_sym_constant( my_agent, new_value );
std::set<Symbol *>::iterator p = my_set->find( my_sym );
if ( p != my_set->end() )
{
my_set->erase( p );
// remove for now and when added to the set
// regenerate value from scratch
value->clear();
for ( p=my_set->begin(); p!=my_set->end(); )
{
value->append( (*p)->sc.name );
p++;
if ( p != my_set->end() )
value->append( ", " );
}
}
else
{
my_set->insert( my_sym );
if ( !value->empty() )
value->append( ", " );
value->append( my_sym->sc.name );
}
}
virtual bool soar_module::sym_set_param::validate_string ( const char *  )
inlinevirtual

Implements soar_module::param.

Definition at line 537 of file soar_module.h.

{
return true;
}

Field Documentation

agent* soar_module::sym_set_param::my_agent
protected

Definition at line 498 of file soar_module.h.

Referenced by in_set(), set_value(), and ~sym_set_param().

std::set<Symbol *>* soar_module::sym_set_param::my_set
protected

Definition at line 494 of file soar_module.h.

Referenced by in_set(), set_value(), and ~sym_set_param().

predicate<const char *>* soar_module::sym_set_param::prot_pred
protected

Definition at line 496 of file soar_module.h.

Referenced by set_string(), and ~sym_set_param().

std::string* soar_module::sym_set_param::value
protected

Definition at line 495 of file soar_module.h.

Referenced by get_string(), set_value(), and ~sym_set_param().


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