Skip to content

Commit

Permalink
move inline functions from .h to .cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Oct 1, 2011
1 parent e338daa commit 85dadcf
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 107 deletions.
3 changes: 0 additions & 3 deletions src/interfaces/modular/Library.i
Expand Up @@ -185,7 +185,6 @@ namespace shogun
/* Include Class Headers to make them visible from within the target language */
/* Template Class DynamicArray */
%include <shogun/lib/DynamicArray.h>
%include <shogun/base/DynArray.h>
namespace shogun
{
%template(DynamicCharArray) CDynamicArray<char>;
Expand All @@ -208,8 +207,6 @@ namespace shogun
SERIALIZABLE_DUMMY(CDynamicArray<float32_t>);
%template(DynamicRealArray) CDynamicArray<float64_t>;
SERIALIZABLE_DUMMY(CDynamicArray<float64_t>);
%template(DynamicPlifArray) DynArray<shogun::CPlifBase*>;
SERIALIZABLE_DUMMY(DynArray<shogun::CPlifBase*>);
}
/* Template Class GCArray */
%include <shogun/lib/GCArray.h>
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/modular/SGBase.i
Expand Up @@ -89,7 +89,6 @@ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, jav
#include <shogun/base/Version.h>
#include <shogun/base/Parallel.h>
#include <shogun/base/SGObject.h>
#include <shogun/base/DynArray.h>

extern void sg_global_print_message(FILE* target, const char* str);
extern void sg_global_print_warning(FILE* target, const char* str);
Expand Down
35 changes: 35 additions & 0 deletions src/shogun/base/Parallel.cpp
Expand Up @@ -46,3 +46,38 @@ int32_t Parallel::get_num_cpus() const
#endif
return 1;
}

void Parallel::set_num_threads(int32_t n)
{
#ifndef HAVE_PTHREAD
ASSERT(n==1);
#endif
num_threads=n;
}

int32_t Parallel::get_num_threads() const
{
return num_threads;
}

int32_t Parallel::ref()
{
++refcount;
return refcount;
}

int32_t Parallel::ref_count() const
{
return refcount;
}

int32_t Parallel::unref()
{
if (refcount==0 || --refcount==0)
{
delete this;
return 0;
}
else
return refcount;
}
36 changes: 5 additions & 31 deletions src/shogun/base/Parallel.h
Expand Up @@ -59,55 +59,29 @@ class Parallel
/** set number of threads
* @param n number of threads
*/
inline void set_num_threads(int32_t n)
{
#ifndef HAVE_PTHREAD
ASSERT(n==1);
#endif
num_threads=n;
}
void set_num_threads(int32_t n);

/** get number of threads
* @return number of threads
*/
inline int32_t get_num_threads() const
{
return num_threads;
}
int32_t get_num_threads() const;

/** ref
* @return current ref counter
*/
inline int32_t ref()
{
++refcount;
return refcount;
}
int32_t ref();

/** get ref count
* @return current ref counter
*/
inline int32_t ref_count() const
{
return refcount;
}
int32_t ref_count() const;

/** unref
* @return current ref counter
*/
inline int32_t unref()
{
if (refcount==0 || --refcount==0)
{
delete this;
return 0;
}
else
return refcount;
}
int32_t unref();

private:

/** ref counter */
int32_t refcount;

Expand Down
106 changes: 106 additions & 0 deletions src/shogun/base/Version.cpp
Expand Up @@ -34,3 +34,109 @@ Version::Version() : refcount(0)
Version::~Version()
{
}

/** print version */
void Version::print_version()
{
SG_SPRINT("libshogun (%s/%s%d)\n\n", MACHINE, VERSION_RELEASE, version_revision);
SG_SPRINT("Copyright (C) 1999-2009 Fraunhofer Institute FIRST\n");
SG_SPRINT("Copyright (C) 1999-2011 Max Planck Society\n");
SG_SPRINT("Copyright (C) 2009-2011 Berlin Institute of Technology\n");
SG_SPRINT("Written (W) 1999-2011 Soeren Sonnenburg, Gunnar Raetsch et al.\n\n");
#ifndef USE_SVMLIGHT
SG_SPRINT("This is free software; see the source for copying conditions. There is NO\n");
SG_SPRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
#endif
SG_SPRINT( "( configure options: \"%s\" compile flags: \"%s\" link flags: \"%s\" )\n", CONFIGURE_OPTIONS, COMPFLAGS_CPP, LINKFLAGS);
}

