![]() |
![]() |
![]() |
cpg-network Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
#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;
GEnum +----CpgNetworkLoadError
GEnum +----CpgNetworkFormat
GEnum +----CpgNetworkError
GObject +----CpgObject +----CpgGroup +----CpgNetwork
CpgNetwork implements CpgUsable, CpgAnnotatable, CpgLayoutable and CpgTaggable.
"file" GFile* : Read / Write / Construct "filename" gchar* : Read "integrator" CpgIntegrator* : Read / Write
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.
#define CPG_NETWORK_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CPG_TYPE_NETWORK, CpgNetwork const))
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.
syntax error | |
error occurred in loading a property | |
error occurred in loading an object | |
error occurred in loading a link | |
error occurred in loading a function | |
error occurred in an import | |
error occurred in an interface |
typedef enum { CPG_NETWORK_FORMAT_UNKNOWN, CPG_NETWORK_FORMAT_CPG, CPG_NETWORK_FORMAT_XML } CpgNetworkFormat;
typedef enum { CPG_NETWORK_ERROR_UNOWNED_TEMPLATE, CPG_NETWORK_ERROR_NUM } CpgNetworkError;
struct CpgNetworkClass { void (*compile_error) (CpgNetwork *network, CpgCompileError *error); };
The CpgNetwork class
CpgNetwork * cpg_network_new (void
);
Create a new empty CPG network
Returns : |
the newly created CPG network |
CpgNetwork * cpg_network_new_from_file (GFile *file
,GError **error
);
Create a new CPG network by reading the network definition from file
|
the file containing the network definition |
|
error return value |
Returns : |
the newly created CPG network or NULL if there was an
error reading the file |
CpgNetwork * cpg_network_new_from_stream (GInputStream *stream
,GError **error
);
Create a new CPG network by reading the network definition from a stream
|
the stream containing the network definition |
|
error return value |
Returns : |
the newly created CPG network or NULL if there was an
error reading the stream |
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.
|
The network file path |
|
A GError |
Returns : |
A CpgNetwork |
CpgNetwork * cpg_network_new_from_string (const gchar *s
,GError **error
);
Create a new CPG network from the network definition
|
definition of the network |
|
error return value |
Returns : |
the newly created CPG network or NULL if there was an
error |
gboolean cpg_network_load_from_file (CpgNetwork *network
,GFile *file
,GError **error
);
Load a network from a file
|
A CpgNetwork |
|
The file to load |
|
A GError |
Returns : |
TRUE if the file could be loaded, FALSE otherwise |
gboolean cpg_network_load_from_stream (CpgNetwork *network
,GInputStream *stream
,GError **error
);
Load a network from a stream
|
A CpgNetwork |
|
The stream to load |
|
A GError |
Returns : |
TRUE if the stream could be loaded, FALSE otherwise |
gboolean cpg_network_load_from_path (CpgNetwork *network
,const gchar *path
,GError **error
);
Load a network from a path into an existing network instance.
|
A CpgNetwork |
|
The filename of the file to load |
|
A GError |
Returns : |
TRUE if the path could be loaded, FALSE otherwise |
gboolean cpg_network_load_from_string (CpgNetwork *network
,const gchar *s
,GError **error
);
Load a network from text into an existing network instance.
|
A CpgNetwork |
|
A GError |
Returns : |
TRUE if the text could be loaded, FALSE otherwise |
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.
|
A GFile |
Returns : |
A CpgNetworkFormat |
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.
|
A GInputStream |
Returns : |
A CpgNetworkFormat |
GFile * cpg_network_get_file (CpgNetwork *network
);
Get the file with which the network was loaded.
|
A CpgNetwork |
Returns : |
The file or NULL if the network was not loaded from file. [transfer full][allow-none]
|
gchar * cpg_network_get_path (CpgNetwork *network
);
Get the path with which the network was loaded.
|
A CpgNetwork |
Returns : |
The path or NULL if the network was not loaded from file. [transfer full][allow-none]
|
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.
|
A CpgNetwork |
|
A CpgIntegrator |
CpgIntegrator * cpg_network_get_integrator (CpgNetwork *network
);
Get the integrator currently associated with the network.
|
A CpgNetwork |
Returns : |
A CpgIntegrator. [transfer none] |
void cpg_network_merge (CpgNetwork *network
,CpgNetwork *other
);
Merges all the globals, templates and objects from other
into network
.
|
a CpgNetwork |
|
a CpgNetwork to merge |
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
.
|
a CpgNetwork |
|
network file |
|
error return value |
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
.
|
a CpgNetwork |
|
network path |
|
error return value |
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
.
|
a CpgNetwork |
|
a string describing the network |
|
error return value |
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.
|
a CpgNetwork |
|
the simulation start time |
|
the integration time step to simulate with |
|
the simulation end time |
void cpg_network_step (CpgNetwork *network
,gdouble timestep
);
Perform one step of simulation given the specified timestep
.
|
a CpgNetwork |
|
the integration timestep |
CpgGroup * cpg_network_get_template_group (CpgNetwork *network
);
Get the group containing the templates.
|
A CpgNetwork |
Returns : |
A CpgGroup. [transfer none] |
"compile-error"
signalvoid user_function (CpgNetwork *network,
CpgCompileError *error,
gpointer user_data) : Run Last
Emitted when there is a compile error
|
a CpgNetwork |
|
a CpgCompileError |
|
user data set when the signal handler was connected. |