CpgObject

CpgObject — Basis for all cpg objects

Synopsis


#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);

Object Hierarchy

  GObject
   +----CpgObject
         +----CpgIntegrator
         +----CpgFunction
         +----CpgLink
         +----CpgState
         +----CpgRelay

Properties

  "id"                       gchar*                : Read / Write / Construct
  "local-id"                 gchar*                : Read
  "template"                 CpgObject*            : Read / Write / Construct

Signals

  "tainted"                                        : Run Last

Description

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.

Details

CPG_OBJECT_ERROR

#define CPG_OBJECT_ERROR (cpg_object_error_quark ())


enum CpgObjectError

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

CPG_OBJECT_ERROR_PROP_UNKNOWN

unknown

CPG_OBJECT_ERROR_PROP_NOT_FOUND

property not found

CPG_OBJECT_ERROR_PROP_IN_USE

property in use

CPG_OBJECT_NUM_ERRORS

num errors

CpgObjectClass

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

typedef struct _CpgObject CpgObject;


cpg_object_new ()

CpgObject *         cpg_object_new                      (const gchar *id);

Creates a new CpgObject.

id :

the object id

Returns :

the newly created CpgObject

cpg_object_get_id ()

const gchar *       cpg_object_get_id                   (CpgObject *object);

Gets the object id

object :

a CpgObject

Returns :

the object id

cpg_object_set_id ()

void                cpg_object_set_id                   (CpgObject *object,
                                                         const gchar *id);

Sets the object id

object :

a CpgObject

id :

the new object id

cpg_object_get_local_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

object :

a CpgObject

Returns :

the object local id

cpg_object_add_property ()

CpgProperty *       cpg_object_add_property             (CpgObject *object,
                                                         const gchar *name,
                                                         const gchar *expression,
                                                         gboolean integrated);

Returns the new property added to the object

object :

the CpgObject

name :

the property name

expression :

the properties initial value

integrated :

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

cpg_object_get_property ()

CpgProperty *       cpg_object_get_property             (CpgObject *object,
                                                         const gchar *name);

Get a CpgProperty from the object by name

object :

a CpgObject

name :

a property name

Returns :

the CpgProperty with name name, or NULL if no such property could be found

cpg_object_has_property ()

gboolean            cpg_object_has_property             (CpgObject *object,
                                                         const gchar *name);

Get whether object has a property with name name

object :

a CpgObject

name :

a property name

Returns :

TRUE if object has a property with name name, FALSE otherwise

cpg_object_remove_property ()

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

object :

a CpgObject

name :

a property name

error :

a GError

Returns :

TRUE if the property could be removed, FALSE otherwise

cpg_object_get_properties ()

GSList *            cpg_object_get_properties           (CpgObject *object);

Gets the object properties.

object :

a CpgObject

Returns :

a list of CpgProperty. The list is owned by the object and should not be freed.

cpg_object_reset ()

void                cpg_object_reset                    (CpgObject *object);

Reset all properties to their initial values

object :

the CpgObject

cpg_object_evaluate ()

void                cpg_object_evaluate                 (CpgObject *object);

Calculates update values for all the properties acted on by links

object :

the CpgObject

cpg_object_reset_cache ()

void                cpg_object_reset_cache              (CpgObject *object);

Reset object expression caches. This will reset all expressions (such as within properties) within the object

object :

a CpgObject

cpg_object_taint ()

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

object :

a CpgObject

cpg_object_compile ()

gboolean            cpg_object_compile                  (CpgObject *object,
                                                         CpgCompileContext *context,
                                                         CpgCompileError *error);

Compile the object.

object :

A CpgObject

context :

A CpgCompileContext

error :

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.

cpg_object_get_actors ()

GSList *            cpg_object_get_actors               (CpgObject *object);

Get the properties which are acted upon by links.

object :

A CpgObject

Returns :

A GSList of CpgProperty. This list is used internally and should not be freed.

Property Details

The "id" property

  "id"                       gchar*                : Read / Write / Construct

The CpgObject id

Default value: NULL


The "local-id" property

  "local-id"                 gchar*                : Read

The CpgObject local id

Default value: NULL


The "template" property

  "template"                 CpgObject*            : Read / Write / Construct

The CpgObject template on which the object is based

Signal Details

The "tainted" signal

void                user_function                      (CpgObject *object,
                                                        gpointer   user_data)      : Run Last

Emitted when the object is tainted

object :

a CpgObject

user_data :

user data set when the signal handler was connected.