update API accodring to the Cyberiada-GraphML-1.0 standard + write to YED format

This commit is contained in:
Alexey Fedoseev
2024-03-23 20:29:34 +03:00
parent 65407577ff
commit 70bf382c73
3 changed files with 1297 additions and 277 deletions

View File

@@ -33,27 +33,26 @@ extern "C" {
/* SM node types: */
typedef enum {
cybNodeSM = 0, /* state machine */
cybNodeSimpleState, /* simple state */
cybNodeCompositeState, /* composite state */
cybNodeSubmachineState, /* submachine state */
cybNodeComment, /* comment node */
cybNodeInitial, /* initial pseudostate */
cybNodeFinal, /* final pseudostate */
cybNodeChoice, /* final pseudostate */
cybNodeJunction, /* junction pseudostate */
cybNodeEntry, /* entry pseudostate */
cybNodeExit, /* exit pseudostate */
cybNodeHistory, /* shallow history pseudostate */
cybNodeDeepHistory, /* deep history pseudostate */
cybNodeFork, /* fork pseudostate */
cybNodeJoin, /* join pseudostate */
cybNodeTerminate, /* terminate pseudostate */
cybNodeSM = 0, /* state machine */
cybNodeSimpleState = 1, /* simple state */
cybNodeCompositeState = 2, /* composite state */
cybNodeSubmachineState = 4, /* submachine state */
cybNodeComment = 8, /* comment node */
cybNodeInitial = 16, /* initial pseudostate */
cybNodeFinal = 32, /* final pseudostate */
cybNodeChoice = 64, /* final pseudostate */
cybNodeEntry = 128, /* entry pseudostate */
cybNodeExit = 256, /* exit pseudostate */
cybNodeShallowHistory = 512, /* shallow history pseudostate */
cybNodeTerminate = 1024, /* terminate pseudostate */
} CyberiadaNodeType;
typedef unsigned int CyberiadaNodeTypeMask;
/* SM node types: */
typedef enum {
cybEdgeTransition = 0,
cybEdgeComment = 1,
} CyberiadaEdgeType;
/* SM behavior types: */
@@ -61,7 +60,7 @@ typedef enum {
cybBehaviorTransition = 0,
cybBehaviorEntry = 1,
cybBehaviorExit = 2,
cybBehaviorDo = 3,
cybBehaviorDo = 4,
} CyberiadaBehaviorType;
/* SM node & transitions geometry */
@@ -126,34 +125,47 @@ typedef struct _CyberiadaEdge {
struct _CyberiadaEdge* next;
} CyberiadaEdge;
/* SM extentions
typedef struct _CyberiadaExtension {
char* id;
size_t id_len;
char* title;
size_t title_len;
char* data;
size_t data_len;
struct _CyberiadaExtension* next;
} CyberiadaExtension;*/
/* SM metainformation */
typedef struct {
char* standard_version; /* HSM standard version (required parameter) */
size_t standard_version_len;
char* platform_name; /* target platform name */
size_t platform_name_len;
char* platform_version; /* target platform version */
size_t platform_version_len;
char* platform_language; /* target platform language */
size_t platform_language_len;
char* target_system; /* target system controlled by the SM */
size_t target_system_len;
char* name; /* document name */
size_t name_len;
char* author; /* document author */
size_t author_len;
char* contact; /* document author's contact */
size_t contact_len;
char* description; /* document description */
size_t description_len;
char* version; /* document version */
size_t version_len;
char* date; /* document date */
size_t date_len;
char actions_order_flag; /* actions order flag (0 = not set, 1 = transition first, 2 = exit first) */
char event_propagation_flag; /* event propagation flag (0 = not set, 1 = block events, 2 = propagate events) */
} CyberiadaMetainformation;
/* SM graph (state machine) */
typedef struct {
char* name;
size_t name_len;
char* version;
size_t version_len;
char* info;
size_t info_len;
char* format; /* SM graph format string */
size_t format_len; /* SM graph format string length */
CyberiadaMetainformation* meta_info;
CyberiadaNode* nodes;
CyberiadaEdge* edges;
/* CyberiadaExtension* extensions;*/
} CyberiadaSM;
/* SM GraphML supported formats */
typedef enum {
cybxmlYED = 0,
cybxmlCyberiada,
cybxmlCyberiada = 0,
cybxmlYED,
cybxmlUnknown
} CyberiadaXMLFormat;
@@ -165,9 +177,10 @@ typedef enum {
#define CYBERIADA_XML_ERROR 1
#define CYBERIADA_FORMAT_ERROR 2
#define CYBERIADA_BEHAVIOR_FORMAT_ERROR 3
#define CYBERIADA_NOT_FOUND 4
#define CYBERIADA_BAD_PARAMETER 5
#define CYBERIADA_ASSERT 6
#define CYBERIADA_METADATA_FORMAT_ERROR 4
#define CYBERIADA_NOT_FOUND 5
#define CYBERIADA_BAD_PARAMETER 6
#define CYBERIADA_ASSERT 7
/* -----------------------------------------------------------------------------
* The Cyberiada GraphML library functions
@@ -176,16 +189,19 @@ typedef enum {
/* Allocate the SM structure in memory (for heap usage) */
CyberiadaSM* cyberiada_create_sm(void);
/* Initialize the SM structure. Do not use the structure before the initialization! */
/* Initialize the SM structure. */
/* Do not use the structure before the initialization! */
int cyberiada_init_sm(CyberiadaSM* sm);
/* Cleanup the content of the SM structure, free the conents memory */
/* Cleanup the content of the SM structure */
/* Free the allocated memory of the structure content but not the structure itself */
int cyberiada_cleanup_sm(CyberiadaSM* sm);
/* Free the allocated SM structure (for heap usage) */
/* Free the allocated SM structure with the content (for heap usage) */
int cyberiada_destroy_sm(CyberiadaSM* sm);
/* Read an XML file and decode the SM structure */
/* Allocate the SM structure first */
int cyberiada_read_sm(CyberiadaSM* sm, const char* filename, CyberiadaXMLFormat format);
/* Encode the SM structure and write the data to an XML file */