#include <clipsmm/environment.h>
Inheritance diagram for CLIPS::Environment:
Vinyard, Jr. <rvinyard@cs.nmsu.edu>
Public Types | |
typedef CLIPSPointer< Environment > | pointer |
Public Member Functions | |
bool | batch_evaluate (const std::string &filename) |
Evaluates a series of commands in the specified file. | |
bool | binary_load (const std::string &filename) |
Loads a binary image of constructs into the CLIPS data base. | |
bool | binary_save (const std::string &filename) |
Saves a binary image of constructs from the CLIPS data base. | |
bool | build (const std::string &construct) |
Allows a construct to be defined. | |
void | clear () |
Clears the environment. | |
Values | evaluate (const std::string &expression) |
Evaluates and expression and returns a vector of the results. | |
Values | function (const std::string &function_name, const std::string &arguments=std::string()) |
Evaluates a CLIPS function. | |
int | load (const std::string &filename) |
Loads a set of constructs into the CLIPS data base. | |
void | reset () |
Resets the CLIPS environment. | |
bool | save (const std::string &filename) |
Saves a set of constructs to the specified file. | |
bool | auto_float_dividend_enabled () |
Returns the current state of the auto-float dividend behavior. | |
bool | use_auto_float_dividend (bool use=true) |
Sets the auto-float dividend behavior. | |
bool | dynamic_constraint_checking_enabled () |
Returns the current state of the dynamic constraint checking behavior. | |
bool | use_dynamic_constraint_checking (bool use=true) |
Sets the dynamic constraint checking behavior. | |
bool | sequence_operator_recognition_enabled () |
Returns the current state of the sequence operator recognition behavior. | |
bool | use_sequence_operator_recognition (bool use=true) |
Sets the sequence operator recognition behavior. | |
bool | static_constraint_checking_enabled () |
Returns the current state of the static constraint checking behavior. | |
bool | use_static_constraint_checking (bool use=true) |
Sets the static constraint checking behavior. | |
bool | fact_duplication_enabled () |
Returns the current state of the fact duplication behavior. | |
bool | use_fact_duplication (bool use=true) |
Sets the static constraint checking behavior. | |
bool | incremental_reset_enabled () |
bool | use_incremental_reset (bool use=true) |
bool | global_reset_enable () |
bool | use_global_reset (bool use=true) |
bool | is_dribble_active () |
Determines if the storing of dribble information is active. | |
bool | dribble_off () |
Turns off the storing of dribble information. | |
bool | dribble_on (const std::string &dribble_file) |
Allows the dribble function of CLIPS to be turned on. | |
int | is_watched (const std::string &item) |
Determine if an item is being watched. | |
bool | watch (const std::string &item) |
bool | unwatch (const std::string &item) |
void | set_as_current () |
Fact::pointer | assert_fact (const std::string &factstring) |
void | clear_focus_stack () |
DefaultFacts::pointer | get_default_facts (const std::string &default_facts_name) |
TODO Facts. | |
std::vector< std::string > | get_default_facts_names () |
Gets a list of default facts names from all modules. | |
std::vector< std::string > | get_default_facts_names (const Module &module) |
Gets a list of default facts names from a specific module. | |
std::vector< std::string > | get_default_facts_names (Module::pointer module) |
Gets a list of default facts names from a specific module. | |
DefaultFacts::pointer | get_default_facts_list_head () |
Template::pointer | get_template (const std::string &template_name) |
std::vector< std::string > | get_template_names () |
Gets a list of template names from all modules. | |
std::vector< std::string > | get_template_names (const Module &module) |
Gets a list of template names from a specific module. | |
std::vector< std::string > | get_template_names (Module::pointer module) |
Gets a list of template names from a specific module. | |
Template::pointer | get_template_list_head () |
Rule::pointer | get_rule (const std::string &rule_name) |
std::vector< std::string > | get_rule_names () |
Gets a list of rule names from all modules. | |
std::vector< std::string > | get_rule_names (const Module &module) |
Gets a list of rule names from a specific module. | |
std::vector< std::string > | get_rule_names (Module::pointer module) |
Gets a list of rule names from a specific module. | |
Rule::pointer | get_rule_list_head () |
void | remove_rules () |
Module::pointer | get_module (const std::string &module_name) |
Module::pointer | get_current_module () |
std::vector< std::string > | get_module_names () |
Module::pointer | get_module_list_head () |
void | refresh_agenda () |
Refreshes the agenda for all modules. | |
void | refresh_agenda (const Module &module) |
Refreshes the agenda for a specific module. | |
void | refresh_agenda (Module::pointer module) |
Refreshes the agenda for a specific module. | |
void | reorder_agenda () |
Reorders the agenda for all modules. | |
void | reorder_agenda (const Module &module) |
Reorders the agenda for a specific module. | |
void | reorder_agenda (Module::pointer module) |
Reorders the agenda for a specific module. | |
long int | run (long int runlimit=-1) |
Allows rules to execute. | |
void | run_threaded (long int runlimit=-1, int priority=0) |
Executes rules in a separate thread. | |
void | join_run_thread () |
Waits until the execution thread is finished. | |
sigc::signal< void, long int > | signal_run () |
Signal emitted when the rules are executed. | |
SalienceEvaluation | get_salience_evaluation () |
Gets the salience evaluation mode. | |
SalienceEvaluation | set_salience_evaluation (SalienceEvaluation se) |
Sets the salience evaluation mode. | |
ConflictResolution | get_conflict_resolution_strategy () |
Gets the current conflict resolution strategy. | |
ConflictResolution | set_conflict_resolution_strategy (ConflictResolution cr) |
Sets the conflict resolution strategy. | |
bool | check_agenda_changed () |
Checks whether the agenda has changed and emits the agenda changed signal if it has. | |
Module::pointer | get_focused_module () |
std::vector< std::string > | get_focus_stack () |
Activation::pointer | get_activation_list_head () |
Global::pointer | get_global (const std::string &global_name) |
Global::pointer | get_global_list_head () |
std::vector< std::string > | get_globals_names () |
Gets a list of global names from all modules. | |
std::vector< std::string > | get_globals_names (const Module &module) |
Gets a list of global names from a specific module. | |
std::vector< std::string > | get_globals_names (Module::pointer module) |
Gets a list of global names from a specific module. | |
bool | check_globals_changed () |
Function::pointer | get_function (const std::string &function_name) |
Function::pointer | get_function_list_head () |
std::vector< std::string > | get_function_names () |
Gets a list of function names from all modules. | |
std::vector< std::string > | get_function_names (const Module &module) |
Gets a list of function names from a specific module. | |
std::vector< std::string > | get_function_names (Module::pointer module) |
Gets a list of function names from a specific module. | |
sigc::signal< void > | signal_clear () |
sigc::signal< void > | signal_periodic () |
sigc::signal< void > | signal_reset () |
sigc::signal< void > | signal_rule_firing () |
sigc::signal< void > | signal_agenda_changed () |
sigc::signal< void > | signal_globals_changed () |
template<typename T_return> | |
bool | add_function (std::string name, const sigc::slot0< T_return > &slot) |
template<typename T_return, typename T_arg1> | |
bool | add_function (std::string name, const sigc::slot1< T_return, T_arg1 > &slot) |
template<typename T_return, typename T_arg1, typename T_arg2> | |
bool | add_function (std::string name, const sigc::slot2< T_return, T_arg1, T_arg2 > &slot) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3> | |
bool | add_function (std::string name, const sigc::slot3< T_return, T_arg1, T_arg2, T_arg3 > &slot) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4> | |
bool | add_function (std::string name, const sigc::slot4< T_return, T_arg1, T_arg2, T_arg3, T_arg4 > &slot) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5> | |
bool | add_function (std::string name, const sigc::slot5< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5 > &slot) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6> | |
bool | add_function (std::string name, const sigc::slot6< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6 > &slot) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7> | |
bool | add_function (std::string name, const sigc::slot7< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 > &slot) |
bool | remove_function (std::string name) |
Protected Types | |
typedef CLIPS::Environment::Job | Job |
Encapsulates the concept of a CLIPS job. | |
Protected Member Functions | |
void | threaded_run () |
Protected method that does the actual work. | |
int(* | get_callback (const sigc::slot0< std::string > &slot))(void *) |
template<typename T_arg1> | |
int(* | get_callback (const sigc::slot1< std::string, T_arg1 > &slot))(void *) |
template<typename T_arg1, typename T_arg2> | |
int(* | get_callback (const sigc::slot2< std::string, T_arg1, T_arg2 > &slot))(void *) |
template<typename T_arg1, typename T_arg2, typename T_arg3> | |
int(* | get_callback (const sigc::slot3< std::string, T_arg1, T_arg2, T_arg3 > &slot))(void *) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4> | |
int(* | get_callback (const sigc::slot4< std::string, T_arg1, T_arg2, T_arg3, T_arg4 > &slot))(void *) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5> | |
int(* | get_callback (const sigc::slot5< std::string, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5 > &slot))(void *) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6> | |
int(* | get_callback (const sigc::slot6< std::string, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6 > &slot))(void *) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7> | |
int(* | get_callback (const sigc::slot7< std::string, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 > &slot))(void *) |
template<typename T_return> | |
int(* | get_callback (const sigc::slot0< T_return > &slot))(void *) |
template<typename T_return, typename T_arg1> | |
int(* | get_callback (const sigc::slot1< T_return, T_arg1 > &slot))(void *) |
template<typename T_return, typename T_arg1, typename T_arg2> | |
int(* | get_callback (const sigc::slot2< T_return, T_arg1, T_arg2 > &slot))(void *) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3> | |
int(* | get_callback (const sigc::slot3< T_return, T_arg1, T_arg2, T_arg3 > &slot))(void *) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4> | |
int(* | get_callback (const sigc::slot4< T_return, T_arg1, T_arg2, T_arg3, T_arg4 > &slot))(void *) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5> | |
int(* | get_callback (const sigc::slot5< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5 > &slot))(void *) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6> | |
int(* | get_callback (const sigc::slot6< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6 > &slot))(void *) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7> | |
int(* | get_callback (const sigc::slot7< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 > &slot))(void *) |
Static Protected Member Functions | |
static void | clear_callback (void *env) |
static void | periodic_callback (void *env) |
static void | reset_callback (void *env) |
static void | rule_firing_callback (void *end) |
static void * | strcallback (void *theEnv) |
template<typename T_arg1> | |
static void * | strcallback (void *theEnv) |
template<typename T_arg1, typename T_arg2> | |
static void * | strcallback (void *theEnv) |
template<typename T_arg1, typename T_arg2, typename T_arg3> | |
static void * | strcallback (void *theEnv) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4> | |
static void * | strcallback (void *theEnv) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5> | |
static void * | strcallback (void *theEnv) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6> | |
static void * | strcallback (void *theEnv) |
template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7> | |
static void * | strcallback (void *theEnv) |
template<typename T_return> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1, typename T_arg2> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6> | |
static T_return | callback (void *theEnv) |
template<typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7> | |
static T_return | callback (void *theEnv) |
static int | get_arg_count (void *env) |
static void * | get_function_context (void *env) |
static void * | add_symbol (const char *s) |
Protected Attributes | |
std::map< std::string, any > | m_slots |
Holds any dynamically created slots. | |
sigc::signal< void > | m_signal_clear |
sigc::signal< void > | m_signal_periodic |
sigc::signal< void > | m_signal_reset |
sigc::signal< void > | m_signal_rule_firing |
sigc::signal< void > | m_signal_agenda_changed |
sigc::signal< void > | m_signal_globals_changed |
Glib::Thread * | m_run_thread |
A pointer to the currently running thread. | |
std::priority_queue< Job > | m_run_queue |
A priority queue of jobs to run. | |
Glib::Mutex | m_mutex_run_queue |
Mutex that protects access to the run queue. | |
Glib::Mutex | m_mutex_run |
Mutex that protects against multiple executions. | |
Glib::Mutex | m_mutex_threaded_run |
Mutex that locks when a threaded run is executing. | |
Glib::Mutex | m_mutex_run_signal |
Mutex that protects against multiple signal emits. | |
sigc::signal< void, long int > | m_signal_run |
Signal emitted when a job is run. | |
Static Protected Attributes | |
static std::map< void *, Environment * > | m_environment_map |
Classes | |
struct | Job |
Encapsulates the concept of a CLIPS job. More... |
typedef struct CLIPS::Environment::Job CLIPS::Environment::Job [protected] |
Encapsulates the concept of a CLIPS job.
Has a priority for comparison and a runlimit
bool CLIPS::Environment::batch_evaluate | ( | const std::string & | filename | ) |
Evaluates a series of commands in the specified file.
bool CLIPS::Environment::binary_load | ( | const std::string & | filename | ) |
Loads a binary image of constructs into the CLIPS data base.
bool CLIPS::Environment::binary_save | ( | const std::string & | filename | ) |
Saves a binary image of constructs from the CLIPS data base.
bool CLIPS::Environment::build | ( | const std::string & | construct | ) |
Allows a construct to be defined.
Values CLIPS::Environment::evaluate | ( | const std::string & | expression | ) |
Evaluates and expression and returns a vector of the results.
If the expression could not be evaluated a zero-length vector is returned.
Values CLIPS::Environment::function | ( | const std::string & | function_name, | |
const std::string & | arguments = std::string() | |||
) |
Evaluates a CLIPS function.
If the function could not be evaluated a zero-length vector is returned.
int CLIPS::Environment::load | ( | const std::string & | filename | ) |
Loads a set of constructs into the CLIPS data base.
bool CLIPS::Environment::save | ( | const std::string & | filename | ) |
Saves a set of constructs to the specified file.
bool CLIPS::Environment::auto_float_dividend_enabled | ( | ) |
Returns the current state of the auto-float dividend behavior.
When enabled, the dividend of the division function is automatically converted to a floating point number.
bool CLIPS::Environment::use_auto_float_dividend | ( | bool | use = true |
) |
Sets the auto-float dividend behavior.
When enabled, the dividend of the division function is automatically converted to a floating point number. Default is enabled.
bool CLIPS::Environment::dynamic_constraint_checking_enabled | ( | ) |
Returns the current state of the dynamic constraint checking behavior.
When enabled, slot values for newly created data objects are checked for constraint violations.
bool CLIPS::Environment::use_dynamic_constraint_checking | ( | bool | use = true |
) |
Sets the dynamic constraint checking behavior.
When enabled, slot values for newly created data objects are checked for constraint violations. Default is disabled.
bool CLIPS::Environment::sequence_operator_recognition_enabled | ( | ) |
Returns the current state of the sequence operator recognition behavior.
When enabled, multifield variables are expanded and passed as separate arguments in the function call.
bool CLIPS::Environment::use_sequence_operator_recognition | ( | bool | use = true |
) |
Sets the sequence operator recognition behavior.
When enabled, multifield variables are expanded and passed as separate arguments in the function call. Default is disabled.
bool CLIPS::Environment::static_constraint_checking_enabled | ( | ) |
Returns the current state of the static constraint checking behavior.
When enabled, constraint violations are checked when function calls and constructs are parsed.
bool CLIPS::Environment::use_static_constraint_checking | ( | bool | use = true |
) |
Sets the static constraint checking behavior.
When enabled, constraint violations are checked when function calls and constructs are parsed.
bool CLIPS::Environment::fact_duplication_enabled | ( | ) |
Returns the current state of the fact duplication behavior.
When disabled, asserting a duplicate of a fact in the fact-list will result in no effect. When enabled, a duplicate fact is asserted with a new fact-index. Default is disabled.
bool CLIPS::Environment::use_fact_duplication | ( | bool | use = true |
) |
Sets the static constraint checking behavior.
When enabled, constraint violations are checked when function calls and constructs are parsed.
bool CLIPS::Environment::is_dribble_active | ( | ) |
Determines if the storing of dribble information is active.
bool CLIPS::Environment::dribble_off | ( | ) |
Turns off the storing of dribble information.
bool CLIPS::Environment::dribble_on | ( | const std::string & | dribble_file | ) |
Allows the dribble function of CLIPS to be turned on.
int CLIPS::Environment::is_watched | ( | const std::string & | item | ) |
Determine if an item is being watched.
item | must be one of the following strings: facts, rules, activations, focus, compilations, statistics, globals, instances, slots, messages, message-handlers, generic-functions, method, or deffunctions. |
void CLIPS::Environment::refresh_agenda | ( | ) |
Refreshes the agenda for all modules.
Recomputes the salience values for all activations on the agenda and then reorders the agenda.
void CLIPS::Environment::refresh_agenda | ( | const Module & | module | ) |
Refreshes the agenda for a specific module.
Recomputes the salience values for all activations on the agenda and then reorders the agenda.
void CLIPS::Environment::refresh_agenda | ( | Module::pointer | module | ) |
Refreshes the agenda for a specific module.
Recomputes the salience values for all activations on the agenda and then reorders the agenda.
void CLIPS::Environment::reorder_agenda | ( | ) |
Reorders the agenda for all modules.
Reorders the agenda based on the current conflict resolution strategy and current activation saliences.
void CLIPS::Environment::reorder_agenda | ( | const Module & | module | ) |
Reorders the agenda for a specific module.
Reorders the agenda based on the current conflict resolution strategy and current activation saliences.
void CLIPS::Environment::reorder_agenda | ( | Module::pointer | module | ) |
Reorders the agenda for a specific module.
Reorders the agenda based on the current conflict resolution strategy and current activation saliences.
long int CLIPS::Environment::run | ( | long int | runlimit = -1 |
) |
Allows rules to execute.
runlimit | How many rules should fire If runlimit is negative, rules will fire until the agenda is empty. |
void CLIPS::Environment::run_threaded | ( | long int | runlimit = -1 , |
|
int | priority = 0 | |||
) |
Executes rules in a separate thread.
If an execution thread is already running, the job will be added to the run queue at the priority level specified. The higher the priority, the higher in the queue. After each execution, the run queue is checked and the next highest priority job is executed.
If the normal run() method is executing, the execution thread will be created, but will block until the previously executing call to run() is completed. After run() completes, the execution thread will unblock and start execution.
The methods of environment are not threadsafe yet. This is just an early look at threading, but making it threadsafe will not be too difficult. For now, to be safe, join the run thread before changing anything in the environment.
sigc::signal< void, long int > CLIPS::Environment::signal_run | ( | ) |
Signal emitted when the rules are executed.
The signal emits the number of rules executed.
SalienceEvaluation CLIPS::Environment::set_salience_evaluation | ( | SalienceEvaluation | se | ) |
Sets the salience evaluation mode.
ConflictResolution CLIPS::Environment::set_conflict_resolution_strategy | ( | ConflictResolution | cr | ) |
Sets the conflict resolution strategy.
bool CLIPS::Environment::check_agenda_changed | ( | ) |
Checks whether the agenda has changed and emits the agenda changed signal if it has.
The agenda does not include any callbacks when the agenda is changed. This method returns true if the agenda has changed and emits the agenda changed signal.
std::map<std::string,any> CLIPS::Environment::m_slots [protected] |
Holds any dynamically created slots.
Type any is used to hold different smart pointers, each of which hold different slots. When a slot is undefined, or at destruction when the map goes out of scope, the memory is reclaimed through the smart pointer.