Graphite  Version 3
An experimental 3D geometry processing program
OGF::Connection Class Referenceabstract

#include <OGF/gom/types/connection.h>

Inheritance diagram for OGF::Connection:
OGF::Callable OGF::Object GEO::Counted OGF::CallableConnection OGF::SlotConnection

Public Member Functions

 Connection (Object *source, const std::string &sig_name)
 Connection constructor. More...
 
virtual ~Connection ()
 Connection destructor.
 
virtual bool invoke (const ArgList &args, Any &ret_val)
 Invokes the target with an arguments list. More...
 
virtual bool invoke_target (const ArgList &args, Any &ret_val)=0
 Directly invokes the target with an arguments list, without any argument translation. More...
 
Objectsource () const
 Gets the source. More...
 
const std::string & signal_name () const
 Gets the signal name. More...
 
Connectionadd_arg (const std::string &name, const std::string &value)
 Adds an argument. More...
 
Connectionrename_arg (const std::string &name, const std::string &new_name)
 Renames an argument. More...
 
Connectiondiscard_arg (const std::string &name)
 Discards an argument. More...
 
void remove ()
 Removes this connection from the slot it is connected to.
 
- Public Member Functions inherited from OGF::Callable
 Callable ()
 Callable constructor.
 
 ~Callable () override
 Callable destructor.
 
bool invoke (const ArgList &args)
 Invokes a method by method name and argument list. More...
 
bool invoke ()
 Invokes a method by method name. More...
 
- Public Member Functions inherited from OGF::Object
 Object (bool transient=false)
 Object constructor. More...
 
virtual ~Object ()
 Object destructor.
 
virtual MetaClassmeta_class () const
 Gets the meta class. More...
 
virtual void set_meta_class (MetaClass *mclass)
 Sets the meta class. More...
 
unsigned int id () const
 Gets the identifier of this object. More...
 
std::string string_id () const
 Gets the unique string identifier. More...
 
bool has_method (const std::string &method_name) const
 Tests whether a method is defined. More...
 
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. More...
 
bool invoke_method (const std::string &method_name, const ArgList &args)
 Invokes a method by method name and argument list. More...
 
bool invoke_method (const std::string &method_name)
 Invokes a method by method name. More...
 
bool has_property (const std::string &prop_name) const
 Tests whether a property is defined. More...
 
virtual bool get_property (const std::string &prop_name, std::string &prop_value) const
 Gets a property. More...
 
virtual Connectionconnect_signal_to_slot (const std::string &signal_name, Object *to, const std::string &slot_name)
 Connects a signal with a slot of another object. More...
 
virtual void add_connection (Connection *connection)
 Adds a connection to this object. More...
 
virtual void remove_connection (Connection *connection)
 Removes a connection to this object. More...
 
virtual void get_element (index_t i, Any &value) const
 Gets an element by index. More...
 
virtual void set_element (index_t i, const Any &value)
 Sets an element by index. More...
 
virtual void search (const std::string &needle, const std::string &path="")
 Displays the names of all objects that contain a substring. More...
 
bool get_signals_enabled () const
 Tests wheter signals are enabled. More...
 
void set_signals_enabled (bool value)
 Enables or disables signals. More...
 
bool get_slots_enabled () const
 Tests wheter slots are enabled. More...
 
void set_slots_enabled (bool value)
 Enables or disables slots. More...
 
MetaClassget_meta_class () const
 Gets the meta class. More...
 
std::string get_string_id () const
 Gets the unique string identifier. More...
 
virtual std::string get_doc () const
 Gets the documentation. More...
 
virtual Sign compare (const Object *other) const
 Compares this object with another one. More...
 
virtual bool is_a (const MetaType *type) const
 Tests whether this object inherits a given type. More...
 
void disconnect ()
 Removes all connections from signals of this objects. More...
 
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. More...
 
virtual bool set_property (const std::string &name, const std::string &value)
 Sets an individual property. More...
 
void help () const
 Displays some help about this object. More...
 
virtual bool set_property (const std::string &name, const Any &value)
 Sets an individual property. More...
 
