CpgProperty

CpgProperty — Property container

Synopsis

#define             CPG_PROPERTY_CONST                  (obj)
enum                CpgPropertyFlags;
struct              CpgProperty;
struct              CpgPropertyClass;
CpgProperty *       cpg_property_new                    (const gchar *name,
                                                         const gchar *expression,
                                                         CpgPropertyFlags flags);
const gchar *       cpg_property_get_name               (CpgProperty *property);
gboolean            cpg_property_set_name               (CpgProperty *property,
                                                         const gchar *name);
gboolean            cpg_property_get_integrated         (CpgProperty *property);
void                cpg_property_set_integrated         (CpgProperty *property,
                                                         gboolean integrated);
CpgPropertyFlags    cpg_property_get_flags              (CpgProperty *property);
void                cpg_property_set_flags              (CpgProperty *property,
                                                         CpgPropertyFlags flags);
void                cpg_property_add_flags              (CpgProperty *property,
                                                         CpgPropertyFlags flags);
void                cpg_property_remove_flags           (CpgProperty *property,
                                                         CpgPropertyFlags flags);
void                cpg_property_reset                  (CpgProperty *property);
gdouble             cpg_property_get_value              (CpgProperty *property);
CpgExpression *     cpg_property_get_expression         (CpgProperty *property);
void                cpg_property_set_value              (CpgProperty *property,
                                                         gdouble value);
void                cpg_property_apply_constraint       (CpgProperty *property);
void                cpg_property_set_expression         (CpgProperty *property,
                                                         CpgExpression *expression);
void                cpg_property_set_constraint         (CpgProperty *property,
                                                         CpgExpression *expression);
CpgExpression *     cpg_property_get_constraint         (CpgProperty *property);
gboolean            cpg_property_equal                  (CpgProperty *property,
                                                         CpgProperty *other);
void                cpg_property_set_update             (CpgProperty *property,
                                                         gdouble value);
gdouble             cpg_property_get_update             (CpgProperty *property);
gchar *             cpg_property_flags_to_string        (CpgPropertyFlags add_flags,
                                                         CpgPropertyFlags remove_flags);
void                cpg_property_flags_from_string      (const gchar *flags,
                                                         CpgPropertyFlags *add_flags,
                                                         CpgPropertyFlags *remove_flags);
gchar *             cpg_property_get_full_name          (CpgProperty *property);
gchar *             cpg_property_get_full_name_for_display
                                                        (CpgProperty *property);
CpgProperty *       cpg_property_copy                   (CpgProperty *property);
                    CpgPropertyPrivate;

Object Hierarchy

  GFlags
   +----CpgPropertyFlags
  GObject
   +----GInitiallyUnowned
         +----CpgProperty

Implemented Interfaces

CpgProperty implements CpgUsable, CpgModifiable, CpgAnnotatable and CpgTaggable.

Properties

  "constraint"               CpgExpression*        : Read / Write / Construct
  "expression"               CpgExpression*        : Read / Write / Construct
  "flags"                    CpgPropertyFlags      : Read / Write / Construct
  "name"                     gchar*                : Read / Write / Construct
  "object"                   CpgObject*            : Read / Write / Construct

Signals

  "expression-changed"                             : Run Last
  "flags-changed"                                  : Run Last
  "invalidate-name"                                : Run Last

Description

A CpgProperty is a container for a specific variable in an object. It consists of a name and a mathematical expression describing its contents.

Details

CPG_PROPERTY_CONST()

#define CPG_PROPERTY_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), CPG_TYPE_PROPERTY, CpgProperty const))


enum CpgPropertyFlags

typedef enum
{
	CPG_PROPERTY_FLAG_NONE = 0,
	CPG_PROPERTY_FLAG_INTEGRATED = 1 << 0,
	CPG_PROPERTY_FLAG_IN = 1 << 1,
	CPG_PROPERTY_FLAG_OUT = 1 << 2,
	CPG_PROPERTY_FLAG_ONCE = 1 << 3,

	CPG_PROPERTY_FLAG_INOUT = CPG_PROPERTY_FLAG_IN | CPG_PROPERTY_FLAG_OUT
} CpgPropertyFlags;

Property flags.

CPG_PROPERTY_FLAG_NONE

none

CPG_PROPERTY_FLAG_INTEGRATED

