Skip to content

Commit

Permalink
DataTableNative
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Jul 7, 2024
1 parent ae546cc commit e6baf71
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
7 changes: 2 additions & 5 deletions include/momo/DataColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1508,10 +1508,7 @@ class DataColumnListStatic
MutableOffsets mMutableOffsets;
};

template<conceptDataStructWithMembers TStruct,
conceptMemManager TMemManager = MemManagerDefault,
typename TSettings = DataSettings<>>
using DataColumnListNative = DataColumnListStatic<TStruct,
DataColumnInfoNative<TStruct>, TMemManager, TSettings>;
template<conceptDataStructWithMembers TStruct>
using DataColumnListNative = DataColumnListStatic<TStruct, DataColumnInfoNative<TStruct>>;

} // namespace momo
5 changes: 5 additions & 0 deletions include/momo/DataTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
concept conceptDataTraits
class DataTraits
class DataTable
class DataTableNative
\**********************************************************/

Expand Down Expand Up @@ -1549,4 +1550,8 @@ class DataTable
Indexes mIndexes;
};

template<conceptDataStructWithMembers TStruct,
conceptDataTraits TDataTraits = DataTraits>
using DataTableNative = DataTable<DataColumnListNative<TStruct>, TDataTraits>;

} // namespace momo
8 changes: 2 additions & 6 deletions test/sources/SimpleDataSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,11 @@ namespace sample_data2
double dblCol;
std::string strCol;
};
using ColumnList = momo::DataColumnListNative<Struct>;
using Table = momo::DataTable<ColumnList>;
*/
void Sample(std::ostream& output)
{
// in this sample the list of columns is specified in accordance with the `Struct` struct
Table table; // construct empty table with 3 columns
momo::DataTableNative<Struct> table; // construct empty table with 3 columns

// unique index (primary key)
table.AddUniqueHashIndex(&Struct::strCol, &Struct::intCol);
Expand Down Expand Up @@ -278,8 +275,7 @@ namespace sample_data5
std::string strCol{};
};
using ColumnList = momo::DataColumnListNative<Struct>;
using Table = momo::DataTable<ColumnList>;
using Table = momo::DataTableNative<Struct>;
*/
void Sample(std::ostream& output)
{
Expand Down
6 changes: 1 addition & 5 deletions test/sources/SimpleDataSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ namespace sample_data2
double dblCol;
std::string strCol;
};

using ColumnList = momo::DataColumnListNative<Struct>;
using Table = momo::DataTable<ColumnList>;
}

namespace sample_data3
Expand Down Expand Up @@ -72,6 +69,5 @@ namespace sample_data5
std::string strCol{};
};

using ColumnList = momo::DataColumnListNative<Struct>;
using Table = momo::DataTable<ColumnList>;
using Table = momo::DataTableNative<Struct>;
}
9 changes: 5 additions & 4 deletions test/sources/SimpleDataTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class SimpleDataTester
{
{
std::cout << "momo::DataColumnListNative (-RowNumber): " << std::flush;
typedef momo::DataColumnListNative<Struct, momo::MemManagerDict<>> DataColumnList;
typedef momo::DataColumnListStatic<Struct, momo::DataColumnInfoNative<Struct>,
momo::MemManagerDict<>> DataColumnList;
DataColumnList columnList;
columnList.SetMutable(&Struct::dblStruct);
columnList.PrepareForVisitors(&Struct::intStruct, &Struct::dblStruct, &Struct::strStruct);
Expand Down Expand Up @@ -503,9 +504,9 @@ class SimpleDataTester
if constexpr (!dynamic)
{
Row row = table.NewRow(Struct{ .intStruct = 1, .dblStruct = 3.5, .strStruct = "2" });
assert(row[intCol] == 1);
assert(row[dblCol] == 3.5);
assert(row[strCol] == "2");
assert(row->intStruct == 1);
assert(row->dblStruct == 3.5);
assert(row->strStruct == "2");
}
}
};
Expand Down

0 comments on commit e6baf71

Please sign in to comment.