/** get version extra */
const char* Version::get_version_extra()
{
return version_extra;
}

/** get version release */
const char* Version::get_version_release()
{
return version_release;
}

/** get version revision */
int32_t Version::get_version_revision()
{
return version_revision;
}

/** get version year */
int32_t Version::get_version_year()
{
return version_year;
}

/** get version month */
int32_t Version::get_version_month()
{
return version_month;
}

/** get version day */
int32_t Version::get_version_day()
{
return version_day;
}

/** get version hour */
int32_t Version::get_version_hour()
{
return version_hour;
}

/** get version minute */
int32_t Version::get_version_minute()
{
return version_year;
}

/** get version parameter */
int32_t Version::get_version_parameter()
{
return version_parameter;
}

/** get version in minutes */
int64_t Version::get_version_in_minutes()
{
return ((((version_year)*12 + version_month)*30 + version_day)* 24 + version_hour)*60 + version_minute;
}

/** ref object
* @return ref count
*/
int32_t Version::ref()
{
++refcount;
return refcount;
}

/** ref count
* @return ref count
*/
int32_t Version::ref_count() const
{
return refcount;
}

/** unref object
* @return ref count
*/
int32_t Version::unref()
{
if (refcount==0 || --refcount==0)
{
delete this;
return 0;
}
else
return refcount;
}
87 changes: 15 additions & 72 deletions src/shogun/base/Version.h
Expand Up @@ -37,110 +37,52 @@ class Version
virtual ~Version();

/** print version */
static inline void print_version()
{
SG_SPRINT("libshogun (%s/%s%d)\n\n", MACHINE, VERSION_RELEASE, version_revision);
SG_SPRINT("Copyright (C) 1999-2009 Fraunhofer Institute FIRST\n");
SG_SPRINT("Copyright (C) 1999-2011 Max Planck Society\n");
SG_SPRINT("Copyright (C) 2009-2011 Berlin Institute of Technology\n");
SG_SPRINT("Written (W) 1999-2011 Soeren Sonnenburg, Gunnar Raetsch et al.\n\n");
#ifndef USE_SVMLIGHT
SG_SPRINT("This is free software; see the source for copying conditions. There is NO\n");
SG_SPRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
#endif
SG_SPRINT( "( configure options: \"%s\" compile flags: \"%s\" link flags: \"%s\" )\n", CONFIGURE_OPTIONS, COMPFLAGS_CPP, LINKFLAGS);
}
static void print_version();

/** get version extra */
static inline const char* get_version_extra()
{
return version_extra;
}
static const char* get_version_extra();

/** get version release */
static inline const char* get_version_release()
{
return version_release;
}
static const char* get_version_release();

/** get version revision */
static inline int32_t get_version_revision()
{
return version_revision;
}
static int32_t get_version_revision();

/** get version year */
static inline int32_t get_version_year()
{
return version_year;
}
static int32_t get_version_year();

/** get version month */
static inline int32_t get_version_month()
{
return version_month;
}
static int32_t get_version_month();

/** get version day */
static inline int32_t get_version_day()
{
return version_day;
}
static int32_t get_version_day();

/** get version hour */
static inline int32_t get_version_hour()
{
return version_hour;
}
static int32_t get_version_hour();

/** get version minute */
static inline int32_t get_version_minute()
{
return version_year;
}
static int32_t get_version_minute();

/** get version parameter */
static inline int32_t get_version_parameter()
{
return version_parameter;
}
static int32_t get_version_parameter();

/** get version in minutes */
static inline int64_t get_version_in_minutes()
{
return ((((version_year)*12 + version_month)*30 + version_day)* 24 + version_hour)*60 + version_minute;
}
static int64_t get_version_in_minutes();

/** ref object
* @return ref count
*/
inline int32_t ref()
{
++refcount;
return refcount;
}
int32_t ref();

/** ref count
* @return ref count
*/
inline int32_t ref_count() const
{
return refcount;
}
int32_t ref_count() const;

/** unref object
* @return ref count
*/
inline int32_t unref()
{
if (refcount==0 || --refcount==0)
{
delete this;
return 0;
}
else
return refcount;
}
int32_t unref();

protected:
/** version release */
Expand All @@ -162,6 +104,7 @@ class Version
static const int32_t version_minute;
/** version parameter */
static const int32_t version_parameter;

private:
int32_t refcount;
};
Expand Down

0 comments on commit 85dadcf

Please sign in to comment.