//------------------------------------------------------------------------------------- bool Controllers::add(KBEShared_ptr<Controller> pController) { uint32 id = pController->id(); if(id == 0) { id = freeID(); } else { // Ë¢ÐÂid¼ÆÊýÆ÷ if(lastid_ <= id) lastid_ = id + 1; } objects_[id] = pController; pController->id(id); pController->pControllers(this); if(objects_.size() > 32) { WARNING_MSG(fmt::format("Controllers::add: size = {}.\n", objects_.size())); } return true; }
/* Associated an output with a process */ int addOutput(ProvObjectPtr p_prov, ProcessPtr p_proc, REFID output) { RecordPtr p_record = ((ProvPtr)p_prov)->p_record; IDREF id = newGeneratedByRecord(p_record, output, (IDREF)p_proc, NULL); assert(id); freeID(id); return(0); }
/* Associated a input with a process */ int addInput(ProvObjectPtr p_prov, ProcessPtr p_proc, REFID input) { RecordPtr p_record = ((ProvPtr)p_prov)->p_record; IDREF id = newUsedRecord(p_record, (IDREF)p_proc, input, NULL); assert(id); freeID(id); return(0); }
//------------------------------------------------------------------------------------- int16 DataDownloads::pushDownload(DataDownload* pdl) { pdl->id(freeID(pdl->id())); usedIDs_.insert(pdl->id()); downloads_[pdl->id()] = pdl; pdl->pDataDownloads(this); Baseapp::getSingleton().threadPool().addTask(pdl); return pdl->id(); }
/* Associate an output with a process */ REFID newProcessOutput(ProvObjectPtr p_prov, ProcessPtr p_proc, const char* name, const char* value, const char* type) { RecordPtr p_record = ((ProvPtr)p_prov)->p_record; IDREF id = newEntity(p_record); assert(id); if (type == NULL) addAttribute(p_record, id, "prov", "xsd:QName", "type", "ni:output"); else addAttribute(p_record, id, "prov", "xsd:string", "type", type); addAttribute(p_record, id, "ni", "xsd:string", "name", name); addAttribute(p_record, id, "ni", "xsd:string", "value", value); IDREF gen_id = newGeneratedByRecord(p_record, id, (IDREF)p_proc, NULL); assert(gen_id); freeID(gen_id); return((REFID)id); }
//------------------------------------------------------------------------------------- bool Controllers::add(Controller* pController) { uint32 id = pController->id(); if(id == 0) id = freeID(); objects_[id].reset(pController); pController->id(id); pController->pControllers(this); if(objects_.size() > 32) { WARNING_MSG(boost::format("Controllers::add: size = %1%.\n") % objects_.size()); } return true; }
/* A simple example on using the provenance library */ int main(int argc, char **argv, char** envp) { ProvPtr p_prov = newProvenanceFactory("1"); RecordPtr p_record = p_prov->p_record; IDREF id, act_id, used_id, genby_id; char arg[50]; int i; addNamespace(p_prov, "https://github.com/INCF/ProvenanceLibrary/wiki/terms", "ni"); // Add program information act_id = newActivity(p_record, NULL, "11/30/11 00:13:20.650432 EST", "11/30/11 00:13:20.650550 EST"); addAttribute(p_record, act_id, "prov", "xsd:string", "type", "program"); addAttribute(p_record, act_id, "ni", NULL, "name", argv[0]); addAttribute(p_record, act_id, "ni", NULL, "version", version); char * cmdline = get_cmdline(argc, argv); addAttribute(p_record, act_id, "ni", NULL, "cmdline", cmdline); free(cmdline); //Add all input parameters. if you use getopt this can be refined further for(i=1;i<argc; i++){ id = newEntity(p_record); addAttribute(p_record, id, "prov", "xsd:string", "type", "input"); sprintf(arg, "arg%d", i); addAttribute(p_record, id, NULL, NULL, arg, argv[i]); used_id = newUsedRecord(p_record, act_id, id, NULL); freeID(used_id); freeID(id); } id = newEntity(p_record); addAttribute(p_record, id, "prov", "xsd:string", "type", "environment"); // add all environment variables char** env; for (env = envp; *env != 0; env++) { char* thisEnv = *env; char *name; char* p_index = thisEnv; int pos = 0; while (thisEnv[pos++] != '='); name = strndup(thisEnv, pos-1); if (name[0] != '_') addAttribute(p_record, id, "ni", "xsd:string", name, &thisEnv[pos]); free(name); } freeID(id); id = newEntity(p_record); addAttribute(p_record, id, "prov", "xsd:string", "type", "runtime"); // add runtime info such as walltime, cputime, host, freeID(id); id = newEntity(p_record); addAttribute(p_record, id, "prov", "xsd:string", "type", "output:file"); addAttribute(p_record, id, "ni", NULL, "warped_file", "/full/path/to/file"); genby_id = newGeneratedByRecord(p_record, id, act_id, NULL); freeID(id); freeID(genby_id); id = newEntity(p_record); addAttribute(p_record, id, "prov", "xsd:string", "type", "output:stat"); addAttribute(p_record, id, "ni", NULL, "pearson_correlation_coefficient", ".234"); genby_id = newGeneratedByRecord(p_record, id, act_id, NULL); freeID(id); freeID(genby_id); freeID(act_id); /* Test i/o manipulations */ char *buffer; int bufsize; //print_provenance(p_prov, NULL); //fprintf(stdout, "==============\n"); print_provenance(p_prov, "testprov.xml"); dumpToMemoryBuffer(p_prov, &buffer, &bufsize); delProvenanceFactory(p_prov); p_prov = newProvenanceFactoryFromMemoryBuffer(buffer, bufsize); freeMemoryBuffer(buffer); delProvenanceFactory(p_prov); p_prov = newProvenanceFactoryFromFile("testprov.xml"); ProvPtr p_prov2 = newProvenanceFactory("1"); addProvAsAccount(p_prov2->p_record, p_prov, NULL); print_provenance(p_prov2, NULL); print_provenance(p_prov2, "testprov2.xml"); delProvenanceFactory(p_prov); delProvenanceFactory(p_prov2); return(0); }
int freeREFID(REFID id) { freeID((IDREF)id); return(0); }