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

change method names, fix bug and docs #3333

Merged
merged 1 commit into from
Jul 4, 2016
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/shogun/base/SGObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class CSGObject
if(!has_with_base_tag(tag))
return false;
const Any value = get_with_base_tag(tag);
return value.sameType<T>();
return value.same_type<T>();
}

/** Setter for a class parameter, identified by a Tag.
Expand All @@ -340,7 +340,7 @@ class CSGObject
else
{
SG_ERROR("\"%s\" does not have a parameter with name \"%s\".\n",
_tag.name().c_str(), get_name());
get_name(), _tag.name().c_str());
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/shogun/lib/any.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ namespace shogun
struct Empty;

/** Constructor */
Any() : policy(selectPolicy<Empty>()), storage(nullptr)
Any() : policy(select_policy<Empty>()), storage(nullptr)
{
}

/** Constructor to copy value */
template <typename T>
explicit Any(const T& v) : policy(selectPolicy<T>()), storage(nullptr)
explicit Any(const T& v) : policy(select_policy<T>()), storage(nullptr)
{
policy->set(&storage, &v);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ namespace shogun
template <typename T>
T& as() const
{
if (sameType<T>())
if (same_type<T>())
{
return *(reinterpret_cast<T*>(storage));
}
Expand All @@ -231,26 +231,26 @@ namespace shogun

/** @return true if type is same. */
template <typename T>
inline bool sameType() const
inline bool same_type() const
{
return (policy == selectPolicy<T>()) || sameTypeFallback<T>();
return (policy == select_policy<T>()) || same_type_fallback<T>();
}

/** @return true if type-id is same. */
template <typename T>
bool sameTypeFallback() const
bool same_type_fallback() const
{
return policy->matches(typeid(T));
}

/** @return true if Any object is empty. */
bool empty() const
{
return sameType<Empty>();
return same_type<Empty>();
}
private:
template <typename T>
static BaseAnyPolicy* selectPolicy()
static BaseAnyPolicy* select_policy()
{
typedef PointerValueAnyPolicy<T> Policy;
static Policy policy;
Expand Down
8 changes: 2 additions & 6 deletions src/shogun/lib/basetag.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,13 @@ namespace shogun
return *this;
}

/** Returns name of Tag
* @return name
*/
/** @return name of Tag */
inline std::string name() const
{
return m_name;
}

/** Returns hash of Tag
* @return hash
*/
/** @return hash of Tag */
inline std::size_t hash() const
{
return m_hash;
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/lib/Any_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ TEST(Any, as)
EXPECT_THROW(any.as<float64_t>(), std::logic_error);
}

TEST(Any, sameType)
TEST(Any, same_type)
{
int32_t integer = 10;
auto any = Any(integer);
EXPECT_EQ(any.sameType<int32_t>(), true);
EXPECT_EQ(any.sameType<float64_t>(), false);
EXPECT_EQ(any.same_type<int32_t>(), true);
EXPECT_EQ(any.same_type<float64_t>(), false);
}

TEST(Any, empty)
Expand All @@ -61,12 +61,12 @@ TEST(Any, empty)
EXPECT_EQ(empty_any.empty(), true);
}

TEST(Any, sameTypeFallback)
TEST(Any, same_type_fallback)
{
int32_t integer = 10;
auto any = Any(integer);
EXPECT_EQ(any.sameTypeFallback<int32_t>(), true);
EXPECT_EQ(any.sameTypeFallback<float64_t>(), false);
EXPECT_EQ(any.same_type_fallback<int32_t>(), true);
EXPECT_EQ(any.same_type_fallback<float64_t>(), false);
}

TEST(Any, erase_type)
Expand Down