Skip to content

Commit

Permalink
fix: copyability
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Mar 28, 2024
1 parent f511ba1 commit e457d37
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
12 changes: 8 additions & 4 deletions hipo4/bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void bank::rowlist::setList(list_t list) {
m_init = true;
}

void bank::rowlist::reduce(std::function<double(hipo::bank&, int)> func) {
void bank::rowlist::reduce(std::function<double(bank&, int)> func) {
if(ownerBankIsUnknown("reduce"))
return;
auto indx = m_list;
Expand All @@ -375,9 +375,9 @@ void bank::rowlist::reduce(std::function<double(hipo::bank&, int)> func) {
void bank::rowlist::reduce(const char *expression) {
if(ownerBankIsUnknown("reduce"))
return;
hipo::Parser p(expression);
Parser p(expression);
int nitems = m_owner_bank->getSchema().getEntries();
hipo::schema &schema = m_owner_bank->getSchema();
schema &schema = m_owner_bank->getSchema();
auto indx = m_list;
m_list.clear();
for(auto const& r : indx){
Expand All @@ -399,7 +399,7 @@ bank::rowlist::list_t bank::rowlist::s_number_list = bank::rowlist::generate_num

bank::rowlist::list_t bank::rowlist::copy_number_list(list_t::size_type num) {
if(num < 0)
return {}
return {};
if(num <= s_number_list.size())
return list_t(s_number_list.begin(), s_number_list.begin() + num);
else {
Expand Down Expand Up @@ -427,6 +427,10 @@ bool bank::rowlist::ownerBankIsUnknown(std::string_view caller) {
// hipo::bank
//////////////////////////////////////////////////////////////////////////////////

bank::bank()= default;

bank::~bank()= default;

void bank::setRows(int rows){
bankRows = rows;
int size = bankSchema.getSizeForRows(bankRows);
Expand Down
30 changes: 15 additions & 15 deletions hipo4/bank.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace hipo {
friend class event;
};

class composite : public hipo::node {
class composite : public node {
/**
* @brief This is composite bank with type = 10, who knows why
* Class is used to store formated data structures without dictionary.
Expand Down Expand Up @@ -205,7 +205,7 @@ namespace hipo {
};
//typedef std::auto_ptr<hipo::generic_node> node_pointer;

class bank : public hipo::structure {
class bank : public structure {

public:

Expand All @@ -216,7 +216,7 @@ namespace hipo {

/// constructor
/// @param ownerBank if set, associate this `rowlist` with bank `ownerBank`
rowlist(bank* const ownerBank = nullptr) : m_list({}), m_init(false), m_ownerBank(ownerBank) {}
rowlist(bank* ownerBank = nullptr) : m_owner_bank(ownerBank) {}
~rowlist() {}

/// initialize with a full list with specified number of rows
Expand All @@ -232,15 +232,15 @@ namespace hipo {
/// filter the list according to a function
/// @param func a function which takes a `hipo::bank` reference and an `int` row number and returns a `double`;
/// if the returned `double` is larger than 0.5, the row is accepted
void reduce(std::function<double(hipo::bank&, int)> func);
void reduce(std::function<double(bank&, int)> func);
/// filter the list according to an expression
/// @param expression the filter expression
void reduce(char const* expression);

private:
bool m_init;
list_t m_list;
bank* const m_owner_bank;
bool m_init{false};
list_t m_list{};
bank* m_owner_bank;

static list_t generate_number_list(list_t::size_type num = 500);
static list_t copy_number_list(list_t::size_type num);
Expand All @@ -252,27 +252,27 @@ namespace hipo {

private:

hipo::schema bankSchema;
rowlist bankRowList;
int bankRows{-1};
schema bankSchema;
rowlist bankRowList{this};
int bankRows{-1};

public:

bank() : bankRowList(rowlist(this)) = default;
bank();
// constructor initializes the nodes in the bank
// and they will be filled automatically by reader.next()
// method.
bank(const hipo::schema& __schema) : bankSchema(__schema), bankRowList(rowlist(this)) {}
bank(const schema& __schema) : bankSchema(__schema) {}

bank(const hipo::schema& __schema, int __rows) : bankSchema(__schema), bankRows(__rows), bankRowList(rowlist(this)) {
bank(const schema& __schema, int __rows) : bankSchema(__schema), bankRows(__rows) {
int size = bankSchema.getSizeForRows(bankRows);
initStructureBySize(bankSchema.getGroup(),bankSchema.getItem(), 11, size);
bankRowList.reset();
}

~bank() = default;
~bank() override;

hipo::schema &getSchema() { return bankSchema;}
schema &getSchema() { return bankSchema;}
int getRows() const noexcept{ return bankRows;}
void setRows( int rows);
int getInt( int item, int index) const noexcept;
Expand Down

0 comments on commit e457d37

Please sign in to comment.