CpgNetwork

CpgNetwork — The main CPG network object

Synopsis

#define             CPG_NETWORK_CONST                   (obj)
#define             CPG_NETWORK_LOAD_ERROR
enum                CpgNetworkLoadError;
enum                CpgNetworkFormat;
#define             CPG_NETWORK_ERROR
enum                CpgNetworkError;
struct              CpgNetwork;
struct              CpgNetworkClass;
GQuark              cpg_network_load_error_quark        (void);
GQuark              cpg_network_error_quark             (void);
CpgNetwork *        cpg_network_new                     (void);
CpgNetwork *        cpg_network_new_from_file           (GFile *file,
                                                         GError **error);
CpgNetwork *        cpg_network_new_from_stream         (GInputStream *stream,
                                                         GError **error);
CpgNetwork *        cpg_network_new_from_path           (const gchar *path,
                                                         GError **error);
CpgNetwork *        cpg_network_new_from_string         (const gchar *s,
                                                         GError **error);
gboolean            cpg_network_load_from_file          (CpgNetwork *network,
                                                         GFile *file,
                                                         GError **error);
gboolean            cpg_network_load_from_stream        (CpgNetwork *network,
                                                         GInputStream *stream,
                                                         GError **error);
gboolean            cpg_network_load_from_path          (CpgNetwork *network,
                                                         const gchar *path,
                                                         GError **error);
gboolean            cpg_network_load_from_string        (CpgNetwork *network,
                                                         const gchar *s,
                                                         GError **error);
CpgNetworkFormat    cpg_network_format_from_file        (GFile *file);
CpgNetworkFormat    cpg_network_format_from_stream      (GInputStream *stream);
GFile *             cpg_network_get_file                (CpgNetwork *network);
gchar *             cpg_network_get_path                (CpgNetwork *network);
void                cpg_network_set_integrator          (CpgNetwork *network,
                                                         CpgIntegrator *integrator);
CpgIntegrator *     cpg_network_get_integrator          (CpgNetwork *network);
void                cpg_network_merge                   (CpgNetwork *network,
                                                         CpgNetwork *other);
void                cpg_network_merge_from_file         (CpgNetwork *network,
                                                         GFile *file,
                                                         GError **error);
void                cpg_network_merge_from_path         (CpgNetwork *network,
                                                         const gchar *path,
                                                         GError **error);
void                cpg_network_merge_from_string       (CpgNetwork *network,
                                                         const gchar *s,
                                                         GError **error);
void                cpg_network_run                     (CpgNetwork *network,
                                                         gdouble from,
                                                         gdouble timestep,
                                                         gdouble to);
void                cpg_network_step                    (CpgNetwork *network,
                                                         gdouble timestep);
CpgGroup *          cpg_network_get_template_group      (CpgNetwork *network);
                    CpgNetworkPrivate;

Object Hierarchy

  GEnum
   +----CpgNetworkLoadError
  GEnum
   +----CpgNetworkFormat
  GEnum
   +----CpgNetworkError
  GObject
   +----CpgObject
         +----CpgGroup
               +----CpgNetwork

Implemented Interfaces

CpgNetwork implements CpgUsable, CpgAnnotatable, CpgLayoutable and CpgTaggable.

Properties

  "file"                     GFile*                : Read / Write / Construct
  "filename"                 gchar*                : Read
  "integrator"               CpgIntegrator*        : Read / Write

Signals

  "compile-error"                                  : Run Last

Description

The cpg network is the main component of the cpg-network library. The network consists of CpgObject and CpgLink objects which combined make up the network.

The easiest way of using the library is to write the network using the XML representation (see xml-specification). You then create the network from file using cpg_network_new_from_file. To simulate the network, use cpg_network_run or for running single steps cpg_network_step.

For more information, see Making a network.

Details

CPG_NETWORK_CONST()

#define CPG_NETWORK_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), CPG_TYPE_NETWORK, CpgNetwork const))


CPG_NETWORK_LOAD_ERROR

#define CPG_NETWORK_LOAD_ERROR (cpg_network_load_error_quark ())


enum CpgNetworkLoadError

typedef enum
{
	CPG_NETWORK_LOAD_ERROR_NONE,
	CPG_NETWORK_LOAD_ERROR_SYNTAX,
	CPG_NETWORK_LOAD_ERROR_PROPERTY,
	CPG_NETWORK_LOAD_ERROR_OBJECT,
	CPG_NETWORK_LOAD_ERROR_LINK,
	CPG_NETWORK_LOAD_ERROR_FUNCTION,
	CPG_NETWORK_LOAD_ERROR_IMPORT,
	CPG_NETWORK_LOAD_ERROR_INPUT_FILE,
	CPG_NETWORK_LOAD_ERROR_INTERFACE
} CpgNetworkLoadError;

