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::constant_param< T > Class Template Reference

#include <soar_module.h>

Inherits soar_module::param.

Public Member Functions

virtual void add_mapping (T val, const char *str)
 constant_param (const char *new_name, T new_value, predicate< T > *new_prot_pred)
virtual char * get_string ()
virtual T get_value ()
virtual bool set_string (const char *new_string)
virtual void set_value (T new_value)
virtual bool validate_string (const char *new_string)
virtual ~constant_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

predicate< T > * prot_pred
std::map< std::string, T > * string_to_value
value
std::map< T, const char * > * value_to_string

Detailed Description

template<typename T>
class soar_module::constant_param< T >

Definition at line 623 of file soar_module.h.

Constructor & Destructor Documentation

template<typename T>
soar_module::constant_param< T >::constant_param ( const char *  new_name,
new_value,
predicate< T > *  new_prot_pred 
)
inline

Definition at line 632 of file soar_module.h.

: param( new_name ), value( new_value ), value_to_string( new std::map<T, const char *>() ), string_to_value( new std::map<std::string, T> ), prot_pred( new_prot_pred ) {}
template<typename T>
virtual soar_module::constant_param< T >::~constant_param ( )
inlinevirtual

Definition at line 634 of file soar_module.h.

{
delete prot_pred;
}

Member Function Documentation

template<typename T>
virtual void soar_module::constant_param< T >::add_mapping ( val,
const char *  str 
)
inlinevirtual

Definition at line 704 of file soar_module.h.

Referenced by epmem_param_container::epmem_param_container(), rl_param_container::rl_param_container(), smem_param_container::smem_param_container(), and wma_param_container::wma_param_container().

{
std::string my_string( str );
// string to value
(*string_to_value)[ my_string ] = val;
// value to string
(*value_to_string)[ val ] = str;
}
template<typename T>
virtual char* soar_module::constant_param< T >::get_string ( )
inlinevirtual

Implements soar_module::named_object.

Definition at line 643 of file soar_module.h.

{
typename std::map<T, const char *>::iterator p;
p = value_to_string->find( value );
if ( p == value_to_string->end() )
return NULL;
else
{
size_t len = strlen( p->second );
char *return_val = new char[ len + 1 ];
strcpy( return_val, p->second );
return_val[ len ] = '\0';
return return_val;
}
}
template<typename T>
virtual T soar_module::constant_param< T >::get_value ( )
inlinevirtual
template<typename T>
virtual bool soar_module::constant_param< T >::set_string ( const char *  new_string)
inlinevirtual

Implements soar_module::param.

Definition at line 662 of file soar_module.h.

{
typename std::map<std::string, T>::iterator p;
std::string temp_str( new_string );
p = string_to_value->find( temp_str );
if ( ( p == string_to_value->end() ) || (*prot_pred)( p->second ) )
{
return false;
}
else
{
set_value( p->second );
return true;
}
}
template<typename T>
virtual void soar_module::constant_param< T >::set_value ( new_value)
inlinevirtual
template<typename T>
virtual bool soar_module::constant_param< T >::validate_string ( const char *  new_string)
inlinevirtual

Implements soar_module::param.

Definition at line 680 of file soar_module.h.

{
typename std::map<std::string, T>::iterator p;
std::string temp_str( new_string );
p = string_to_value->find( temp_str );
return ( p != string_to_value->end() );
}

Field Documentation

template<typename T>
predicate<T>* soar_module::constant_param< T >::prot_pred
protected
template<typename T>
std::map<std::string, T>* soar_module::constant_param< T >::string_to_value
protected
template<typename T>
T soar_module::constant_param< T >::value
protected
template<typename T>
std::map<T, const char *>* soar_module::constant_param< T >::value_to_string
protected

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