Graphite  Version 3
An experimental 3D geometry processing program
OGF::Object Class Reference

Base class for all objects in the GOM system. More...

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

Inheritance diagram for OGF::Object:
GEO::Counted OGF::ApplicationBase OGF::ArcBall OGF::Callable OGF::Camera OGF::CheckerSphere OGF::DynamicObject OGF::FullScreenEffect OGF::Interface OGF::Interpreter OGF::MetaInformation OGF::NL::Blas OGF::NL::Library OGF::NL::Matrix OGF::NL::Vector OGF::Node OGF::RayPicker OGF::RenderArea OGF::SceneGraphShaderManager OGF::Scope OGF::ShaderManager OGF::TextEditor OGF::Transform3d OGF::Translation

Public Member Functions

 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...
 

Static Public Member Functions

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...
 

Public Attributes

 __pad0__: virtual index_t get_nb_elements() const
 
 __pad1__: bool equals(const Object* other) const
 

Protected Member Functions

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...
 

Friends

class MetaMethod
 

Detailed Description

Base class for all objects in the GOM system.

Definition at line 65 of file object.h.

Constructor & Destructor Documentation

◆ Object()

OGF::Object::Object ( bool  transient = false)
explicit

Object constructor.

Parameters
[in]transientif true, the object is transient. Transient objects have their id set to zero and are not referenced in the global id_to_object_ table.

Member Function Documentation

◆ add_connection()

virtual void OGF::Object::add_connection ( Connection connection)
virtual

Adds a connection to this object.

Parameters
[in]connectiona pointer to the connection to be added

◆ compare()

virtual Sign OGF::Object::compare ( const Object other) const
virtual

Compares this object with another one.

Default implementation compares addresses

Parameters
[in]otherthe other object to be compared
Return values
POSITIVEif this object is greater than other
ZEROif this object and other are equal
NEGATIVEif this object is lower than other

◆ connect_signal_to_slot()

virtual Connection* OGF::Object::connect_signal_to_slot ( const std::string &  signal_name,
Object to,
const std::string &  slot_name 
)
virtual

Connects a signal with a slot of another object.

Parameters
[in]signal_namename of the signal
[in]toa pointer to the receiver Object
[in]slot_namename of the receiver's slot
Returns
a pointer to the newly created Connection

◆ disconnect()

void OGF::Object::disconnect ( )

Removes all connections from signals of this objects.

Connections to slots of this object are kept.

◆ emit_signal()

virtual bool OGF::Object::emit_signal ( const std::string &  signal_name,
const ArgList args,
bool  called_from_slot = false 
)
protectedvirtual

Emits a signal and calls the slots it is connected to.

This function is used by GOMGEN to implement all the signal adapters, that marshall the signal's arguments in the argument list and calls the slots.

Parameters
[in]signal_namename of the signal
[in]argsa const reference to the arguments list
[in]called_from_slotdistingishes whether the signal was called after an event, or was called from client code. This can be used to implement a recording mechanism.

Reimplemented in OGF::MetaMethod.

◆ get_doc()

virtual std::string OGF::Object::get_doc ( ) const
virtual

Gets the documentation.

Returns
A string with a human-readable documentation about this object.

Reimplemented in OGF::Request, OGF::MetaMethod, and OGF::MetaClass.

◆ get_element()

virtual void OGF::Object::get_element ( index_t  i,
Any value 
) const
virtual

Gets an element by index.

Part of the array interface, used by operator[] in scripting language.

Parameters
[in]ithe index of the element, in [0..get_nb_elements()-1].
[out]valuethe element at index i.

Reimplemented in OGF::NL::Vector.

◆ get_meta_class()

MetaClass* OGF::Object::get_meta_class ( ) const
inline

Gets the meta class.

Returns
a pointer to the MetaClass of this object.

Definition at line 314 of file object.h.

◆ get_property() [1/2]

virtual bool OGF::Object::get_property ( const std::string &  prop_name,
Any prop_value 
) const
virtual

Gets a property.

Parameters
[in]prop_namename of the property
[out]prop_valuevalue of the property as a string
Return values
trueif the property could be sucessfully read
falseotherwise

Reimplemented in OGF::DynamicObject.

◆ get_property() [2/2]

virtual bool OGF::Object::get_property ( const std::string &  prop_name,
std::string &  prop_value 
) const
virtual

Gets a property.

Parameters
[in]prop_namename of the property
[out]prop_valuevalue of the property as a string
Return values
trueif the property could be sucessfully read
falseotherwise

◆ get_signals_enabled()

bool OGF::Object::get_signals_enabled ( ) const
inline

Tests wheter signals are enabled.

Return values
trueif signals are enabled
falseotherwise

Definition at line 279 of file object.h.

◆ get_slots_enabled()

bool OGF::Object::get_slots_enabled ( ) const
inline

Tests wheter slots are enabled.

Return values
trueif slots are enabled
falseotherwise

Definition at line 297 of file object.h.

◆ get_string_id()

std::string OGF::Object::get_string_id ( ) const
inline

Gets the unique string identifier.

The unique string identifier is composed of the class name and instance id.

Returns
the unique string identifier
See also
string_id(), id()

Definition at line 325 of file object.h.

◆ has_method()

bool OGF::Object::has_method ( const std::string &  method_name) const

Tests whether a method is defined.