Network load error types.

CPG_NETWORK_LOAD_ERROR_NONE

CPG_NETWORK_LOAD_ERROR_SYNTAX

syntax error

CPG_NETWORK_LOAD_ERROR_PROPERTY

error occurred in loading a property

CPG_NETWORK_LOAD_ERROR_OBJECT

error occurred in loading an object

CPG_NETWORK_LOAD_ERROR_LINK

error occurred in loading a link

CPG_NETWORK_LOAD_ERROR_FUNCTION

error occurred in loading a function

CPG_NETWORK_LOAD_ERROR_IMPORT

error occurred in an import

CPG_NETWORK_LOAD_ERROR_INPUT_FILE

CPG_NETWORK_LOAD_ERROR_INTERFACE

error occurred in an interface

enum CpgNetworkFormat

typedef enum
{
	CPG_NETWORK_FORMAT_UNKNOWN,
	CPG_NETWORK_FORMAT_CPG,
	CPG_NETWORK_FORMAT_XML
} CpgNetworkFormat;


CPG_NETWORK_ERROR

#define CPG_NETWORK_ERROR (cpg_network_error_quark ())


enum CpgNetworkError

typedef enum
{
	CPG_NETWORK_ERROR_UNOWNED_TEMPLATE,
	CPG_NETWORK_ERROR_NUM
} CpgNetworkError;


struct CpgNetwork

struct CpgNetwork;


struct CpgNetworkClass

struct CpgNetworkClass {
	void (*compile_error) (CpgNetwork      *network,
	                       CpgCompileError *error);
};

The CpgNetwork class

compile_error ()

compile error default signal handler

cpg_network_load_error_quark ()

GQuark              cpg_network_load_error_quark        (void);


cpg_network_error_quark ()

GQuark              cpg_network_error_quark             (void);


cpg_network_new ()

CpgNetwork *        cpg_network_new                     (void);

Create a new empty CPG network

Returns :

the newly created CPG network

cpg_network_new_from_file ()

CpgNetwork *        cpg_network_new_from_file           (GFile *file,
                                                         GError **error);

Create a new CPG network by reading the network definition from file

file :

the file containing the network definition

error :

error return value

Returns :

the newly created CPG network or NULL if there was an error reading the file

cpg_network_new_from_stream ()

CpgNetwork *        cpg_network_new_from_stream         (GInputStream *stream,
                                                         GError **error);

Create a new CPG network by reading the network definition from a stream

stream :

the stream containing the network definition

error :

error return value

Returns :

the newly created CPG network or NULL if there was an error reading the stream

cpg_network_new_from_path ()

CpgNetwork *        cpg_network_new_from_path           (const gchar *path,
                                                         GError **error);

Create a new CPG network by reading the network definition from a file path. See cpg_network_new_from_file for more information.

path :

The network file path

error :

A GError

Returns :

A CpgNetwork

cpg_network_new_from_string ()

CpgNetwork *        cpg_network_new_from_string         (const gchar *s,
                                                         GError **error);

Create a new CPG network from the network definition

s :

definition of the network

error :

error return value

Returns :

the newly created CPG network or NULL if there was an error

cpg_network_load_from_file ()

gboolean            cpg_network_load_from_file          (CpgNetwork *network,
                                                         GFile *file,
                                                         GError **error);

Load a network from a file

network :

A CpgNetwork

file :

The file to load

error :

A GError

Returns :

TRUE if the file could be loaded, FALSE otherwise

cpg_network_load_from_stream ()

gboolean            cpg_network_load_from_stream        (CpgNetwork *network,
                                                         GInputStream *stream,
                                                         GError **error);

Load a network from a stream

network :

A CpgNetwork

stream :

The stream to load

error :

A GError

Returns :

TRUE if the stream could be loaded, FALSE otherwise

cpg_network_load_from_path ()

gboolean            cpg_network_load_from_path          (CpgNetwork *network,
                                                         const gchar *path,
                                                         GError **error);

Load a network from a path into an existing network instance.

network :

A CpgNetwork

path :

The filename of the file to load

error :

A GError

Returns :

TRUE if the path could be loaded, FALSE otherwise

cpg_network_load_from_string ()

gboolean            cpg_network_load_from_string        (CpgNetwork *network,
                                                         const gchar *s,
                                                         GError **error);

Load a network from text into an existing network instance.

network :

A CpgNetwork

error :

A GError

