void DataTreeView::nodeAdded( serialization::Node* a_pNode,serialization::Node* a_pParentNode) { o_connect(a_pNode, loaded(), this, nodeLoaded()); o_connect(a_pNode, aboutToBeUnloaded(), this, nodeAboutToBeUnloaded()); string name = nameOf(typeOf<serialization::Node>()).c_str(); // m_pDataBase->setNodeAttributeValue(a_pNode, m_uiNameAttributeIndex, name); addNodeItem(a_pNode); }
int main() { orientdb *oh; orientdb_con *oc; struct timeval tv; int rc; char str[O_ERR_MAXLEN]; long x; oh = o_new(); o_debug_setlevel(oh, ORIENT_DEBUG); o_debug_sethook(oh, &my_debug); //rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "192.168.1.100", "2424"); rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "127.0.0.1", "2424"); if (rc != O_OK) { o_strerr(rc, str, O_ERR_MAXLEN); fprintf(stderr, "Error preparing connections (%i): %s\n", rc, str); o_free(oh); return rc; } // this user will be used to execute administrative commands to orientdb rc = o_prepare_user(oh, ORIENT_ADMIN, "root", "test"); // this user will be used on database open to execute commands to the db rc = o_prepare_user(oh, ORIENT_USER, "admin", "admin"); // set a connection timeout of 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // try to create the connection with orientdb. NULL if a problem is encountered oc = o_connect(oh, &tv, 0); if (!oc) { o_free(oh); return 1; } // set a connection timeout of 5 seconds tv.tv_sec = 15; tv.tv_usec = 0; //rc = bin_dbopen(oh, oc, &tv, 0, "demo"); rc = o_bin_dbopen(oh, oc, &tv, 0, "test"); tv.tv_sec = 15; tv.tv_usec = 0; x = o_bin_dataclustercount(oh, oc, &tv, 0, 6); fprintf(stderr, "Cluster count: %ld\n", x); tv.tv_sec = 15; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; }
int main() { orientdb *oh; orientdb_con *oc; struct timeval tv; ODOC_OBJECT *odoc; int rc; char str[O_ERR_MAXLEN]; long position; int i; oh = o_new(); o_debug_setlevel(oh, ORIENT_DEBUG); //o_debug_setlevel(oh, ORIENT_CRITICAL); o_debug_sethook(oh, &my_debug); //rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "192.168.1.100", "2424"); rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "127.0.0.1", "2424"); if (rc != O_OK) { o_strerr(rc, str, O_ERR_MAXLEN); fprintf(stderr, "Error preparing connections (%i): %s\n", rc, str); o_free(oh); return rc; } // this user will be used to execute administrative commands to orientdb rc = o_prepare_user(oh, ORIENT_ADMIN, "root", "test"); // this user will be used on database open to execute commands to the db rc = o_prepare_user(oh, ORIENT_USER, "admin", "admin"); // set a connection timeout of 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // try to create the connection with orientdb. NULL if a problem is encountered oc = o_connect(oh, &tv, 0); if (!oc) { o_free(oh); return 1; } // set a connection timeout of 5 seconds tv.tv_sec = 15; tv.tv_usec = 0; rc = o_bin_dbopen(oh, oc, &tv, 0, "test"); tv.tv_sec = 15; tv.tv_usec = 0; // initialize a new document with the classname called "Class" ODOC_INITIALIZE_DOCUMENT(odoc, NULL); if (!odoc) { fprintf(stderr, "RECORD_CREATE: problem initializating document\n"); tv.tv_sec = 5; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; } odoc_setraw(odoc, "nully:,shorty:10s,inty:20,embeddeddocy:(stringyembeddy:\"Hello world!! This is a string\",intyembeddy:12345),binny:_SGVsbG8gd29ybGQhISBUaGlzIGlzIGEgc3RyaW5n_,collecty:[]", strlen("nully:,shorty:10s,inty:20,embeddeddocy:(stringyembeddy:\"Hello world!! This is a string\",intyembeddy:12345),binny:_SGVsbG8gd29ybGQhISBUaGlzIGlzIGEgc3RyaW5n_,collecty:[]")); tv.tv_sec = 3; tv.tv_usec = 0; position = o_bin_recordcreate(oh, oc, &tv, 0, 6, odoc, O_RECORD_DOC, O_RECSYNC); fprintf(stderr, "RECORD_CREATE: %ld\n", position); i = ODOC_FREE_DOCUMENT(odoc); tv.tv_sec = 10; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; }
int main() { orientdb *oh; orientdb_con *oc; struct timeval tv; int rc; char str[O_ERR_MAXLEN]; ODOC_OBJECT *odoc; short cluster_id; long cluster_position; // create the orientdb object oh = o_new(); // setup debug hook, so that my_debug() finction will be invoked each time the library has to say something useful o_debug_setlevel(oh, ORIENT_DEBUG); o_debug_sethook(oh, &my_debug); // prepare the connection to the database (no real connection will be made) rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "127.0.0.1", "2424"); if (rc != O_OK) { o_strerr(rc, str, O_ERR_MAXLEN); fprintf(stderr, "Error preparing connections (%i): %s\n", rc, str); o_free(oh); return rc; } // this user will be used to execute administrative commands to orientdb rc = o_prepare_user(oh, ORIENT_ADMIN, "root", "test"); // this user will be used on database open to execute commands to the db rc = o_prepare_user(oh, ORIENT_USER, "admin", "admin"); // set a connection timeout of 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // try to create the connection with orientdb. NULL if a problem is encountered oc = o_connect(oh, &tv, 0); if (!oc) { o_free(oh); return 1; } // set a timeout of 10 seconds tv.tv_sec = 10; tv.tv_usec = 0; // Open a database named "test" rc = o_bin_dbopen(oh, oc, &tv, 0, "test"); // set a timeout of 15 seconds tv.tv_sec = 15; tv.tv_usec = 0; // simulating a record id like #6:0 cluster_id = 6; cluster_position = 0; // get the document from the database odoc = o_bin_recordload(oh, oc, &tv, 0, cluster_id, cluster_position, "*:-1"); if (!odoc) { fprintf(stderr, "RECORD_LOAD: problem getting record\n"); tv.tv_sec = 5; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; } fprintf(stderr, "RECORD_LOAD: got a document: %s\n", odoc_getraw(odoc, NULL)); // free the returned document when you no longer need it ODOC_FREE_DOCUMENT(odoc); tv.tv_sec = 5; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; }