12 #ifndef __SGOBJECT_H__
13 #define __SGOBJECT_H__
39 class CSerializableFile;
42 template <
class T,
class K>
class CMap;
45 template <
class T>
class DynArray;
49 #ifdef USE_REFERENCE_COUNTING
50 #define SG_REF(x) { if (x) (x)->ref(); }
51 #define SG_UNREF(x) { if (x) { if ((x)->unref()==0) (x)=NULL; } }
52 #define SG_UNREF_NO_NULL(x) { if (x) { (x)->unref(); } }
56 #define SG_UNREF_NO_NULL(x)
63 #define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N
64 #define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1)
66 #define VARARG_IMPL2(base, count, ...) base##count(__VA_ARGS__)
67 #define VARARG_IMPL(base, count, ...) VARARG_IMPL2(base, count, __VA_ARGS__)
68 #define VARARG(base, ...) VARARG_IMPL(base, VA_NARGS(__VA_ARGS__), __VA_ARGS__)
70 #define SG_ADD4(param, name, description, ms_available) {\
71 m_parameters->add(param, name, description);\
73 m_model_selection_parameters->add(param, name, description);\
76 #define SG_ADD5(param, name, description, ms_available, gradient_available) {\
77 m_parameters->add(param, name, description);\
79 m_model_selection_parameters->add(param, name, description);\
80 if (gradient_available)\
81 m_gradient_parameters->add(param, name, description);\
84 #define SG_ADD(...) VARARG(SG_ADD, __VA_ARGS__)
127 #ifdef USE_REFERENCE_COUNTING
146 #endif //USE_REFERENCE_COUNTING
171 virtual const char*
get_name()
const = 0;
181 virtual bool is_generic(EPrimitiveType*
generic)
const;
240 const char* prefix=
"");
255 int32_t current_version,
273 int32_t& base_version,
343 #ifdef TRACE_MEMORY_ALLOCS
344 static void list_memory_allocs()
346 shogun::list_memory_allocs();
370 virtual TParameter*
migrate(DynArray<TParameter*>* param_base,
371 const SGParamInfo* target);
396 const SGParamInfo* target, TParameter*& replacement,
397 TParameter*& to_migrate,
char* old_name=NULL);
471 void set_global_objects();
472 void unset_global_objects();
480 bool is_param_new(const SGParamInfo param_info) const;
490 bool save_parameter_version(CSerializableFile* file, const
char* prefix="",
491 int32_t param_version=Version::get_version_parameter());
496 int32_t load_parameter_version(CSerializableFile* file,
497 const
char* prefix="");
509 void get_parameter_incremental_hash(Parameter* param,
510 uint32_t& hash, uint32_t& carry, uint32_t& total_length);
539 EPrimitiveType m_generic;
540 bool m_load_pre_called;
541 bool m_load_post_called;
542 bool m_save_pre_called;
543 bool m_save_post_called;
548 #endif // __SGOBJECT_H__