int objects_hierarchyMain(int argc, char *argv[]) { /* Create an object in the global object hierarchy */ corto_object *parent = corto_createChild(root_o, "parent", corto_void_o); if (!parent) { goto error; } /* Show information about the parent object */ printInfo(parent); /* Create an object in the scope of the parent object */ corto_object *child = corto_createChild(parent, "child", corto_void_o); if (!parent) { goto error; } /* Show information about the child object */ printInfo(child); /* Delete both the parent and child object */ if (corto_delete(parent)) { goto error; } return 0; error: corto_error("error: %s", corto_lasterr()); return -1; }
int dynamic_structMain(int argc, char *argv[]) { /* Create a new struct */ corto_struct Point = corto_declareChild(root_o, "Point", corto_struct_o); if (!Point) { goto error; } /* Create x member */ corto_member x = corto_declareChild(Point, "x", corto_member_o); if (!x) { goto error; } if (!corto_checkState(x, CORTO_DEFINED)) { corto_setref(&x->type, corto_int32_o); if (corto_define(x)) { goto error; } } /* Create y member */ corto_member y = corto_declareChild(Point, "y", corto_member_o); if (!y) { goto error; } if (!corto_checkState(y, CORTO_DEFINED)) { corto_setref(&y->type, corto_int32_o); if (corto_define(y)) { goto error; } } /* Finalize struct */ if (corto_define(Point)) { goto error; } /* Create an instance of Point */ corto_object p = corto_createChild(root_o, "p", Point); if (!p) { goto error; } *(corto_int32*)CORTO_OFFSET(p, x->offset) = 10; *(corto_int32*)CORTO_OFFSET(p, y->offset) = 20; printf("p = %s\n", corto_contentof(NULL, "text/corto", p)); return 0; error: corto_error("error: %s", corto_lasterr()); return -1; }
/* This is a managed file. Do not delete this comment. */ #include <include/test.h> void test_MountSubscription_tc_subscribeForMountWithTypeFilter( test_MountSubscription this) { corto_object mountRoot = corto_createChild(root_o, "mountRoot", corto_void_o); test_assert(mountRoot != NULL); corto_object obj1 = corto_createChild(mountRoot, "obj1", corto_int32_o); test_assert(obj1 != NULL); corto_object obj2 = corto_createChild(mountRoot, "obj2", corto_float32_o); test_assert(obj2 != NULL); /* Create a mount with a filter on int32 */ test_AutoResumeSinkMount m = test_AutoResumeSinkMountCreate(mountRoot, "int32", NULL); test_assert(m != NULL); /* Subscribe for scope in mountRoot: ok */ corto_subscriber s1 = corto_subscribe("*").from("/mountRoot") .callback(NULL); test_assert(s1 != NULL); test_assertint(corto_ll_size(m->subscribes), 1); test_assertint(corto_ll_size(m->unsubscribes), 0); /* Subscribe for scope in obj1: ok */ corto_subscriber s2 = corto_subscribe("obj1/*").from("/mountRoot") .callback(NULL);