EXPORT CLASS *init(CALLBACKS *fntable, MODULE *module, int argc, char *argv[]) { PROPERTYTYPE p; if(sizeof(void *) == sizeof(int32)) p = PT_int32; if(sizeof(void *) == sizeof(int64)) p = PT_int64; // set the GridLAB core API callback table callback = fntable; gl_global_create("glmjava::classpath",PT_char256,get_classpath(),NULL); gl_global_create("glmjava::libpath",PT_char256,get_libpath(),NULL); gl_global_create("glmjava::jcallback",p,get_jcb(),PT_ACCESS,PA_REFERENCE,NULL); // default values strcpy(get_classpath(), "Win32/Debug/"); strcpy(get_libpath(), "Win32/Debug/"); // if(get_jvm() == NULL){ // gl_error("Unable to initialize JVM in java->init()"); // return NULL; // } // very nonstandard. return new_holder(module); }
///@todo 1.9 add error reporting bool manager::add_ai_for_side( side_number side, const std::string& ai_algorithm_type, bool replace ) { if (replace) { remove_ai_for_side (side); } config cfg; cfg["ai_algorithm"] = ai_algorithm_type; holder new_holder(side,cfg); std::stack<holder>& ai_stack_for_specific_side = get_or_create_ai_stack_for_side(side); ai_stack_for_specific_side.push(new_holder); return true; }
// ======================================================================= // AI HOLDERS // ======================================================================= holder& manager::get_active_ai_holder_for_side( side_number side ) { std::stack<holder>& ai_stack_for_specific_side = get_or_create_ai_stack_for_side(side); if (!ai_stack_for_specific_side.empty()){ return ai_stack_for_specific_side.top(); } else { config cfg = configuration::get_default_ai_parameters(); holder new_holder(side, cfg); ai_stack_for_specific_side.push(new_holder); return ai_stack_for_specific_side.top(); } }
bool manager::add_ai_for_side_from_config( side_number side, const config& cfg, bool replace ){ config parsed_cfg; configuration::parse_side_config(side, cfg, parsed_cfg); if (replace) { remove_ai_for_side(side); } holder new_holder(side,parsed_cfg); std::stack<holder>& ai_stack_for_specific_side = get_or_create_ai_stack_for_side(side); ai_stack_for_specific_side.push(new_holder); return true; }