Skip to content

Commit

Permalink
chore(libsinsp): substitute class with namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Jan 9, 2025
1 parent 8d60b8d commit bd0bb9b
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions userspace/libsinsp/sinsp_filter_transformers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,31 @@ limitations under the License.
#include <libsinsp/sinsp_filter_transformers/sinsp_filter_transformer_tolower.h>
#include <libsinsp/sinsp_filter_transformers/sinsp_filter_transformer_toupper.h>

class sinsp_filter_transformer_factory {
public:
sinsp_filter_transformer_factory() = delete;
~sinsp_filter_transformer_factory() = delete;
sinsp_filter_transformer_factory operator=(const sinsp_filter_transformer_factory&) = delete;

static std::unique_ptr<sinsp_filter_transformer> create_transformer(
filter_transformer_type trtype) {
switch(trtype) {
case FTR_TOUPPER: {
return std::make_unique<sinsp_filter_transformer_toupper>();
}
case FTR_TOLOWER: {
return std::make_unique<sinsp_filter_transformer_tolower>();
}
case FTR_BASE64: {
return std::make_unique<sinsp_filter_transformer_base64>();
}
case FTR_STORAGE: {
return std::make_unique<sinsp_filter_transformer_storage>();
}
case FTR_BASENAME: {
return std::make_unique<sinsp_filter_transformer_basename>();
}
case FTR_LEN: {
return std::make_unique<sinsp_filter_transformer_len>();
}
default:
throw sinsp_exception("transformer '" + std::to_string(trtype) + "' is not supported");
return nullptr;
}
namespace sinsp_filter_transformer_factory {
inline std::unique_ptr<sinsp_filter_transformer> create_transformer(
filter_transformer_type trtype) {
switch(trtype) {
case FTR_TOUPPER: {
return std::make_unique<sinsp_filter_transformer_toupper>();
}
case FTR_TOLOWER: {
return std::make_unique<sinsp_filter_transformer_tolower>();
}
case FTR_BASE64: {
return std::make_unique<sinsp_filter_transformer_base64>();
}
case FTR_STORAGE: {
return std::make_unique<sinsp_filter_transformer_storage>();
}
case FTR_BASENAME: {
return std::make_unique<sinsp_filter_transformer_basename>();
}
case FTR_LEN: {
return std::make_unique<sinsp_filter_transformer_len>();
}
default:
throw sinsp_exception("transformer '" + std::to_string(trtype) + "' is not supported");
return nullptr;
}
};
}
}; // namespace sinsp_filter_transformer_factory

0 comments on commit bd0bb9b

Please sign in to comment.