Version.h

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) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max Planck Society
00009  */
00010 
00011 #include "base/init.h"
00012 
00013 #include "lib/common.h"
00014 #include "lib/io.h"
00015 #include "lib/versionstring.h"
00016 #include "lib/config.h"
00017 
00018 #ifndef VERSION_H__
00019 #define VERSION_H__
00020 
00021 class CIO;
00022 
00029 class CVersion
00030 {
00031 public:
00032     CVersion();
00033     virtual ~CVersion();
00034 
00035     static inline void print_version()
00036     {
00037         SG_SPRINT("libshogun (%s/%s%d)\n\n", MACHINE, VERSION_RELEASE, version_revision);
00038         SG_SPRINT("Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max Planck Society\n");
00039         SG_SPRINT("Written   (W) 2000-2009 Soeren Sonnenburg, Gunnar Raetsch et al.\n\n");
00040 #ifdef GPL
00041         SG_SPRINT("This is free software; see the source for copying conditions.  There is NO\n");
00042         SG_SPRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
00043 #endif
00044         SG_SPRINT( "( configure options: \"%s\" compile flags: \"%s\" link flags: \"%s\" )\n", CONFIGURE_OPTIONS, COMPFLAGS_CPP, LINKFLAGS);
00045     }
00046 
00047     static inline const char* get_version_extra()
00048     {
00049         return version_extra;
00050     }
00051 
00052     static inline const char* get_version_release()
00053     {
00054         return version_release;
00055     }
00056 
00057     static inline int32_t get_version_revision()
00058     {
00059         return version_revision;
00060     }
00061 
00062     static inline int32_t get_version_year()
00063     {
00064         return version_year;
00065     }
00066 
00067     static inline int32_t get_version_month()
00068     {
00069         return version_month;
00070     }
00071 
00072     static inline int32_t get_version_day()
00073     {
00074         return version_day;
00075     }
00076 
00077     static inline int32_t get_version_hour()
00078     {
00079         return version_hour;
00080     }
00081 
00082     static inline int32_t get_version_minute()
00083     {
00084         return version_year;
00085     }
00086 
00087     static inline int64_t get_version_in_minutes()
00088     {
00089         return ((((version_year)*12 + version_month)*30 + version_day)* 24 + version_hour)*60 + version_minute;
00090     }
00091 
00092     inline int32_t ref()
00093     {
00094         ++refcount;
00095         return refcount;
00096     }
00097 
00098     inline int32_t ref_count() const
00099     {
00100         return refcount;
00101     }
00102 
00103     inline int32_t unref()
00104     {
00105         if (refcount==0 || --refcount==0)
00106         {
00107             delete this;
00108             return 0;
00109         }
00110         else
00111             return refcount;
00112     }
00113 
00114 protected:
00115     static const char version_release[128];
00116     static const char version_extra[128];
00117 
00118     static const int32_t version_revision;
00119     static const int32_t version_year;
00120     static const int32_t version_month;
00121     static const int32_t version_day;
00122     static const int32_t version_hour;
00123     static const int32_t version_minute;
00124 private:
00125     int32_t refcount;
00126 };
00127 #endif

SHOGUN Machine Learning Toolbox - Documentation