integrated

CPG_PROPERTY_FLAG_IN

in

CPG_PROPERTY_FLAG_OUT

out

CPG_PROPERTY_FLAG_ONCE

once

CPG_PROPERTY_FLAG_INOUT

convenience for CPG_PROPERTY_FLAG_IN | CPG_PROPERTY_FLAG_OUT

struct CpgProperty

struct CpgProperty;


struct CpgPropertyClass

struct CpgPropertyClass {
	/* signals */
	gboolean (*invalidate_name) (CpgProperty *property,
	                             const gchar *name);

	void (*expression_changed) (CpgProperty      *property,
	                            CpgExpression    *expression);
	void (*flags_changed)      (CpgProperty      *property,
	                            CpgPropertyFlags  flags);
};


cpg_property_new ()

CpgProperty *       cpg_property_new                    (const gchar *name,
                                                         const gchar *expression,
                                                         CpgPropertyFlags flags);

Create a new property object. Property objects are assigned to CpgObject objects and are of little use on their own. The provided expression will not be parsed initially.

name :

the property name

expression :

the value expression

flags :

the property flags

Returns :

the new CpgProperty

cpg_property_get_name ()

const gchar *       cpg_property_get_name               (CpgProperty *property);

Get the property name

property :

a CpgProperty

Returns :

the property name. [transfer none]

cpg_property_set_name ()

gboolean            cpg_property_set_name               (CpgProperty *property,
                                                         const gchar *name);

Set a new name for a property.

property :

A CpgProperty

name :

The new property name

Returns :

TRUE if the name could be successfully changed, FALSE otherwise

cpg_property_get_integrated ()

gboolean            cpg_property_get_integrated         (CpgProperty *property);

Get whether the property should be integrated during evaluation or not. This is a convenience function that simply checks if the CPG_PROPERTY_FLAG_INTEGRATED flag is set.

property :

a CpgProperty

Returns :

TRUE if the property will be integrated, FALSE otherwise

cpg_property_set_integrated ()

void                cpg_property_set_integrated         (CpgProperty *property,
                                                         gboolean integrated);

Set whether the property should be integrated during evaluation or not. This is a convenience function that simply sets or unsets the CPG_PROPERTY_FLAG_INTEGRATED flag.

property :

a CpgProperty

integrated :

integrate the property

cpg_property_get_flags ()

CpgPropertyFlags    cpg_property_get_flags              (CpgProperty *property);

The property flags. The flags contains information on the type of property ( such as in, or out).

property :

A CpgProperty

Returns :

A CpgPropertyFlags

cpg_property_set_flags ()

void                cpg_property_set_flags              (CpgProperty *property,
                                                         CpgPropertyFlags flags);

Set the property flags.

property :

A CpgProperty

flags :

A CpgPropertyFlags

cpg_property_add_flags ()

void                cpg_property_add_flags              (CpgProperty *property,
                                                         CpgPropertyFlags flags);

Add a flags flag to the property flagss.

property :

A CpgProperty

flags :

A CpgPropertyFlags

cpg_property_remove_flags ()

void                cpg_property_remove_flags           (CpgProperty *property,
                                                         CpgPropertyFlags flags);

Remove a flags flag from the property flagss.

property :

A CpgProperty

flags :

A CpgPropertyFlags

cpg_property_reset ()

void                cpg_property_reset                  (CpgProperty *property);

Reset the property. This will reset the value of the property to the stored string representation.

property :

A CpgProperty

cpg_property_get_value ()

gdouble             cpg_property_get_value              (CpgProperty *property);

Get the numerical value of the current value of the property

property :

the CpgProperty

Returns :

the numerical value of the property's current value

cpg_property_get_expression ()

CpgExpression *     cpg_property_get_expression         (CpgProperty *property);

Get the property value expression

property :

a CpgProperty

Returns :

a CpgExpression. The expression is owned by the property and should not be freed. [transfer none]

cpg_property_set_value ()

void                cpg_property_set_value              (CpgProperty *property,
                                                         gdouble value);

Change the value to a specific number.

property :

the CpgProperty

value :

the new value

cpg_property_apply_constraint ()

void                cpg_property_apply_constraint       (CpgProperty *property);


cpg_property_set_expression ()