virtual bool get_property (const std::string &prop_name, Any &prop_value) const
 Gets a property. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Public Attributes

 __pad0__: Connection* if_arg( const std::string& name
 
const std::string & value
 
return this
 
- Public Attributes inherited from OGF::Object
 __pad0__: virtual index_t get_nb_elements() const
 
 __pad1__: bool equals(const Object* other) const
 

Protected Member Functions

bool test_arg_conditions (const ArgList &args) const
 Tests whether an argument list satisfies the argument conditions. More...
 
bool test_arg_condition (const std::string &value, const std::string &condition) const
 Tests whether an argument satisfies a condition. More...
 
void translate_args (const ArgList &args_in, ArgList &args_out)
 Applies all the argument list transformations. More...
 
- 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. More...
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from OGF::Object
static Objectid_to_object (unsigned int id)
 Gets an object from a unique object id. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Detailed Description

A connection connects a signal with a function. The arguments are matched between the signal and callable by their names. If argument names mismatch between the signal and the slot, a connection can rename/add/remove arguments before calling the target's slot. In addition, the target's slot can be invoked conditionally, depending of the value of some arguments.

Definition at line 66 of file connection.h.

Constructor & Destructor Documentation

◆ Connection()

OGF::Connection::Connection ( Object source,
const std::string &  sig_name 
)

Connection constructor.

Parameters
[in]sourcea pointer to the source object
[in]sig_namethe name of the source's signal

Member Function Documentation

◆ add_arg()

Connection* OGF::Connection::add_arg ( const std::string &  name,
const std::string &  value 
)
inline

Adds an argument.

Each time the signal is triggered, all the arguments specified by this function are added to the ArgList before being sent to the target's slot.

Parameters
[in]namename of the argument
[in]valuevalue of the argument
Returns
a pointer to this Connection.

Definition at line 154 of file connection.h.

◆ discard_arg()

Connection* OGF::Connection::discard_arg ( const std::string &  name)
inline

Discards an argument.

Each time the signal is triggered, all the arguments specified by this function are discarded before the ArgList is sent to the target's slot.

Parameters
[in]namename of the argument to be discarded
Returns
a pointer to this Connection.

Definition at line 194 of file connection.h.

◆ invoke()

virtual bool OGF::Connection::invoke ( const ArgList args,
Any ret_val 
)
virtual

Invokes the target with an arguments list.

The arguments are translated before being sent to the target.

Parameters
[in]argsa const reference to the arguments list
[out]ret_valon exit, contains "void".

Implements OGF::Callable.

◆ invoke_target()

virtual bool OGF::Connection::invoke_target ( const ArgList args,
Any ret_val 
)
pure virtual

Directly invokes the target with an arguments list, without any argument translation.

Parameters
[in]argsa const reference to the arguments list
[out]ret_valon exit, contains "void".

Implemented in OGF::CallableConnection, and OGF::SlotConnection.

◆ rename_arg()

Connection* OGF::Connection::rename_arg ( const std::string &  name,
const std::string &  new_name 
)
inline

Renames an argument.

Each time the signal is triggered, all the arguments specified by this function are renamed before being sent to the target's slot.

Parameters
[in]namename of the argument
[in]new_namenew name of the argument
Returns
a pointer to this Connection.

Definition at line 175 of file connection.h.

◆ signal_name()

const std::string& OGF::Connection::signal_name ( ) const
inline

Gets the signal name.

Returns
the name of the source signal.

Definition at line 115 of file connection.h.

◆ source()

Object* OGF::Connection::source ( ) const
inline

Gets the source.

Returns
a pointer to the source object.

Definition at line 107 of file connection.h.

◆ test_arg_condition()

bool OGF::Connection::test_arg_condition ( const std::string &  value,
const std::string &  condition 
) const
protected

Tests whether an argument satisfies a condition.

Parameters
[in]valuename of the argument
[in]conditionto be tested, it can be either the value to be tested for equality, or "==value", or "!=value".
Return values
trueif args satisfies the condition
falseotherwise
See also
add_arg_condition()

◆ test_arg_conditions()

bool OGF::Connection::test_arg_conditions ( const ArgList args) const
protected

Tests whether an argument list satisfies the argument conditions.

Parameters
[in]argsthe ArgList to be tested
Return values
trueif args satisfies all argument conditions
falseotherwise
See also
add_arg_condition()

◆ translate_args()

void OGF::Connection::translate_args ( const ArgList args_in,
ArgList args_out 
)
protected

Applies all the argument list transformations.

Parameters
[in]args_ina const reference to the input ArgList
[out]args_outa reference to the transformed ArgList
See also
add_arg(), discard_arg(), rename_arg()

Member Data Documentation

◆ value

const std::string& OGF::Connection::value
Initial value:
{
if(conditions_.has_arg(name)) {
Logger::err("GOM")
<< "if_arg(): duplicate condition for " << name
<< std::endl;
return this;
}
conditions_.create_arg(name, value)
Any & create_arg(const std::string &name)
Creates an uninitialized argument.
Definition: arg_list.h:259
bool has_arg(const std::string &name) const
Tests whether an argument of a given name exists in this ArgList.
Definition: arg_list.h:129

Definition at line 133 of file connection.h.


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