Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store parameters in the AnyParameter wrapper #4052

Merged
merged 1 commit into from
Dec 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/shogun/base/SGObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,29 @@

namespace shogun
{
typedef std::map<BaseTag, Any> ParametersMap;
class AnyParameter
{
public:
AnyParameter() : m_value()
{
}
explicit AnyParameter(const Any& value) : m_value(value)
{
}
explicit AnyParameter(const AnyParameter& other)
: m_value(other.m_value)
{
}
Any value() const
{
return m_value;
}

private:
Any m_value;
};

typedef std::map<BaseTag, AnyParameter> ParametersMap;
typedef std::unordered_map<std::string,
std::pair<SG_OBS_VALUE_TYPE, std::string>>
ObsParamsList;
Expand All @@ -46,14 +68,14 @@ namespace shogun
public:
void put(const BaseTag& tag, const Any& any)
{
map[tag] = any;
map[tag] = AnyParameter(any);
}

Any get(const BaseTag& tag) const
{
if(!has(tag))
return Any();
return map.at(tag);
return map.at(tag).value();
}

bool has(const BaseTag& tag) const
Expand Down