void                cpg_property_set_expression         (CpgProperty *property,
                                                         CpgExpression *expression);

Set the property value from an expression.

property :

a CpgProperty

expression :

the expression

cpg_property_set_constraint ()

void                cpg_property_set_constraint         (CpgProperty *property,
                                                         CpgExpression *expression);

Set the property constraint from an expression.

property :

a CpgProperty

expression :

the constraint expression

cpg_property_get_constraint ()

CpgExpression *     cpg_property_get_constraint         (CpgProperty *property);

Get the property value constraint expression

property :

a CpgProperty

Returns :

a CpgExpression. The expression is owned by the property and should not be freed. [transfer none]

cpg_property_equal ()

gboolean            cpg_property_equal                  (CpgProperty *property,
                                                         CpgProperty *other);

Compare two properties for equal values/expressions

property :

a CpgProperty

other :

a CpgProperty

Returns :

TRUE if the properties are equal, FALSE otherwise

cpg_property_set_update ()

void                cpg_property_set_update             (CpgProperty *property,
                                                         gdouble value);

Set the update value of the property. The update value is used to store the result of differential equations on the property/ You normally do not need to use this function.

property :

A CpgProperty

value :

The update value

cpg_property_get_update ()

gdouble             cpg_property_get_update             (CpgProperty *property);

Get the update value of a property. The update value is used to store the result of differential equations on the property. You normally do not need to use this function.

property :

A CpgProperty

Returns :

The update value

cpg_property_flags_to_string ()

gchar *             cpg_property_flags_to_string        (CpgPropertyFlags add_flags,
                                                         CpgPropertyFlags remove_flags);

Convert flags to a string representation.

Returns :

the string representation of the flags

cpg_property_flags_from_string ()

void                cpg_property_flags_from_string      (const gchar *flags,
                                                         CpgPropertyFlags *add_flags,
                                                         CpgPropertyFlags *remove_flags);

Parse a string into a set of property flags. The flags can be specified by their nicks (none, in, out, once, integrated) and separated by any combination of spaces, comma's and/or pipes.

flags :

The flags to parse

cpg_property_get_full_name ()

gchar *             cpg_property_get_full_name          (CpgProperty *property);

Get the full name of the property. This is the name that can be used in the outer most parent to refer to this property (i.e. cpg_group_find_property (top_parent, cpg_property_get_full_name (deep_property)) == deep_property)

property :

A CpgProperty

Returns :

The full name of the property. This is a newly allocated string that should be freed with g_free.

cpg_property_get_full_name_for_display ()

gchar *             cpg_property_get_full_name_for_display
                                                        (CpgProperty *property);


cpg_property_copy ()

CpgProperty *       cpg_property_copy                   (CpgProperty *property);

Make a copy of property.

property :

A CpgProperty

Returns :

A CpgProperty. [transfer full]

CpgPropertyPrivate

typedef struct _CpgPropertyPrivate CpgPropertyPrivate;

Property Details

The "constraint" property

  "constraint"               CpgExpression*        : Read / Write / Construct

Constraint.


The "expression" property

  "expression"               CpgExpression*        : Read / Write / Construct

The property expression


The "flags" property

  "flags"                    CpgPropertyFlags      : Read / Write / Construct

The property flags


The "name" property

  "name"                     gchar*                : Read / Write / Construct

The property name

Default value: NULL


The "object" property

  "object"                   CpgObject*            : Read / Write / Construct

The object on which the property is defined

Signal Details

The "expression-changed" signal

void                user_function                      (CpgProperty   *cpgproperty,
                                                        CpgExpression *arg1,
                                                        gpointer       user_data)        : Run Last

cpgproperty :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "flags-changed" signal

void                user_function                      (CpgProperty     *cpgproperty,
                                                        CpgPropertyFlags arg1,
                                                        gpointer         user_data)        : Run Last

cpgproperty :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "invalidate-name" signal

gboolean            user_function                      (CpgProperty *property,
                                                        gchar       *name,
                                                        gpointer     user_data)      : Run Last

This signal is emitted to validate (or rather, invalidate) a new name for a property. When a signal handler returns TRUE, the new name is rejected.

property :

a CpgProperty

name :

the new property name

user_data :

user data set when the signal handler was connected.

Returns :

TRUE if the new name should be rejected, FALSE otherwise