Parameters
[in]method_namename of the property
Return values
trueif this Object has the method
falseotherwise

◆ has_property()

bool OGF::Object::has_property ( const std::string &  prop_name) const

Tests whether a property is defined.

Parameters
[in]prop_namename of the property
Return values
trueif this Object has the property
falseotherwise

◆ help()

void OGF::Object::help ( ) const

Displays some help about this object.

Outputs the doc property to the logger.

◆ id()

unsigned int OGF::Object::id ( ) const
inline

Gets the identifier of this object.

Each object instance has a unique identifier. This identifier is used by the object maps managed by each MetaClass. It is also used by the VCR mechanism that allows one to record and playback all the events in the system.

Returns
the unique identifier of this object
See also
string_id()

Definition at line 107 of file object.h.

◆ id_to_object()

static Object* OGF::Object::id_to_object ( unsigned int  id)
inlinestatic

Gets an object from a unique object id.

Parameters
[in]idthe object id.
Returns
a pointer to the object or nullptr if there is no such object.
See also
id().

Definition at line 226 of file object.h.

◆ invoke_method() [1/3]

bool OGF::Object::invoke_method ( const std::string &  method_name)
inline

Invokes a method by method name.

This variant of invoke() is for methods with no argument and void return type.

Parameters
[in]method_namename of the method
Return values
trueif the method could be sucessfully invoked
falseotherwise

Definition at line 168 of file object.h.

◆ invoke_method() [2/3]

bool OGF::Object::invoke_method ( const std::string &  method_name,
const ArgList args 
)
inline

Invokes a method by method name and argument list.

This variant of invoke() is for methods with void return type.

Parameters
[in]method_namename of the method
[in]argsa const reference to the ArgList
Return values
trueif the method could be sucessfully invoked
falseotherwise

Definition at line 153 of file object.h.

◆ invoke_method() [3/3]

virtual bool OGF::Object::invoke_method ( const std::string &  method_name,
const ArgList args,
Any ret_val 
)
virtual

Invokes a method by method name and argument list, and gets the return value.

Parameters
[in]method_namename of the method
[in]argsa const reference to the ArgList
[out]ret_valthe return value as an Any
Return values
trueif the method could be sucessfully invoked
falseotherwise

Reimplemented in OGF::Commands.

◆ is_a()

virtual bool OGF::Object::is_a ( const MetaType type) const
virtual

Tests whether this object inherits a given type.

Parameters
[in]typea const pointer to the MetaType to be tested.
Return values
trueif this object inherits type
falseotherwise

◆ meta_class()

virtual MetaClass* OGF::Object::meta_class ( ) const
virtual

Gets the meta class.

Returns
a pointer to the MetaClass of this object.

◆ remove_connection()

virtual void OGF::Object::remove_connection ( Connection connection)
virtual

Removes a connection to this object.

Parameters
[in]connectiona pointer to the connection to be removed

◆ search()

virtual void OGF::Object::search ( const std::string &  needle,
const std::string &  path = "" 
)
virtual

Displays the names of all objects that contain a substring.

Parameters
[in]needlethe substring
[in]paththe path to be prepended to the names

Reimplemented in OGF::MetaClass, OGF::Scope, OGF::MetaInformation, and OGF::Interpreter.

◆ set_element()

virtual void OGF::Object::set_element ( index_t  i,
const Any value 
)
virtual

Sets an element by index.

Part of the array interface, used by operator[] in scripting language.

Parameters
[in]ithe index of the element, in [0..get_nb_elements()-1].
[in]valuethe element at index i.

Reimplemented in OGF::NL::Vector.

◆ set_meta_class()

virtual void OGF::Object::set_meta_class ( MetaClass mclass)
virtual

Sets the meta class.

This function is automatically called by the factories generated by GOMGEN. User code does not need to use it.

Parameters
[in]mclassa pointer to the MetaClass

◆ set_properties()

void OGF::Object::set_properties ( const ArgList args)

Sets several properties in a single call.

Parameters
[in]argsa const reference to a set of name-value pairs

◆ set_property() [1/2]

virtual bool OGF::Object::set_property ( const std::string &  name,
const Any value 
)
virtual

Sets an individual property.

Parameters
[in]namename of the property
[in]valuevalue of the property as an Any
Return values
trueif the property could be sucessfully set
falseotherwise

Reimplemented in OGF::DynamicObject.

◆ set_property() [2/2]

virtual bool OGF::Object::set_property ( const std::string &  name,
const std::string &  value 
)
virtual

Sets an individual property.

Parameters
[in]namename of the property
[in]valuevalue of the property
Return values
trueif the property could be sucessfully set
falseotherwise

◆ set_signals_enabled()

void OGF::Object::set_signals_enabled ( bool  value)
inline

Enables or disables signals.

Parameters
[in]valuetrue if signals should be enabled, false if they should be disabled.

Definition at line 288 of file object.h.

◆ set_slots_enabled()

void OGF::Object::set_slots_enabled ( bool  value)
inline

Enables or disables slots.

Parameters
[in]valuetrue if slots should be enabled, false if they should be disabled.

Definition at line 306 of file object.h.

◆ string_id()

std::string OGF::Object::string_id ( ) const

Gets the unique string identifier.

The unique string identifier is composed of the class name and instance id.

Returns
the unique string identifier
See also
id()

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