![]() |
![]() |
![]() |
cpg-network Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
#include <cpg-network/cpg-object.h> #define CPG_OBJECT_ERROR enum CpgObjectError; CpgObjectClass; CpgObject; CpgObject * cpg_object_new (const gchar *id); const gchar * cpg_object_get_id (CpgObject *object); void cpg_object_set_id (CpgObject *object, const gchar *id); gchar * cpg_object_get_local_id (CpgObject *object); CpgProperty * cpg_object_add_property (CpgObject *object, const gchar *name, const gchar *expression, gboolean integrated); CpgProperty * cpg_object_get_property (CpgObject *object, const gchar *name); gboolean cpg_object_has_property (CpgObject *object, const gchar *name); gboolean cpg_object_remove_property (CpgObject *object, const gchar *name, GError **error); GSList * cpg_object_get_properties (CpgObject *object); void cpg_object_reset (CpgObject *object); void cpg_object_evaluate (CpgObject *object); void cpg_object_reset_cache (CpgObject *object); void cpg_object_taint (CpgObject *object); gboolean cpg_object_compile (CpgObject *object, CpgCompileContext *context, CpgCompileError *error); GSList * cpg_object_get_actors (CpgObject *object);
GObject +----CpgObject +----CpgIntegrator +----CpgFunction +----CpgLink +----CpgState +----CpgRelay
"id" gchar* : Read / Write / Construct "local-id" gchar* : Read "template" CpgObject* : Read / Write / Construct
CpgObject is a base class for all the objects which can be added to a network. It provides property storage and virtual methods which can be implemented that drive the simulation process.
typedef enum { CPG_OBJECT_ERROR_PROP_UNKNOWN, CPG_OBJECT_ERROR_PROP_NOT_FOUND, CPG_OBJECT_ERROR_PROP_IN_USE, CPG_OBJECT_NUM_ERRORS } CpgObjectError;
Enum used to indicate an error when removing a property
typedef struct { gboolean (*compile) (CpgObject *object, CpgCompileContext *context, CpgCompileError *error); void (*reset) (CpgObject *object); void (*evaluate) (CpgObject *object); void (*tainted) (CpgObject *object); void (*reset_cache) (CpgObject *object); void (*copy) (CpgObject *object, CpgObject *source); } CpgObjectClass;
CpgObject * cpg_object_new (const gchar *id);
Creates a new CpgObject.
|
the object id |
Returns : |
the newly created CpgObject |
const gchar * cpg_object_get_id (CpgObject *object);
Gets the object id
|
a CpgObject |
Returns : |
the object id |
void cpg_object_set_id (CpgObject *object, const gchar *id);
Sets the object id
|
a CpgObject |
|
the new object id |
gchar * cpg_object_get_local_id (CpgObject *object);
Gets the object's local id. The local id is the last part of a dot-namespaced object name
|
a CpgObject |
Returns : |
the object local id |
CpgProperty * cpg_object_add_property (CpgObject *object, const gchar *name, const gchar *expression, gboolean integrated);
Returns the new property added to the object
|
the CpgObject |
|
the property name |
|
the properties initial value |
|
whether or not the update values should be integrated when a link acts on the property |
Returns : |
the new CpgProperty. The returned object is owned by
object and should not be freed
|
CpgProperty * cpg_object_get_property (CpgObject *object, const gchar *name);
Get a CpgProperty from the object by name
|
a CpgObject |
|
a property name |
Returns : |
the CpgProperty with name name , or NULL if no such property could
be found
|
gboolean cpg_object_has_property (CpgObject *object, const gchar *name);
Get whether object
has a property with name name
|
a CpgObject |
|
a property name |
Returns : |
TRUE if object has a property with name name , FALSE otherwise
|
gboolean cpg_object_remove_property (CpgObject *object, const gchar *name, GError **error);
Remove the property name
from object
. If the property was not found or
could not be removed, error
will be appropriately set
|
a CpgObject |
|
a property name |
|
a GError |
Returns : |
TRUE if the property could be removed, FALSE otherwise
|
GSList * cpg_object_get_properties (CpgObject *object);
Gets the object properties.
|
a CpgObject |
Returns : |
a list of CpgProperty. The list is owned by the object and should not be freed. |
void cpg_object_reset (CpgObject *object);
Reset all properties to their initial values
|
the CpgObject |
void cpg_object_evaluate (CpgObject *object);
Calculates update values for all the properties acted on by links
|
the CpgObject |
void cpg_object_reset_cache (CpgObject *object);
Reset object expression caches. This will reset all expressions (such as within properties) within the object
|
a CpgObject |
void cpg_object_taint (CpgObject *object);
Mark the object as tainted. This emits the "tainted" signal. The CpgNetwork in which the object is added acts on this signal to mark the network tainted and as such the object will be properly recompiled when the network needs to be simulated
|
a CpgObject |
gboolean cpg_object_compile (CpgObject *object, CpgCompileContext *context, CpgCompileError *error);
Compile the object.
|
A CpgObject |
|
A CpgCompileContext |
|
A CpgCompileError |
Returns : |
TRUE if the object compiled successfully, FALSE otherwise. If the
compilation failed and error was set, the reason for the compile
failure is set in error .
|
GSList * cpg_object_get_actors (CpgObject *object);
Get the properties which are acted upon by links.
|
A CpgObject |
Returns : |
A GSList of CpgProperty. This list is used internally and should not be freed. |