12 #ifndef __SGOBJECT_H__
13 #define __SGOBJECT_H__
39 class CSerializableFile;
41 template <
class T,
class K>
class CMap;
48 #ifdef USE_REFERENCE_COUNTING
49 #define SG_REF(x) { if (x) (x)->ref(); }
50 #define SG_UNREF(x) { if (x) { if ((x)->unref()==0) (x)=NULL; } }
51 #define SG_UNREF_NO_NULL(x) { if (x) { (x)->unref(); } }
55 #define SG_UNREF_NO_NULL(x)
62 #define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N
63 #define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1)
65 #define VARARG_IMPL2(base, count, ...) base##count(__VA_ARGS__)
66 #define VARARG_IMPL(base, count, ...) VARARG_IMPL2(base, count, __VA_ARGS__)
67 #define VARARG(base, ...) VARARG_IMPL(base, VA_NARGS(__VA_ARGS__), __VA_ARGS__)
69 #define SG_ADD4(param, name, description, ms_available) {\
70 m_parameters->add(param, name, description);\
72 m_model_selection_parameters->add(param, name, description);\
75 #define SG_ADD5(param, name, description, ms_available, gradient_available) {\
76 m_parameters->add(param, name, description);\
78 m_model_selection_parameters->add(param, name, description);\
79 if (gradient_available)\
80 m_gradient_parameters->add(param, name, description);\
83 #define SG_ADD(...) VARARG(SG_ADD, __VA_ARGS__)
126 #ifdef USE_REFERENCE_COUNTING
145 #endif //USE_REFERENCE_COUNTING
170 virtual const char*
get_name()
const = 0;
180 virtual bool is_generic(EPrimitiveType*
generic)
const;
239 const char* prefix=
"");
254 int32_t current_version,
272 int32_t& base_version,
342 #ifdef TRACE_MEMORY_ALLOCS
343 static void list_memory_allocs()
345 shogun::list_memory_allocs();
369 virtual TParameter*
migrate(DynArray<TParameter*>* param_base,
370 const SGParamInfo* target);
395 const SGParamInfo* target, TParameter*& replacement,
396 TParameter*& to_migrate,
char* old_name=NULL);
470 void set_global_objects();
471 void unset_global_objects();
479 bool is_param_new(const SGParamInfo param_info) const;
489 bool save_parameter_version(CSerializableFile* file, const
char* prefix="",
490 int32_t param_version=Version::get_version_parameter());
495 int32_t load_parameter_version(CSerializableFile* file,
496 const
char* prefix="");
508 void get_parameter_incremental_hash(Parameter* param,
509 uint32_t& hash, uint32_t& carry, uint32_t& total_length);
538 EPrimitiveType m_generic;
539 bool m_load_pre_called;
540 bool m_load_post_called;
541 bool m_save_pre_called;
542 bool m_save_post_called;
547 #endif // __SGOBJECT_H__
virtual const char * get_name() const =0
SGStringList< char > get_modelsel_names()
Parallel * get_global_parallel()
virtual bool save_serializable(CSerializableFile *file, const char *prefix="", int32_t param_version=Version::get_version_parameter())
Class that holds informations about a certain parameter of an CSGObject. Contains name...
ParameterMap * m_parameter_map
virtual TParameter * migrate(DynArray< TParameter * > *param_base, const SGParamInfo *target)
virtual CSGObject * clone()
virtual CSGObject * deep_copy() const
Version * get_global_version()
virtual void save_serializable_pre()
virtual bool is_generic(EPrimitiveType *generic) const
#define SG_NOTIMPLEMENTED
EModelSelectionAvailability
virtual CSGObject * shallow_copy() const
static int32_t get_version_parameter()
Implements a map of ParameterMapElement instances Maps one key to a set of values.
virtual bool update_parameter_hash()
char * get_modsel_param_descr(const char *param_name)
DynArray< TParameter * > * load_file_parameters(const SGParamInfo *param_info, int32_t file_version, CSerializableFile *file, const char *prefix="")
Class SGObject is the base class of all shogun objects.
void build_gradient_parameter_dictionary(CMap< TParameter *, CSGObject * > *dict)
virtual bool equals(CSGObject *other, float64_t accuracy=0.0)
Template Dynamic array class that creates an array that can be used like a list or an array...
virtual bool load_serializable(CSerializableFile *file, const char *prefix="", int32_t param_version=Version::get_version_parameter())
DynArray< TParameter * > * load_all_file_parameters(int32_t file_version, int32_t current_version, CSerializableFile *file, const char *prefix="")
the class CMap, a map based on the hash-table. w: http://en.wikipedia.org/wiki/Hash_table ...
virtual void save_serializable_post()
void print_modsel_params()
Class Version provides version information.
Parameter * m_model_selection_parameters
void set_global_parallel(Parallel *parallel)
virtual void load_serializable_pre()
virtual void load_serializable_post()
Class Parallel provides helper functions for multithreading.
virtual void one_to_one_migration_prepare(DynArray< TParameter * > *param_base, const SGParamInfo *target, TParameter *&replacement, TParameter *&to_migrate, char *old_name=NULL)
void map_parameters(DynArray< TParameter * > *param_base, int32_t &base_version, DynArray< const SGParamInfo * > *target_param_infos)
index_t get_modsel_param_index(const char *param_name)
void set_global_io(SGIO *io)
Class SGIO, used to do input output operations throughout shogun.
Parameter * m_gradient_parameters
virtual void print_serializable(const char *prefix="")
void set_global_version(Version *version)
template class SGStringList