Skip to content

Commit

Permalink
make sgobject dispatcher methods protected (#4266)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Apr 30, 2018
1 parent 4692a74 commit 9a14c52
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions src/shogun/base/SGObject.h
Expand Up @@ -370,32 +370,6 @@ class CSGObject
}
}

#ifndef SWIG
template <typename T>
bool put_sgobject_type_dispatcher(const std::string& name, CSGObject* value)
{
if (dynamic_cast<T*>(value))
{
put(Tag<T*>(name), (T*)value);
return true;
}
return false;
}

template <typename T>
CSGObject* get_sgobject_type_dispatcher(const std::string& name)
{
if (has<T*>(name))
{
T* result = get<T*>(name);
SG_REF(result)
return (CSGObject*)result;
}

return nullptr;
}
#endif // SWIG

/** Untyped setter for an object class parameter, identified by a name.
* Will attempt to convert passed object to appropriate type.
*
Expand Down Expand Up @@ -539,6 +513,30 @@ class CSGObject
void list_observable_parameters();

protected:
template <typename T>
bool put_sgobject_type_dispatcher(const std::string& name, CSGObject* value)
{
if (dynamic_cast<T*>(value))
{
put(Tag<T*>(name), (T*)value);
return true;
}
return false;
}

template <typename T>
CSGObject* get_sgobject_type_dispatcher(const std::string& name)
{
if (has<T*>(name))
{
T* result = get<T*>(name);
SG_REF(result)
return (CSGObject*)result;
}

return nullptr;
}

/** Can (optionally) be overridden to pre-initialize some member
* variables which are not PARAMETER::ADD'ed. Make sure that at
* first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_PRE
Expand Down

0 comments on commit 9a14c52

Please sign in to comment.