Returns :

TRUE if the text could be loaded, FALSE otherwise

cpg_network_format_from_file ()

CpgNetworkFormat    cpg_network_format_from_file        (GFile *file);

Determine the type of CPG format from a file. If the type of the file could not be determined, CPG_NETWORK_FORMAT_UNKNOWN is returned. This function only uses the mime type of a file. Use cpg_network_format_from_stream to determine the format from the contents.

file :

A GFile

Returns :

A CpgNetworkFormat

cpg_network_format_from_stream ()

CpgNetworkFormat    cpg_network_format_from_stream      (GInputStream *stream);

Determine the type of CPG format from a stream. This only works if either the stream is seekable (see GSeekable), or if the stream is a GBufferedInputStream. If needed, you can wrap your stream in a GBufferedInputStream before passing it.

stream :

A GInputStream

Returns :

A CpgNetworkFormat

cpg_network_get_file ()

GFile *             cpg_network_get_file                (CpgNetwork *network);

Get the file with which the network was loaded.

network :

A CpgNetwork

Returns :

The file or NULL if the network was not loaded from file. [transfer full][allow-none]

cpg_network_get_path ()

gchar *             cpg_network_get_path                (CpgNetwork *network);

Get the path with which the network was loaded.

network :

A CpgNetwork

Returns :

The path or NULL if the network was not loaded from file. [transfer full][allow-none]

cpg_network_set_integrator ()

void                cpg_network_set_integrator          (CpgNetwork *network,
                                                         CpgIntegrator *integrator);

Set the integrator used to integrate the network. Note that the network is automatically reset when the integrator is changed.

network :

A CpgNetwork

integrator :

A CpgIntegrator

cpg_network_get_integrator ()

CpgIntegrator *     cpg_network_get_integrator          (CpgNetwork *network);

Get the integrator currently associated with the network.

network :

A CpgNetwork

Returns :

A CpgIntegrator. [transfer none]

cpg_network_merge ()

void                cpg_network_merge                   (CpgNetwork *network,
                                                         CpgNetwork *other);

Merges all the globals, templates and objects from other into network.

network :

a CpgNetwork

other :

a CpgNetwork to merge

cpg_network_merge_from_file ()

void                cpg_network_merge_from_file         (CpgNetwork *network,
                                                         GFile *file,
                                                         GError **error);

Merges the network defined in the file file into network. This is similar to creating a network from a file and merging it with network.

network :

a CpgNetwork

file :

network file

error :

error return value

cpg_network_merge_from_path ()

void                cpg_network_merge_from_path         (CpgNetwork *network,
                                                         const gchar *path,
                                                         GError **error);

Merges the network defined in the file path into network. This is similar to creating a network from a file and merging it with network.

network :

a CpgNetwork

path :

network path

error :

error return value

cpg_network_merge_from_string ()

void                cpg_network_merge_from_string       (CpgNetwork *network,
                                                         const gchar *s,
                                                         GError **error);

Merges the network defined in s into network. This is similar to creating a network from xml and merging it with network.

network :

a CpgNetwork

s :

a string describing the network

error :

error return value

cpg_network_run ()

void                cpg_network_run                     (CpgNetwork *network,
                                                         gdouble from,
                                                         gdouble timestep,
                                                         gdouble to);

Perform a period of simulation. The period is determined by from, timestep and to as described above.

network :

a CpgNetwork

from :

the simulation start time

timestep :

the integration time step to simulate with

to :

the simulation end time

cpg_network_step ()

void                cpg_network_step                    (CpgNetwork *network,
                                                         gdouble timestep);

Perform one step of simulation given the specified timestep.

network :

a CpgNetwork

timestep :

the integration timestep

cpg_network_get_template_group ()

CpgGroup *          cpg_network_get_template_group      (CpgNetwork *network);

Get the group containing the templates.

network :

A CpgNetwork

Returns :

A CpgGroup. [transfer none]

CpgNetworkPrivate

typedef struct _CpgNetworkPrivate CpgNetworkPrivate;

Property Details

The "file" property

  "file"                     GFile*                : Read / Write / Construct

File.


The "filename" property

  "filename"                 gchar*                : Read

Filename.

Default value: NULL


The "integrator" property

  "integrator"               CpgIntegrator*        : Read / Write

Integrator.

Signal Details

The "compile-error" signal

void                user_function                      (CpgNetwork      *network,
                                                        CpgCompileError *error,
                                                        gpointer         user_data)      : Run Last

Emitted when there is a compile error

network :

a CpgNetwork

error :

a CpgCompileError

user_data :

user data set when the signal handler was connected.