variant_type variant_converter<gl_sarray, void>::set(gl_sarray val) { if (USE_GL_DATATYPE) { return variant_type(std::dynamic_pointer_cast<model_base>(std::make_shared<gl_sarray>(val))); } else { return variant_type(std::shared_ptr<unity_sarray_base>(val)); } }
static void _check_types_disc(char *fname, int lmin, int lmax) { FILE *f = fopen(fname, "r"); if (!f) return; char *suffix = strrchr(fname, '.'); char qname[MAX_QNAME_SIZE]; int lchr, rchr, lstart, lend, rstart, rend; char lori, rori; int tmp; while (-1 < (tmp = fscanf(f, "%s\t%d\t%d\t%d\t%c\t%d\t%d\t%d\t%c\n", qname, &lchr, &lstart, &lend, &lori, &rchr, &rstart, &rend, &rori))) { switch (variant_type(lchr, rchr, ori2num(lori), ori2num(rori), lstart, rend, lmin, lmax)) { case INS: assert(!strcmp(".insertion", suffix)); break; case DEL: assert(!strcmp(".deletion", suffix)); break; case TRANS: assert(!strcmp(".translocation", suffix)); break; case INV: assert(!strcmp(".inversion", suffix)); break; case DIV: assert(!strcmp(".divergent", suffix)); break; case NUM_VTYPES: case CONC: assert(0); } } fclose(f); }
variant_type toolkit_class_base::get_value(std::string key, variant_map_type& arg) { perform_registration(); if (key == "list_functions") { return to_variant(list_functions()); } else if (key == "list_get_properties") { return to_variant(list_get_properties()); } else if (key == "list_set_properties") { return to_variant(list_set_properties()); } else if (key == "call_function") { // dispatches to a user defined function if (!arg.count("__function_name__")) { throw("Invalid function call format"); } std::string function_name = variant_get_value<std::string>(arg["__function_name__"]); return to_variant(call_function(function_name, arg)); } else if (key == "set_property") { // dispatches to a user defined set property if (!arg.count("__property_name__")) { throw("Invalid function call format"); } std::string property_name = variant_get_value<std::string>(arg["__property_name__"]); return to_variant(set_property(property_name, arg)); } else if (key == "get_property") { // dispatches to a user defined get property if (!arg.count("__property_name__")) { throw("Invalid function call format"); } std::string property_name = variant_get_value<std::string>(arg["__property_name__"]); return to_variant(get_property(property_name, arg)); } else if (key == "get_docstring") { // dispatches to a user defined get property if (!arg.count("__symbol__")) { throw("Invalid function call format"); } std::string symbol = variant_get_value<std::string>(arg["__symbol__"]); return to_variant(get_docstring(symbol)); } else if (key == "__name__") { return name(); } else if (key == "__uid__") { return uid(); } else { return variant_type(); } }
variant_type variant_converter<gl_gframe, void>::set(gl_gframe val) { return variant_type(std::shared_ptr<unity_sframe_base>(val)); };
variant_type variant_converter<gl_sgraph, void>::set(gl_sgraph val) { return variant_type(std::shared_ptr<unity_sgraph_base>(val)); };
variant_type variant_converter<std::shared_ptr<unity_sgraph>, void>::set(std::shared_ptr<unity_sgraph> val) { return variant_type(std::static_pointer_cast<unity_sgraph_base>(val)); }
static void _check_types_conc(char *fname, int lmin, int lmax) { FILE *f = fopen(fname, "r"); int lchr, lstart, rend; while (-1 < fscanf(f, "%d\t%d\t%d\n", &lchr, &lstart, &rend)) assert(CONC == variant_type(lchr, lchr, 0, 1, lstart, rend, lmin, lmax)); fclose(f); }