Skip to content

Commit

Permalink
allow for putting parameters using Some<>
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Feb 20, 2018
1 parent 9bd758b commit 8ff6b01
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/shogun/base/SGObject.h
Expand Up @@ -12,6 +12,7 @@

#include <shogun/base/AnyParameter.h>
#include <shogun/base/Version.h>
#include <shogun/base/some.h>
#include <shogun/base/unique.h>
#include <shogun/io/SGIO.h>
#include <shogun/lib/DataType.h>
Expand Down Expand Up @@ -376,6 +377,20 @@ class CSGObject
*/
void put(const std::string& name, CSGObject* value);

#ifndef SWIG
/** Untyped setter for an object class parameter, identified by a name.
* Will attempt to convert passed object to appropriate type.
*
* @param name name of the parameter
* @param value value of the parameter, wrapped in smart pointer
*/
template <typename T, typename T2 = typename std::enable_if<std::is_base_of<CSGObject, typename std::remove_pointer<T>::type>::value, T>::type>
void put(const std::string& name, Some<T> value)
{
put(name, (CSGObject*)(value.get()));
}
#endif // SWIG

/** Typed setter for a non-object class parameter, identified by a name.
*
* @param name name of the parameter
Expand Down

0 comments on commit 8ff6b01

Please sign in to comment.