Skip to content

Commit

Permalink
[hash]: Handle review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Nazarii Hnydyn <[email protected]>
  • Loading branch information
nazariig committed Nov 2, 2023
1 parent 4b3d4db commit c398098
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
18 changes: 10 additions & 8 deletions orchagent/switch/switch_capabilities.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// includes -----------------------------------------------------------------------------------------------------------

extern "C" {
#include <saitypes.h>
#include <saiobject.h>
#include <saistatus.h>
#include <saitypes.h>
#include <saihash.h>
#include <saiswitch.h>
}

#include <cstdint>
#include <string>
#include <vector>
#include <set>
#include <unordered_map>
#include <algorithm>

#include <sai_serialize.h>
Expand Down Expand Up @@ -81,28 +83,28 @@ extern sai_object_id_t gSwitchId;

// functions ----------------------------------------------------------------------------------------------------------

static std::string toStr(sai_object_type_t objType, sai_attr_id_t attrId) noexcept
static std::string toStr(sai_object_type_t objType, sai_attr_id_t attrId)
{
const auto *meta = sai_metadata_get_attr_metadata(objType, attrId);

return meta != nullptr ? meta->attridname : "UNKNOWN";
}

static std::string toStr(sai_native_hash_field_t value) noexcept
static std::string toStr(sai_native_hash_field_t value)
{
const auto *name = sai_metadata_get_native_hash_field_name(value);

return name != nullptr ? name : "UNKNOWN";
}

static std::string toStr(sai_hash_algorithm_t value) noexcept
static std::string toStr(sai_hash_algorithm_t value)
{
const auto *name = sai_metadata_get_hash_algorithm_name(value);

return name != nullptr ? name : "UNKNOWN";
}

static std::string toStr(const std::set<sai_native_hash_field_t> &value) noexcept
static std::string toStr(const std::set<sai_native_hash_field_t> &value)
{
std::vector<std::string> strList;

Expand All @@ -118,7 +120,7 @@ static std::string toStr(const std::set<sai_native_hash_field_t> &value) noexcep
return join(",", strList.cbegin(), strList.cend());
}

static std::string toStr(const std::set<sai_hash_algorithm_t> &value) noexcept
static std::string toStr(const std::set<sai_hash_algorithm_t> &value)
{
std::vector<std::string> strList;

Expand All @@ -134,13 +136,13 @@ static std::string toStr(const std::set<sai_hash_algorithm_t> &value) noexcept
return join(",", strList.cbegin(), strList.cend());
}

static std::string toStr(bool value) noexcept
static std::string toStr(bool value)
{
return value ? "true" : "false";
}

template <typename T1, typename T2>
static void insertBack(T1 &out, const T2 &in) noexcept
static void insertBack(T1 &out, const T2 &in)
{
out.insert(out.end(), in.cbegin(), in.cend());
}
Expand Down
3 changes: 2 additions & 1 deletion orchagent/switch/switch_capabilities.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

extern "C" {
#include <saiobject.h>
#include <saitypes.h>
#include <saiobject.h>
#include <saihash.h>
#include <saiswitch.h>
}

#include <vector>
Expand Down
5 changes: 5 additions & 0 deletions orchagent/switch/switch_helper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// includes -----------------------------------------------------------------------------------------------------------

extern "C" {
#include <saihash.h>
#include <saiswitch.h>
}

#include <unordered_map>
#include <unordered_set>
#include <string>
Expand Down
2 changes: 2 additions & 0 deletions orchagent/switch/switch_helper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <string>

#include "switch_container.h"

class SwitchHelper final
Expand Down

0 comments on commit c398098

Please sign in to comment.