init.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2009 Soeren Sonnenburg
00008  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #include "lib/Mathematics.h"
00012 #include "base/init.h"
00013 #include "base/Parallel.h"
00014 #include "base/Version.h"
00015 
00016 CParallel* sg_parallel=NULL;
00017 CIO* sg_io=NULL;
00018 CVersion* sg_version=NULL;
00019 CMath* sg_math=NULL;
00020 
00022 void (*sg_print_message)(FILE* target, const char* str) = NULL;
00023 
00025 void (*sg_print_warning)(FILE* target, const char* str) = NULL;
00026 
00028 void (*sg_print_error)(FILE* target, const char* str) = NULL;
00029 
00031 void (*sg_cancel_computations)(bool &delayed, bool &immediately)=NULL;
00032 
00033 void init_shogun(void (*print_message)(FILE* target, const char* str),
00034         void (*print_warning)(FILE* target, const char* str),
00035         void (*print_error)(FILE* target, const char* str),
00036         void (*cancel_computations)(bool &delayed, bool &immediately))
00037 {
00038     if (!sg_io)
00039         sg_io = new CIO();
00040     if (!sg_parallel)
00041         sg_parallel=new CParallel();
00042     if (!sg_version)
00043         sg_version = new CVersion();
00044     if (!sg_math)
00045         sg_math = new CMath();
00046 
00047     SG_REF(sg_io);
00048     SG_REF(sg_parallel);
00049     SG_REF(sg_version);
00050     SG_REF(sg_math);
00051 
00052     sg_print_message=print_message;
00053     sg_print_warning=print_warning;
00054     sg_print_error=print_error;
00055     sg_cancel_computations=cancel_computations;
00056 }
00057 
00058 void exit_shogun()
00059 {
00060     sg_print_message=NULL;
00061     sg_print_warning=NULL;
00062     sg_print_error=NULL;
00063     sg_cancel_computations=NULL;
00064 
00065     SG_UNREF(sg_math);
00066     SG_UNREF(sg_version);
00067     SG_UNREF(sg_parallel);
00068     SG_UNREF(sg_io);
00069 };

SHOGUN Machine Learning Toolbox - Documentation