Skip to content

Commit

Permalink
cleanup(sinsp): move create_table_entry to built_in_table
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Nosek <[email protected]>
  • Loading branch information
gnosek committed Dec 13, 2024
1 parent 10c796a commit f8c7258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
9 changes: 0 additions & 9 deletions userspace/libsinsp/plugin_table_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,6 @@ struct plugin_table_wrapper : public libsinsp::state::table<KeyType> {
return true;
}

std::unique_ptr<libsinsp::state::table_entry> new_entry() const override {
auto res = m_input->writer_ext->create_table_entry(m_input->table);
if(res == NULL) {
throw sinsp_exception(table_input_error_prefix(m_owner, m_input.get()) +
"create entry failure: " + m_owner->get_last_error());
}
return std::make_unique<plugin_table_entry>(m_owner, m_input, m_dyn_fields, res, true);
}

const char* name() const override { return m_input->name; }

const ss_plugin_table_fieldinfo* list_fields(libsinsp::state::sinsp_table_owner* owner,
Expand Down
16 changes: 8 additions & 8 deletions userspace/libsinsp/state/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,6 @@ class base_table {
m_dynamic_fields = dynf;
}

/**
* @brief Allocates and returns a new entry for the table. This is just
* a factory method, the entry will not automatically added to the table.
* Once a new entry is allocated with this method, users must invoke
* add_entry() in order to actually insert it in the table.
*/
virtual std::unique_ptr<table_entry> new_entry() const = 0;

/**
* @brief Iterates over all the entries contained in the table and invokes
* the given predicate for each of them.
Expand Down Expand Up @@ -302,6 +294,14 @@ class built_in_table : public table<KeyType> {
*/
virtual std::shared_ptr<table_entry> get_entry(const KeyType& key) = 0;

/**
* @brief Allocates and returns a new entry for the table. This is just
* a factory method, the entry will not automatically added to the table.
* Once a new entry is allocated with this method, users must invoke
* add_entry() in order to actually insert it in the table.
*/
virtual std::unique_ptr<table_entry> new_entry() const = 0;

/**
* @brief Inserts a new entry in the table with the given key. If another
* entry is already present with the same key, it gets replaced. After
Expand Down

0 comments on commit f8c7258

Please sign in to comment.