|
Graphite Version 3
An experimental 3D geometry processing program
|
Abstract base class for the GOM interpreter. More...
#include <OGF/gom/interpreter/interpreter.h>
Public Member Functions | |
| Interpreter () | |
| Interpreter constructor. | |
| virtual void | reset ()=0 |
| Clears all variables, restarts from initial state. | |
| virtual Any | resolve (const std::string &id, bool quiet=true) const |
| Finds a variable by id. | |
| virtual void | bind (const std::string &id, const Any &value)=0 |
| Binds a value to a variable. | |
| virtual void | list_names (std::vector< std::string > &names) const |
| Lists the global variable names in this Interpreter.. | |
| virtual Any | eval (const std::string &expression, bool quiet=true) const |
| Evaluates a string with an expression. | |
| void | inspect_meta_type (MetaType *meta_type) |
| Outputs to the logger the methods, slots, properties of a given MetaClass. | |
| void | list_classes () |
| Outputs to the logger the names of all classes registered to GOM. | |
| void | bind_object (const std::string &id, Object *object) |
| Binds an object to a variable. | |
| Object * | resolve_object (const std::string &id, bool quiet=true) const |
| Finds an objet by id. | |
| Object * | resolve_object_by_global_id (const std::string &id, bool quiet=true) const |
| Finds an objet by global id. | |
| Object * | eval_object (const std::string &expression, bool quiet=true) const |
| Evaluates a string with an expression. | |
| std::string | eval_string (const std::string &expression, bool quiet=true) const |
| Evaluates a string with an expression. | |
| virtual MetaType * | resolve_meta_type (const std::string &type_name) const |
| Finds a MetaType by name. | |
| virtual bool | bind_meta_type (MetaType *mtype) |
| Binds a MetaType. | |
| virtual Object * | create (const ArgList &args) |
| Creates an object. | |
| virtual std::string | get_environment_value (const std::string &name) |
| Gets the value of a Geogram environment value. | |
| virtual void | set_environment_value (const std::string &name, const std::string &value) |
| Sets the value of an environment variable. | |
| virtual bool | execute (const std::string &command, bool save_in_history=true, bool log=true)=0 |
| Executes a single line of code in the interpreted language. | |
| virtual bool | execute_file (const std::string &file_name) |
| Executes commands from a given file. | |
| virtual void | out (const std::string &message, const std::string &tag="GOM") |
| Displays a message in the terminal or console. | |
| virtual void | err (const std::string &message, const std::string &tag="GOM") |
| Displays an error message in the terminal or console. | |
| virtual void | warn (const std::string &message, const std::string &tag="GOM") |
| Displays a warning message in the terminal or console. | |
| virtual void | status (const std::string &message) |
| Displays a status message. | |
| virtual void | append_dynamic_libraries_path (const std::string &path) |
| Adds a path where dynamic libraries can be loaded. | |
| virtual bool | load_module (const std::string &module_name) |
| Loads a plug-in. | |
| virtual Connection * | connect (Request *from, Callable *to) |
| Connects a signal to a callable. | |
| Interpreter * | interpreter (const std::string &language) |
| Gets an interpreter for a given language. | |
| Interpreter * | interpreter_by_file_extension (const std::string &extension) |
| Gets an interpreter for a given language by file extension. | |
| void | search (const std::string &needle, const std::string &path="") override |
| Displays the names of all objects that contain a substring. | |
| const std::string & | get_language () const |
| Gets the name of the interpreted language. | |
| const std::string & | get_filename_extension () const |
| Gets the filename extensions for the interpreted language. | |
| Scope * | get_globals () const |
| Gets the Scope with the global variables. | |
| Scope * | get_meta_types () const |
| Gets the Scope with the meta types. | |
| ~Interpreter () override | |
| Interpreter destructor. | |
| Object * | create (const std::string &classname, const ArgList &args) |
| Creates an object from a classname and arguments list. | |
| virtual void | automatic_completion (const std::string &line, index_t startw, index_t endw, const std::string &cmpword, std::vector< std::string > &matches) |
| Gets the possible automatic completions from a partial command entered by the user in the command line. | |
| virtual void | save_history (const std::string &file_name) const |
| Saves the history to a file. | |
| virtual void | clear_history () |
| Clears the history. | |
| void | add_to_history (const std::string &command) |
| Adds a command line to the history. | |
| size_t | history_size () const |
| Gets the size of the history. | |
| std::string | history_line (unsigned int l) const |
| Gets one of the commands in the history by line index. | |
Public Member Functions inherited from OGF::Object | |
| Object (bool transient=false) | |
| Object constructor. | |
| ~Object () override | |
| Object destructor. | |
| virtual MetaClass * | meta_class () const |
| Gets the meta class. | |
| virtual void | set_meta_class (MetaClass *mclass) |
| Sets the meta class. | |
| unsigned int | id () const |
| Gets the identifier of this object. | |
| std::string | string_id () const |
| Gets the unique string identifier. | |
| bool | has_method (const std::string &method_name) const |
| Tests whether a method is defined. | |
| virtual bool | invoke_method (const std::string &method_name, const ArgList &args, Any &ret_val) |
| Invokes a method by method name and argument list, and gets the return value. | |
| bool | invoke_method (const std::string &method_name, const ArgList &args) |
| Invokes a method by method name and argument list. | |
| bool | invoke_method (const std::string &method_name) |
| Invokes a method by method name. | |
| bool | has_property (const std::string &prop_name) const |
| Tests whether a property is defined. | |
| virtual bool | get_property (const std::string &prop_name, std::string &prop_value) const |
| Gets a property. | |
| virtual Connection * | connect_signal_to_slot (const std::string &signal_name, Object *to, const std::string &slot_name) |
| Connects a signal with a slot of another object. | |
| virtual void | add_connection (Connection *connection) |
| Adds a connection to this object. | |
| virtual void | remove_connection (Connection *connection) |
| Removes a connection to this object. | |
| virtual void | get_element (index_t i, Any &value) const |
| Gets an element by index. | |
| virtual void | set_element (index_t i, const Any &value) |
| Sets an element by index. | |
| void | get_element (index_t item, index_t component, Any &value) const |
| Gets an element by item and component. | |
| void | set_element (index_t item, index_t component, const Any &value) |
| Sets an element by item and component. | |
| virtual index_t | get_dimension () const |
| Gets the number of elements per item. | |
| bool | get_signals_enabled () const |
| Tests wheter signals are enabled. | |
| void | set_signals_enabled (bool value) |
| Enables or disables signals. | |
| bool | get_slots_enabled () const |
| Tests wheter slots are enabled. | |
| void | set_slots_enabled (bool value) |
| Enables or disables slots. | |
| MetaClass * | get_meta_class () const |
| Gets the meta class. | |
| std::string | get_string_id () const |
| Gets the unique string identifier. | |
| virtual std::string | get_doc () const |
| Gets the documentation. | |
| virtual Sign | compare (const Object *other) const |
| Compares this object with another one. | |
| virtual bool | is_a (const MetaType *type) const |
| Tests whether this object inherits a given type. | |
| void | disconnect () |
| Removes all connections from signals of this objects. | |
| void | enable_signals () |
| Enables signals. | |
| void | disable_signals () |
| Disables signals. | |
| void | enable_slots () |
| Enables slots. | |
| void | disable_slots () |
| Disables slots. | |
| void | set_properties (const ArgList &args) |
| Sets several properties in a single call. | |
| virtual bool | set_property (const std::string &name, const std::string &value) |
| Sets an individual property. | |
| void | help () const |
| Displays some help about this object. | |
| virtual bool | set_property (const std::string &name, const Any &value) |
| Sets an individual property. | |
| virtual bool | get_property (const std::string &prop_name, Any &prop_value) const |
| Gets a property. | |
Public Member Functions inherited from GEO::Counted | |
| void | ref () const |
| Increments the reference count. | |
| void | unref () const |
| Decrements the reference count. | |
| bool | is_shared () const |
| Check if the object is shared. | |
| int | nb_refs () const |
| Gets the number of references that point to this object. | |
Static Public Member Functions | |
| static Interpreter * | default_interpreter () |
| Gets the default interpreter. | |
| static Interpreter * | instance_by_language (const std::string &language) |
| Gets the instance of the interpreter that interprets a given language. | |
| static Interpreter * | instance_by_file_extension (const std::string &extension) |
| Gets the instance of the interpreter by file extension. | |
| static void | initialize (Interpreter *instance, const std::string &language, const std::string &extension) |
| Initializes the interpreter subsystem, and defines the interpreter to be used. | |
| static void | terminate (const std::string &language, const std::string &extension) |
| Terminates an interpreter and removes a given language from the list of interpreters. | |
| static void | terminate () |
| Terminates the interpreter subsystem, and deallocates the interpreter. | |
Static Public Member Functions inherited from OGF::Object | |
| static Object * | id_to_object (unsigned int id) |
| Gets an object from a unique object id. | |
Static Public Member Functions inherited from GEO::Counted | |
| static void | ref (const Counted *counted) |
| Increments the reference count. | |
| static void | unref (const Counted *counted) |
| Decrements the reference count. | |
Public Attributes | |
| : void inspect(Object* object) | |
| : virtual std::string get_history() const | |
Public Attributes inherited from OGF::Object | |
| : virtual index_t get_nb_elements() const | |
| : bool equals(const Object* other) const | |
Protected Member Functions | |
| void | filename_completion (const std::string &prefix, std::vector< std::string > &completions) |
| Gets all possible filenames starting from a certain prefix. | |
| void | filter_completion_candidates (const std::string &prefix, std::vector< std::string > &completions) |
| Keeps in a list of completion only those that start with a given prefix. | |
| virtual void | get_keys (const std::string &context, std::vector< std::string > &keys) |
| Gets all possible keys in a certain context. | |
| virtual void | get_keys (Any &context, std::vector< std::string > &keys) |
| Gets all possible keys in a certain context. | |
| void | inspect_method (Object *object, MetaMethod *mmethod) |
| Displays the prototype of a given method of an object. | |
| void | inspect_meta_class (Object *object, MetaClass *mclass) |
| Displays a meta class. | |
| void | inspect_meta_method (MetaMethod *mmethod) |
| Outputs to the logger the signature of a method. | |
| void | set_language (const std::string &language) |
| Sets the name of the interpreted language. | |
| void | set_filename_extension (const std::string &extension) |
| Sets the filename extensions for the interpreted language. | |
| virtual std::string | stringify (const std::string &str) const |
| Transforms a string into a string constant in the interpreted language. | |
| virtual std::string | name_value_pair_call (const std::string &args) const |
| Transforms a list of name-value pairs arguments. | |
Protected Member Functions inherited from OGF::Object | |
| virtual bool | emit_signal (const std::string &signal_name, const ArgList &args, bool called_from_slot=false) |
| Emits a signal and calls the slots it is connected to. | |
Protected Member Functions inherited from GEO::Counted | |
| Counted () | |
| Creates a reference counted object. | |
| virtual | ~Counted () |
| Destroys a reference counted object. | |
Protected Attributes | |
| std::vector< std::string > | history_ |
| std::string | language_ |
| std::string | extension_ |
Abstract base class for the GOM interpreter.
It is completely independent of the used interpreted language. It is implemented in the gel_lua (and upcoming gel_python libraries).
Definition at line 222 of file interpreter.h.
| void OGF::Interpreter::add_to_history | ( | const std::string & | command | ) |
Adds a command line to the history.
| [in] | command | the command line to be added to the history |
|
virtual |
Adds a path where dynamic libraries can be loaded.
Under Windows, adds the path to the PATH environment variable. Under other OSes, does nothing.
| [in] | path | the path to be added. |
|
virtual |
Gets the possible automatic completions from a partial command entered by the user in the command line.
| [in] | line | the command line to be completed. |
| [in] | startw,endw | the position of the word to be completed. |
| [in] | cmpword | the word to be completed |
| [out] | matches | the possible completions. |
|
pure virtual |
Binds a value to a variable.
The variable is then visible from the interpreter in the global scope.
| [in] | id | the name of the variable. |
| [in] | value | the value of the variable to be bound. |
Implemented in OGF::LuaInterpreter.
|
virtual |
| void OGF::Interpreter::bind_object | ( | const std::string & | id, |
| Object * | object | ||
| ) |
Binds an object to a variable.
The object is then visible from the interpreter in the global scope.
| [in] | id | the name of the variable. |
| [in] | object | the object to be bound |
|
virtual |
Creates an object.
| [in] | args | the ArgList, with at least an argument classname. The other arguments are passed to the constructor. |
Creates an object from a classname and arguments list.
| [in] | classname | the classname, with the 'OGF::' scope. |
| [in] | args | the arguments list. |
|
inlinestatic |
Gets the default interpreter.
Definition at line 521 of file interpreter.h.
|
virtual |
Displays an error message in the terminal or console.
| [in] | message | the message to be displayed. |
| [in] | tag | an optional tag. |
|
virtual |
Evaluates a string with an expression.
| [in] | expression | a string with an expression. |
| [in] | quiet | if true, do not display error messages. |
Reimplemented in OGF::LuaInterpreter.
| Object * OGF::Interpreter::eval_object | ( | const std::string & | expression, |
| bool | quiet = true |
||
| ) | const |
Evaluates a string with an expression.
| [in] | expression | a string with an expression. |
| [in] | quiet | if true, do not display error messages. |
| std::string OGF::Interpreter::eval_string | ( | const std::string & | expression, |
| bool | quiet = true |
||
| ) | const |
Evaluates a string with an expression.
| [in] | expression | a string with an expression. |
| [in] | quiet | if true, do not display error messages. |
|
pure virtual |
Executes a single line of code in the interpreted language.
| [in] | command | the line of code |
| [in] | save_in_history | true if the command should be saved in the history |
| [in] | log | true if the command should be displayed to the logging console |
| true | if the command could be sucessfully executed |
| false | otherwise |
Implemented in OGF::LuaInterpreter.
|
virtual |
Executes commands from a given file.
| [in] | file_name | name of the file that contains the commands to be executed |
| true | if the file could be sucessfully executed |
| false | otherwise |
Reimplemented in OGF::LuaInterpreter.
|
protected |
Gets all possible filenames starting from a certain prefix.
| [in] | prefix | either en empty string, or an escaped string with the beginning of a filename. |
| [out] | completions | all the filenames that match the input prefix. |
|
protected |
Keeps in a list of completion only those that start with a given prefix.
| [in] | prefix | the prefix |
| [in,out] | completions | the vector of strings to be filtered. On exit, only those that start with prefix are kept. |
|
virtual |
Gets the value of a Geogram environment value.
| [in] | name | name of the variable |
|
inline |
Gets the filename extensions for the interpreted language.
Definition at line 546 of file interpreter.h.
|
inline |
Gets the Scope with the global variables.
Definition at line 554 of file interpreter.h.
|
protectedvirtual |
Gets all possible keys in a certain context.
| [in] | context | the name of a variable. |
| [out] | keys | the name of all the data members and function members of the variable. |
|
protectedvirtual |
Gets all possible keys in a certain context.
| [in] | context | the name of a variable. |
| [out] | keys | the name of all the data members and function members of the variable. |
Reimplemented in OGF::LuaInterpreter.
|
inline |
Gets the name of the interpreted language.
Definition at line 537 of file interpreter.h.
|
inline |
Gets the Scope with the meta types.
Definition at line 562 of file interpreter.h.
|
inline |
Gets one of the commands in the history by line index.
| [in] | l | the index of the line in the history |
Definition at line 680 of file interpreter.h.
|
inline |
Gets the size of the history.
Definition at line 671 of file interpreter.h.
|
static |
Initializes the interpreter subsystem, and defines the interpreter to be used.
This function is called at Graphite startup by the library that creates the interpreter (gel_python2 or gel_python3). Client code is not supposed to call this function directly.
| [in] | instance | the interpreter to be used. |
| [in] | language | the name of the interpreted language. |
| [in] | extension | file extension for the interpreted language, without the point. |
Displays a meta class.
The meta class is displayed by the Logger.
| [in] | object | the object. |
| [in] | mclass | the meta class. |
|
protected |
Outputs to the logger the signature of a method.
| [in] | mmethod | a pointer to the MetaMethod. |
| void OGF::Interpreter::inspect_meta_type | ( | MetaType * | meta_type | ) |
|
protected |
Displays the prototype of a given method of an object.
The prototype is displayed by the Logger.
| [in] | object | the object |
| [in] | mmethod | the method |
|
static |
Gets the instance of the interpreter by file extension.
| [in] | extension | file extension without the dot. |
|
static |
Gets the instance of the interpreter that interprets a given language.
| [in] | language | the interpreted language. |
|
inline |
Gets an interpreter for a given language.
| [in] | language | "Lua" for lua, "Python" for python... |
Definition at line 495 of file interpreter.h.
|
inline |
Gets an interpreter for a given language by file extension.
| [in] | extension | "lua" for lua, "py" for python... |
Definition at line 503 of file interpreter.h.
|
virtual |
Lists the global variable names in this Interpreter..
| [out] | names | a vector of strings with the names of the global variables. |
Reimplemented in OGF::LuaInterpreter.
|
virtual |
Loads a plug-in.
| [in] | module_name | the name of the plug-in. |
| true | if the module was successfully loaded. |
| false | otherwise. |
|
protectedvirtual |
Transforms a list of name-value pairs arguments.
Some interpreters (e.g., Lua) need special syntax for name-value pair calls. Default implementation returns the input string.
| [in] | args | a set of comma-separated name-value pairs. |
Reimplemented in OGF::LuaInterpreter.
|
virtual |
Displays a message in the terminal or console.
| [in] | message | the message to be displayed. |
| [in] | tag | an optional tag. |
|
pure virtual |
Clears all variables, restarts from initial state.
Implemented in OGF::LuaInterpreter.
|
virtual |
Finds a variable by id.
| [in] | id | the id, can be either a previously bound id defined in the interpreter, or an id of the form "@ClassName::#instance", where ClassName is the name of a class registered to GOM, and instance an integer that refers to a specific instance of that class (the latter form of ids is used by the VCR system for recording events received by the GUI widgets). |
| [in] | quiet | if true, do not display error messages. |
id in the current Scope, or nil if there is no such a variable. Reimplemented in OGF::LuaInterpreter.
|
virtual |
| Object * OGF::Interpreter::resolve_object | ( | const std::string & | id, |
| bool | quiet = true |
||
| ) | const |
Finds an objet by id.
| [in] | id | the id, can be either a previously bound id defined in the interpreter, or an id of the form "@ClassName::#instance", where ClassName is the name of a class registered to GOM, and instance an integer that refers to a specific instance of that class. |
| [in] | quiet | if true, do not display error messages. |
| Object * OGF::Interpreter::resolve_object_by_global_id | ( | const std::string & | id, |
| bool | quiet = true |
||
| ) | const |
Finds an objet by global id.
| [in] | id | the id in the form "@ClassName::#instance", where ClassName is the name of a class registered to GOM, and instance an integer that refers to a specific instance of that class. |
| [in] | quiet | if true, do not display error messages. |
|
virtual |
Saves the history to a file.
| [in] | file_name | name of the file where the history should be saved. |
|
overridevirtual |
Displays the names of all objects that contain a substring.
| [in] | needle | the substring |
| [in] | path | the path to be prepended to the names |
Reimplemented from OGF::Object.
|
virtual |
Sets the value of an environment variable.
| [in] | name | name of the variable |
| [in] | value | new value of the environment variable |
|
inlineprotected |
Sets the filename extensions for the interpreted language.
| [in] | extension | the extension. |
Definition at line 764 of file interpreter.h.
|
inlineprotected |
Sets the name of the interpreted language.
| [in] | language | the name of the interpreted language. |
Definition at line 756 of file interpreter.h.
|
virtual |
Displays a status message.
| [in] | message | the message. |
|
protectedvirtual |
Transforms a string into a string constant in the interpreted language.
Default implementation adds single quotes.
| [in] | str | the string to be transformed. |
|
static |
Terminates the interpreter subsystem, and deallocates the interpreter.
This function is called at Graphite shutdown. Client code is not supposed to call this function directly.
|
static |
Terminates an interpreter and removes a given language from the list of interpreters.
| [in] | language | the name of the language to be terminated. |
| [in] | extension | file extension for the interpreted language, without the point. |
|
virtual |
Displays a warning message in the terminal or console.
| [in] | message | the message to be displayed. |
| [in] | tag | an optional tag. |
| OGF::Interpreter::__pad0__ |
Definition at line 274 of file interpreter.h.
| OGF::Interpreter::__pad1__ |
Definition at line 521 of file interpreter.h.
|
protected |
Definition at line 791 of file interpreter.h.
|
protected |
Definition at line 789 of file interpreter.h.
|
protected |
Definition at line 790 of file interpreter.h.