OpenM++ runtime library (libopenm)
dbMetaTable.h
Go to the documentation of this file.
1 
5 // Copyright (c) 2013-2015 OpenM++
6 // This code is licensed under the MIT license (see LICENSE.txt for details)
7 
8 #ifndef DB_META_TABLE_H
9 #define DB_META_TABLE_H
10 
11 #include <algorithm>
12 #include <functional>
13 #include <mutex>
14 using namespace std;
15 
16 #include "dbExec.h"
17 #include "libopenm/db/dbMetaRow.h"
18 
19 namespace openm
20 {
22  template<class TRow> struct IMetaTable
23  {
24  public:
25  virtual ~IMetaTable<TRow>(void) noexcept { }
26 
27  protected:
29  static vector<TRow> rows(const IRowBaseVec & i_rowVec)
30  {
31  vector<TRow> vec;
32  for (IRowBaseVec::const_iterator rowIt = i_rowVec.begin(); rowIt != i_rowVec.end(); ++rowIt) {
33  vec.push_back( *dynamic_cast<TRow *>(rowIt->get()) );
34  }
35  return vec;
36  }
37  };
38 
40  template<class TRow> struct IMetaLoadedTable : public IMetaTable<TRow>
41  {
43  typedef function<bool(const TRow & i_dbRow)> RowEqual;
44 
45  virtual ~IMetaLoadedTable<TRow>(void) noexcept { }
46 
48  virtual const IRowBaseVec & rowsCRef(void) const = 0;
49 
51  virtual IRowBaseVec & rowsRef(void) = 0;
52 
54  IRowBaseVec::difference_type rowCount(void) const { return rowsCRef().size(); }
55 
57  vector<TRow> rows(void) const
58  {
59  vector<TRow> vec;
60  for (IRowBaseVec::const_iterator rowIt = rowsCRef().cbegin(); rowIt != rowsCRef().cend(); ++rowIt) {
61  vec.push_back(*dynamic_cast<TRow *>(rowIt->get()));
62  }
63  return vec;
64  }
65 
67  const TRow * firstRow(void) const
68  {
69  return dynamic_cast<TRow *>(!rowsCRef().empty() ? rowsCRef()[0].get() : nullptr);
70  }
71 
73  vector<TRow> findAll(RowEqual i_cmp) const
74  {
75  vector<TRow> vec;
76  for (IRowBaseVec::const_iterator rowIt = rowsCRef().cbegin(); rowIt != rowsCRef().cend(); ++rowIt) {
77  if (i_cmp(*dynamic_cast<TRow *>(rowIt->get()))) vec.push_back(*dynamic_cast<TRow *>(rowIt->get()));
78  }
79  return vec;
80  }
81 
83  const TRow * findFirst(RowEqual i_cmp) const { return byIndex(indexOf(i_cmp)); }
84 
86  const TRow * byIndex(IRowBaseVec::difference_type i_index) const
87  {
88  return (0 <= i_index && i_index < rowCount()) ? dynamic_cast<TRow *>(rowsCRef()[i_index].get()) : nullptr;
89  }
90 
92  IRowBaseVec::difference_type indexOf(RowEqual i_cmp, IRowBaseVec::difference_type i_startPos = 0) const
93  {
94  if (i_startPos >= 0) {
95  for (IRowBaseVec::size_type pos = i_startPos; pos < rowsCRef().size(); pos++) {
96  if (i_cmp(*dynamic_cast<TRow *>(rowsCRef()[pos].get()))) return pos;
97  }
98  }
99  return -1;
100  }
101 
103  IRowBaseVec::size_type countOf(RowEqual i_cmp) const
104  {
105  IRowBaseVec::size_type nCount = 0;
106  for (IRowBaseVec::const_iterator rowIt = rowsCRef().cbegin(); rowIt != rowsCRef().cend(); ++rowIt) {
107  if (i_cmp(*dynamic_cast<TRow *>(rowIt->get()))) nCount++;
108  }
109  return nCount;
110  }
111 
112  protected:
114  static IRowBaseVec load(const string & i_sqlSelect, IDbExec * i_dbExec, const IRowAdapter & i_adapter)
115  {
116  if (i_dbExec == nullptr) throw DbException("invalid (NULL) database connection");
117 
118  IRowBaseVec vec = i_dbExec->selectRowVector(i_sqlSelect, i_adapter);
119  stable_sort(vec.begin(), vec.end(), TRow::keyLess);
120  return vec;
121  }
122 
124  const TRow * findKey(const IRowBaseUptr & i_row) const
125  {
126  IRowBaseVec::const_iterator rowIt = lower_bound(rowsCRef().cbegin(), rowsCRef().cend(), i_row, TRow::keyLess);
127  return dynamic_cast<TRow *>((rowIt != rowsCRef().cend() && TRow::keyEqual(*rowIt, i_row)) ? rowIt->get() : nullptr);
128  }
129  };
130 
132  struct ILangLstTable : public IMetaLoadedTable<LangLstRow>
133  {
134  virtual ~ILangLstTable() noexcept = 0;
135 
137  static ILangLstTable * create(IDbExec * i_dbExec);
138 
140  virtual const LangLstRow * byKey(int i_langId) const = 0;
141 
143  virtual const LangLstRow * byCode(const string & i_code) const = 0;
144 
146  static ILangLstTable * create(IRowBaseVec & io_rowVec);
147 
149  virtual IRowBaseVec & rowsRef(void) = 0;
150  };
151 
153  struct ILangWordTable : public IMetaLoadedTable<LangWordRow>
154  {
155  virtual ~ILangWordTable() noexcept = 0;
156 
161  static ILangWordTable * create(IDbExec * i_dbExec, int i_langId = -1);
162 
164  virtual const LangWordRow * byKey(int i_langId, const string & i_code) const = 0;
165 
167  static ILangWordTable * create(IRowBaseVec & io_rowVec);
168 
170  virtual IRowBaseVec & rowsRef(void) = 0;
171  };
172 
174  struct IModelDicTable : public IMetaLoadedTable<ModelDicRow>
175  {
176  virtual ~IModelDicTable() noexcept = 0;
177 
183  static IModelDicTable * create(IDbExec * i_dbExec, const char * i_name = nullptr, const char * i_digest = nullptr);
184 
186  static IModelDicTable * create(IDbExec * i_dbExec, int i_modelId);
187 
189  virtual const ModelDicRow * byKey(int i_modelId) const = 0;
190 
192  virtual const ModelDicRow * byNameDigest(const string & i_name, const string & i_digest) const = 0;
193 
195  static IModelDicTable * create(IRowBaseVec & io_rowVec);
196 
198  virtual IRowBaseVec & rowsRef(void) = 0;
199  };
200 
202  struct IModelDicTxtTable : public IMetaLoadedTable<ModelDicTxtRow>
203  {
204  virtual ~IModelDicTxtTable() noexcept = 0;
205 
212  static IModelDicTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
213 
215  virtual const ModelDicTxtRow * byKey(int i_modelId, int i_langId) const = 0;
216 
218  static IModelDicTxtTable * create(IRowBaseVec & io_rowVec);
219 
221  virtual IRowBaseVec & rowsRef(void) = 0;
222  };
223 
225  struct IModelWordTable : public IMetaLoadedTable<ModelWordRow>
226  {
227  virtual ~IModelWordTable() noexcept = 0;
228 
235  static IModelWordTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
236 
238  virtual const ModelWordRow * byKey(int i_modelId, int i_langId, const string & i_code) const = 0;
239 
241  static IModelWordTable * create(IRowBaseVec & io_rowVec);
242 
244  virtual IRowBaseVec & rowsRef(void) = 0;
245  };
246 
248  struct ITypeDicTable : public IMetaLoadedTable<TypeDicRow>
249  {
250  virtual ~ITypeDicTable() noexcept = 0;
251 
257  static ITypeDicTable * create(IDbExec * i_dbExec, int i_modelId = 0);
258 
260  virtual const TypeDicRow * byKey(int i_modelId, int i_typeId) const = 0;
261 
263  static ITypeDicTable * create(IRowBaseVec & io_rowVec);
264 
266  virtual IRowBaseVec & rowsRef(void) = 0;
267  };
268 
270  struct ITypeDicTxtTable : public IMetaLoadedTable<TypeDicTxtRow>
271  {
272  virtual ~ITypeDicTxtTable() noexcept = 0;
273 
280  static ITypeDicTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
281 
283  virtual const TypeDicTxtRow * byKey(int i_modelId, int i_typeId, int i_langId) const = 0;
284 
286  static ITypeDicTxtTable * create(IRowBaseVec & io_rowVec);
287 
289  virtual IRowBaseVec & rowsRef(void) = 0;
290  };
291 
293  struct ITypeEnumLstTable : public IMetaLoadedTable<TypeEnumLstRow>
294  {
295  virtual ~ITypeEnumLstTable() noexcept = 0;
296 
302  static ITypeEnumLstTable * create(IDbExec * i_dbExec, int i_modelId = 0);
303 
305  virtual const TypeEnumLstRow * byKey(int i_modelId, int i_typeId, int i_enumId) const = 0;
306 
308  virtual vector<TypeEnumLstRow> byModelId(int i_modelId) const = 0;
309 
311  virtual vector<TypeEnumLstRow> byModelIdTypeId(int i_modelId, int i_typeId) const = 0;
312 
314  virtual const TypeEnumLstRow * byName(int i_modelId, int i_typeId, const char * i_name) const = 0;
315 
317  static ITypeEnumLstTable * create(IRowBaseVec & io_rowVec);
318 
320  virtual IRowBaseVec & rowsRef(void) = 0;
321  };
322 
324  struct ITypeEnumTxtTable : public IMetaLoadedTable<TypeEnumTxtRow>
325  {
326  virtual ~ITypeEnumTxtTable() noexcept = 0;
327 
334  static ITypeEnumTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
335 
337  virtual const TypeEnumTxtRow * byKey(int i_modelId, int i_typeId, int i_enumId, int i_langId) const = 0;
338 
340  static ITypeEnumTxtTable * create(IRowBaseVec & io_rowVec);
341 
343  virtual IRowBaseVec & rowsRef(void) = 0;
344  };
345 
347  struct IParamDicTable : public IMetaLoadedTable<ParamDicRow>
348  {
349  virtual ~IParamDicTable() noexcept = 0;
350 
356  static IParamDicTable * create(IDbExec * i_dbExec, int i_modelId = 0);
357 
359  virtual const ParamDicRow * byKey(int i_modelId, int i_paramId) const = 0;
360 
362  virtual vector<ParamDicRow> byModelId(int i_modelId) const = 0;
363 
365  virtual const ParamDicRow * byModelIdName(int i_modelId, const string & i_name) const = 0;
366 
368  static IParamDicTable * create(IRowBaseVec & io_rowVec);
369 
371  virtual IRowBaseVec & rowsRef(void) = 0;
372  };
373 
375  struct IParamImportTable : public IMetaLoadedTable<ParamImportRow>
376  {
377  virtual ~IParamImportTable() noexcept = 0;
378 
384  static IParamImportTable * create(IDbExec * i_dbExec, int i_modelId = 0);
385 
387  virtual const ParamImportRow * byKey(int i_modelId, int i_paramId) const = 0;
388 
390  virtual vector<ParamImportRow> byModelId(int i_modelId) const = 0;
391 
393  static IParamImportTable * create(IRowBaseVec & io_rowVec);
394 
396  virtual IRowBaseVec & rowsRef(void) = 0;
397  };
398 
400  struct IParamDicTxtTable : public IMetaLoadedTable<ParamDicTxtRow>
401  {
402  virtual ~IParamDicTxtTable() noexcept = 0;
403 
410  static IParamDicTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
411 
413  virtual const ParamDicTxtRow * byKey(int i_modelId, int i_paramId, int i_langId) const = 0;
414 
416  static IParamDicTxtTable * create(IRowBaseVec & io_rowVec);
417 
419  virtual IRowBaseVec & rowsRef(void) = 0;
420  };
421 
423  struct IParamDimsTable : public IMetaLoadedTable<ParamDimsRow>
424  {
425  virtual ~IParamDimsTable() noexcept = 0;
426 
432  static IParamDimsTable * create(IDbExec * i_dbExec, int i_modelId = 0);
433 
435  virtual const ParamDimsRow * byKey(int i_modelId, int i_paramId, int i_dimId) const = 0;
436 
438  virtual vector<ParamDimsRow> byModelIdParamId(int i_modelId, int i_paramId) const = 0;
439 
441  static IParamDimsTable * create(IRowBaseVec & io_rowVec);
442 
444  virtual IRowBaseVec & rowsRef(void) = 0;
445  };
446 
448  struct IParamDimsTxtTable : public IMetaLoadedTable<ParamDimsTxtRow>
449  {
450  virtual ~IParamDimsTxtTable() noexcept = 0;
451 
458  static IParamDimsTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
459 
461  virtual const ParamDimsTxtRow * byKey(int i_modelId, int i_paramId, int i_dimId, int i_langId) const = 0;
462 
464  static IParamDimsTxtTable * create(IRowBaseVec & io_rowVec);
465 
467  virtual IRowBaseVec & rowsRef(void) = 0;
468  };
469 
471  struct ITableDicTable : public IMetaLoadedTable<TableDicRow>
472  {
473  virtual ~ITableDicTable() noexcept = 0;
474 
480  static ITableDicTable * create(IDbExec * i_dbExec, int i_modelId = 0);
481 
483  virtual const TableDicRow * byKey(int i_modelId, int i_tableId) const = 0;
484 
486  virtual vector<TableDicRow> byModelId(int i_modelId) const = 0;
487 
489  virtual const TableDicRow * byModelIdName(int i_modelId, const string & i_name) const = 0;
490 
492  static ITableDicTable * create(IRowBaseVec & io_rowVec);
493 
495  virtual IRowBaseVec & rowsRef(void) = 0;
496  };
497 
499  struct ITableDicTxtTable : public IMetaLoadedTable<TableDicTxtRow>
500  {
501  virtual ~ITableDicTxtTable() noexcept = 0;
502 
509  static ITableDicTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
510 
512  virtual const TableDicTxtRow * byKey(int i_modelId, int i_tableId, int i_langId) const = 0;
513 
515  static ITableDicTxtTable * create(IRowBaseVec & io_rowVec);
516 
518  virtual IRowBaseVec & rowsRef(void) = 0;
519  };
520 
522  struct ITableDimsTable : public IMetaLoadedTable<TableDimsRow>
523  {
524  virtual ~ITableDimsTable() noexcept = 0;
525 
531  static ITableDimsTable * create(IDbExec * i_dbExec, int i_modelId = 0);
532 
534  virtual const TableDimsRow * byKey(int i_modelId, int i_tableId, int i_dimId) const = 0;
535 
537  virtual vector<TableDimsRow> byModelIdTableId(int i_modelId, int i_tableId) const = 0;
538 
540  static ITableDimsTable * create(IRowBaseVec & io_rowVec);
541 
543  virtual IRowBaseVec & rowsRef(void) = 0;
544  };
545 
547  struct ITableDimsTxtTable : public IMetaLoadedTable<TableDimsTxtRow>
548  {
549  virtual ~ITableDimsTxtTable() noexcept = 0;
550 
557  static ITableDimsTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
558 
560  virtual const TableDimsTxtRow * byKey(int i_modelId, int i_tableId, int i_dimId, int i_langId) const = 0;
561 
563  static ITableDimsTxtTable * create(IRowBaseVec & io_rowVec);
564 
566  virtual IRowBaseVec & rowsRef(void) = 0;
567  };
568 
570  struct ITableAccTable : public IMetaLoadedTable<TableAccRow>
571  {
572  virtual ~ITableAccTable() noexcept = 0;
573 
580  static ITableAccTable * create(IDbExec * i_dbExec, int i_modelId = 0, bool i_isIncludeDerived = false);
581 
583  virtual const TableAccRow * byKey(int i_modelId, int i_tableId, int i_accId) const = 0;
584 
586  virtual vector<TableAccRow> byModelId(int i_modelId) const = 0;
587 
589  virtual vector<TableAccRow> byModelIdTableId(int i_modelId, int i_tableId) const = 0;
590 
592  static ITableAccTable * create(IRowBaseVec & io_rowVec);
593 
595  virtual IRowBaseVec & rowsRef(void) = 0;
596  };
597 
599  struct ITableAccTxtTable : public IMetaLoadedTable<TableAccTxtRow>
600  {
601  virtual ~ITableAccTxtTable() noexcept = 0;
602 
609  static ITableAccTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
610 
612  virtual const TableAccTxtRow * byKey(int i_modelId, int i_tableId, int i_accId, int i_langId) const = 0;
613 
615  static ITableAccTxtTable * create(IRowBaseVec & io_rowVec);
616 
618  virtual IRowBaseVec & rowsRef(void) = 0;
619  };
620 
622  struct ITableExprTable : public IMetaLoadedTable<TableExprRow>
623  {
624  virtual ~ITableExprTable() noexcept = 0;
625 
631  static ITableExprTable * create(IDbExec * i_dbExec, int i_modelId = 0);
632 
634  virtual const TableExprRow * byKey(int i_modelId, int i_tableId, int i_exprId) const = 0;
635 
637  virtual vector<TableExprRow> byModelId(int i_modelId) const = 0;
638 
640  virtual vector<TableExprRow> byModelIdTableId(int i_modelId, int i_tableId) const = 0;
641 
643  static ITableExprTable * create(IRowBaseVec & io_rowVec);
644 
646  virtual IRowBaseVec & rowsRef(void) = 0;
647  };
648 
650  struct ITableExprTxtTable : public IMetaLoadedTable<TableExprTxtRow>
651  {
652  virtual ~ITableExprTxtTable() noexcept = 0;
653 
660  static ITableExprTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
661 
663  virtual const TableExprTxtRow * byKey(int i_modelId, int i_tableId, int i_exprId, int i_langId) const = 0;
664 
666  static ITableExprTxtTable * create(IRowBaseVec & io_rowVec);
667 
669  virtual IRowBaseVec & rowsRef(void) = 0;
670  };
671 
673  struct IGroupLstTable : public IMetaLoadedTable<GroupLstRow>
674  {
675  virtual ~IGroupLstTable() noexcept = 0;
676 
682  static IGroupLstTable * create(IDbExec * i_dbExec, int i_modelId = 0);
683 
685  virtual const GroupLstRow * byKey(int i_modelId, int i_groupId) const = 0;
686 
688  virtual vector<GroupLstRow> byModelId(int i_modelId, bool i_isParam) const = 0;
689 
691  static IGroupLstTable * create(IRowBaseVec & io_rowVec);
692 
694  virtual IRowBaseVec & rowsRef(void) = 0;
695  };
696 
698  struct IGroupTxtTable : public IMetaLoadedTable<GroupTxtRow>
699  {
700  virtual ~IGroupTxtTable() noexcept = 0;
701 
708  static IGroupTxtTable * create(IDbExec * i_dbExec, int i_modelId = 0, int i_langId = -1);
709 
711  virtual const GroupTxtRow * byKey(int i_modelId, int i_groupId, int i_langId) const = 0;
712 
714  static IGroupTxtTable * create(IRowBaseVec & io_rowVec);
715 
717  virtual IRowBaseVec & rowsRef(void) = 0;
718  };
719 
721  struct IGroupPcTable : public IMetaLoadedTable<GroupPcRow>
722  {
723  virtual ~IGroupPcTable() noexcept = 0;
724 
730  static IGroupPcTable * create(IDbExec * i_dbExec, int i_modelId = 0);
731 
733  virtual const GroupPcRow * byKey(int i_modelId, int i_groupId, int i_chidPos) const = 0;
734 
736  virtual vector<GroupPcRow> byModelId(int i_modelId) const = 0;
737 
739  virtual vector<int> groupLeafs(int i_modelId, int i_groupId) const = 0;
740 
742  static IGroupPcTable * create(IRowBaseVec & io_rowVec);
743 
745  virtual IRowBaseVec & rowsRef(void) = 0;
746  };
747 
749  struct IProfileLstTable : public IMetaLoadedTable<ProfileLstRow>
750  {
751  virtual ~IProfileLstTable() noexcept = 0;
752 
754  static IProfileLstTable * create(IDbExec * i_dbExec);
755 
757  virtual const ProfileLstRow * byKey(const string & i_name) const = 0;
758 
760  static IProfileLstTable * create(IRowBaseVec & io_rowVec);
761 
763  virtual IRowBaseVec & rowsRef(void) = 0;
764  };
765 
767  struct IProfileOptionTable : public IMetaLoadedTable<ProfileOptionRow>
768  {
769  virtual ~IProfileOptionTable() noexcept = 0;
770 
776  static IProfileOptionTable * create(IDbExec * i_dbExec, const string & i_name = "");
777 
779  virtual const ProfileOptionRow * byKey(const string & i_name, const string & i_key) const = 0;
780 
782  virtual vector<ProfileOptionRow> byName(const string & i_name) const = 0;
783 
785  static IProfileOptionTable * create(IRowBaseVec & io_rowVec);
786 
788  virtual IRowBaseVec & rowsRef(void) = 0;
789  };
790 
792  struct IRunLstTable : public IMetaTable<RunLstRow>
793  {
794  virtual ~IRunLstTable() noexcept = 0;
795 
801  static vector<RunLstRow> select(IDbExec * i_dbExec, int i_modelId = 0);
802 
804  static vector<RunLstRow> byKey(IDbExec * i_dbExec, int i_runId);
805 
807  static string digestRun(IDbExec * i_dbExec, int i_modelId, int i_runId);
808  };
809 
811  struct IRunTxtTable : public IMetaTable<RunTxtRow>
812  {
813  virtual ~IRunTxtTable() noexcept = 0;
814 
820  static vector<RunTxtRow> select(IDbExec * i_dbExec, int i_langId = -1);
821 
823  static vector<RunTxtRow> byKey(IDbExec * i_dbExec, int i_runId, int i_langId);
824  };
825 
827  struct IRunOptionTable : public IMetaLoadedTable<RunOptionRow>
828  {
829  virtual ~IRunOptionTable() noexcept = 0;
830 
836  static IRunOptionTable * create(IDbExec * i_dbExec, int i_runId = 0);
837 
839  virtual const RunOptionRow * byKey(int i_runId, const string & i_key) const = 0;
840 
842  virtual vector<RunOptionRow> byRunId(int i_runId) const = 0;
843 
845  virtual bool isExist(int i_runId, const char * i_key) const noexcept = 0;
846 
848  virtual bool isExist(const char * i_key) const noexcept = 0;
849 
851  virtual string strValue(int i_runId, const char * i_key, const string & i_default = "") const noexcept = 0;
852 
854  virtual string strValue(const char * i_key, const string & i_default = "") const noexcept = 0;
855 
857  virtual bool boolValue(int i_runId, const char * i_key) const noexcept = 0;
858 
860  virtual bool boolValue(const char * i_key) const noexcept = 0;
861 
863  virtual long long longValue(int i_runId, const char * i_key, long long i_default) const noexcept = 0;
864 
866  virtual long long longValue(const char * i_key, long long i_default) const noexcept = 0;
867 
869  virtual double doubleValue(int i_runId, const char * i_key, double i_default) const noexcept = 0;
870 
872  virtual double doubleValue(const char * i_key, double i_default) const noexcept = 0;
873 
875  static IRunOptionTable * create(IRowBaseVec & io_rowVec);
876 
878  virtual IRowBaseVec & rowsRef(void) = 0;
879  };
880 
882  struct IRunParamTxtTable : public IMetaLoadedTable<RunParamTxtRow>
883  {
884  virtual ~IRunParamTxtTable() noexcept = 0;
885 
892  static IRunParamTxtTable * create(IDbExec * i_dbExec, int i_runId = 0, int i_langId = -1);
893 
895  virtual const RunParamTxtRow * byKey(int i_runId, int i_paramId, int i_langId) const = 0;
896 
898  static IRunParamTxtTable * create(IRowBaseVec & io_rowVec);
899 
901  virtual IRowBaseVec & rowsRef(void) = 0;
902  };
903 
905  struct IWorksetLstTable : public IMetaTable<WorksetLstRow>
906  {
907  virtual ~IWorksetLstTable() noexcept = 0;
908 
914  static vector<WorksetLstRow> select(IDbExec * i_dbExec, int i_modelId = 0);
915 
917  static vector<WorksetLstRow> byKey(IDbExec * i_dbExec, int i_setId);
918  };
919 
921  struct IWorksetTxtTable : public IMetaTable<WorksetTxtRow>
922  {
923  virtual ~IWorksetTxtTable() noexcept = 0;
924 
930  static vector<WorksetTxtRow> select(IDbExec * i_dbExec, int i_langId = -1);
931 
933  static vector<WorksetTxtRow> byKey(IDbExec * i_dbExec, int i_setId, int i_langId);
934  };
935 
937  struct IWorksetParamTable : public IMetaTable<WorksetParamRow>
938  {
939  virtual ~IWorksetParamTable() noexcept = 0;
940 
946  static vector<WorksetParamRow> select(IDbExec * i_dbExec, int i_setId = 0);
947 
949  static vector<WorksetParamRow> byKey(IDbExec * i_dbExec, int i_setId, int i_paramId);
950  };
951 
953  struct IWorksetParamTxtTable : public IMetaTable<WorksetParamTxtRow>
954  {
955  virtual ~IWorksetParamTxtTable() noexcept = 0;
956 
963  static vector<WorksetParamTxtRow> select(IDbExec * i_dbExec, int i_setId = 0, int i_langId = -1);
964 
966  static vector<WorksetParamTxtRow> byKey(IDbExec * i_dbExec, int i_setId, int i_paramId, int i_langId);
967  };
968 
969 
971  struct ITaskLstTable : public IMetaTable<TaskLstRow>
972  {
973  virtual ~ITaskLstTable() noexcept = 0;
974 
980  static vector<TaskLstRow> select(IDbExec * i_dbExec, int i_modelId = 0);
981 
983  static vector<TaskLstRow> byKey(IDbExec * i_dbExec, int i_taskId);
984  };
985 
987  struct ITaskTxtTable : public IMetaTable<TaskTxtRow>
988  {
989  virtual ~ITaskTxtTable() noexcept = 0;
990 
996  static vector<TaskTxtRow> select(IDbExec * i_dbExec, int i_langId = -1);
997 
999  static vector<TaskTxtRow> byKey(IDbExec * i_dbExec, int i_taskId, int i_langId);
1000  };
1001 
1003  struct ITaskSetTable : public IMetaTable<TaskSetRow>
1004  {
1005  virtual ~ITaskSetTable() noexcept = 0;
1006 
1012  static vector<TaskSetRow> select(IDbExec * i_dbExec, int i_taskId = 0);
1013 
1015  static vector<TaskSetRow> byKey(IDbExec * i_dbExec, int i_taskId, int i_setId);
1016  };
1017 
1019  struct ITaskRunLstTable : public IMetaTable<TaskRunLstRow>
1020  {
1021  virtual ~ITaskRunLstTable() noexcept = 0;
1022 
1028  static vector<TaskRunLstRow> select(IDbExec * i_dbExec, int i_taskId = 0);
1029 
1031  static vector<TaskRunLstRow> byKey(IDbExec * i_dbExec, int i_taskRunId);
1032  };
1033 
1035  struct ITaskRunSetTable : public IMetaTable<TaskRunSetRow>
1036  {
1037  virtual ~ITaskRunSetTable() noexcept = 0;
1038 
1044  static vector<TaskRunSetRow> select(IDbExec * i_dbExec, int i_taskRunId = 0);
1045 
1047  static vector<TaskRunSetRow> byKey(IDbExec * i_dbExec, int i_taskRunId, int i_runId);
1048  };
1049 }
1050 
1051 #endif // DB_META_TABLE_H
task_run_set table public interface.
Definition: dbMetaTable.h:1035
type_enum_txt join to model_type_dic table row.
Definition: dbMetaRow.h:425
type_enum_lst table public interface.
Definition: dbMetaTable.h:293
type_dic_txt join to model_type_dic table row.
Definition: dbMetaRow.h:338
table_dic_txt table row.
Definition: dbMetaRow.h:824
const TRow * byIndex(IRowBaseVec::difference_type i_index) const
return row value by index or NULL if out of range.
Definition: dbMetaTable.h:86
task_txt table public interface.
Definition: dbMetaTable.h:987
table_dic table public interface.
Definition: dbMetaTable.h:471
profile_option table public interface.
Definition: dbMetaTable.h:767
parameter_dic table public interface.
Definition: dbMetaTable.h:347
group_txt table public interface.
Definition: dbMetaTable.h:698
lang_word table row.
Definition: dbMetaRow.h:83
table_expr table row.
Definition: dbMetaRow.h:1093
table_dims_txt table public interface.
Definition: dbMetaTable.h:547
base class for metadata db-tables
Definition: dbMetaTable.h:22
group_txt table row.
Definition: dbMetaRow.h:1235
parameter_dims_txt table public interface.
Definition: dbMetaTable.h:448
static IRowBaseVec load(const string &i_sqlSelect, IDbExec *i_dbExec, const IRowAdapter &i_adapter)
load table: return vector of selected rows sorted by primary key.
Definition: dbMetaTable.h:114
table_dims_txt table row.
Definition: dbMetaRow.h:931
workset_lst table public interface.
Definition: dbMetaTable.h:905
type_enum_lst join to model_type_dic table row.
Definition: dbMetaRow.h:390
run_option table public interface.
Definition: dbMetaTable.h:827
parameter_dims join to model_parameter_dic table row.
Definition: dbMetaRow.h:650
parameter_dims_txt join to model_parameter_dic table row.
Definition: dbMetaRow.h:690
group_pc table public interface.
Definition: dbMetaTable.h:721
group_lst table public interface.
Definition: dbMetaTable.h:673
profile_lst table row.
Definition: dbMetaRow.h:1326
model_dic_txt table row.
Definition: dbMetaRow.h:170
task_run_lst table public interface.
Definition: dbMetaTable.h:1019
openM++ namespace
Definition: argReader.cpp:16
task_lst table public interface.
Definition: dbMetaTable.h:971
parameter_dims table public interface.
Definition: dbMetaTable.h:423
lang_lst table row.
Definition: dbMetaRow.h:39
vector< TRow > findAll(RowEqual i_cmp) const
get list of rows by predicate: all rows where comparator to i_row return true.
Definition: dbMetaTable.h:73
lang_lst table public interface.
Definition: dbMetaTable.h:132
function< bool(const TRow &i_dbRow)> RowEqual
db table row comparator.
Definition: dbMetaTable.h:43
table_dic_txt table public interface.
Definition: dbMetaTable.h:499
database connection wrapper to execute sql commands.
Definition: dbExec.h:20
model_word table public interface.
Definition: dbMetaTable.h:225
table_expr table public interface.
Definition: dbMetaTable.h:622
parameter_dic_txt table public interface.
Definition: dbMetaTable.h:400
IRowBaseVec::size_type countOf(RowEqual i_cmp) const
count rows by predicate: where comparator to i_row return true.
Definition: dbMetaTable.h:103
table_acc table row.
Definition: dbMetaRow.h:987
model_word table row.
Definition: dbMetaRow.h:218
base class for preloaded metadata db-tables
Definition: dbMetaTable.h:40
run_parameter_txt join to model_parameter_dic table row.
Definition: dbMetaRow.h:1517
model_parameter_import table public interface.
Definition: dbMetaTable.h:375
workset_txt table public interface.
Definition: dbMetaTable.h:921
virtual IRowBaseVec selectRowVector(const string &i_sql, const IRowAdapter &i_adapter)=0
select vector of rows, each row created and field values set by row adapter.
profile_lst table public interface.
Definition: dbMetaTable.h:749
profile_option table row.
Definition: dbMetaRow.h:1347
parameter_dic_txt join to model_parameter_dic table row.
Definition: dbMetaRow.h:598
type_dic_txt table public interface.
Definition: dbMetaTable.h:270
vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:190
run_option table row.
Definition: dbMetaRow.h:1486
row factory and setter interface to select row from database
Definition: dbCommon.h:44
const TRow * firstRow(void) const
return first table row or NULL if table is empty.
Definition: dbMetaTable.h:67
run_parameter_txt table public interface.
Definition: dbMetaTable.h:882
parameter_dic join to model_parameter_dic table row.
Definition: dbMetaRow.h:481
run_txt table public interface.
Definition: dbMetaTable.h:811
task_set table public interface.
Definition: dbMetaTable.h:1003
OpenM++ data library: db rows of model metadata tables.
model_dic table row.
Definition: dbMetaRow.h:114
table_dims table row.
Definition: dbMetaRow.h:884
workset_parameter_txt table public interface.
Definition: dbMetaTable.h:953
table_acc_txt table public interface.
Definition: dbMetaTable.h:599
OpenmException< 4000, dbUnknownErrorMessage > DbException
db-exception
Definition: dbCommon.h:41
IRowBaseVec::difference_type indexOf(RowEqual i_cmp, IRowBaseVec::difference_type i_startPos=0) const
get first row by predicate or -1 if not found: first row where comparator to i_row return true...
Definition: dbMetaTable.h:92
model_dic table public interface.
Definition: dbMetaTable.h:174
OpenM++ data library: public interface.
workset_parameter table public interface.
Definition: dbMetaTable.h:937
type_enum_txt table public interface.
Definition: dbMetaTable.h:324
type_dic table public interface.
Definition: dbMetaTable.h:248
group_pc table row.
Definition: dbMetaRow.h:1287
group_lst table row.
Definition: dbMetaRow.h:1196
parameter_dic join to model_parameter_import table row.
Definition: dbMetaRow.h:555
table_acc_txt table row.
Definition: dbMetaRow.h:1037
run_lst table public interface.
Definition: dbMetaTable.h:792
table_dic table row.
Definition: dbMetaRow.h:746
static vector< TRow > rows(const IRowBaseVec &i_rowVec)
get list of table rows.
Definition: dbMetaTable.h:29
vector< TRow > rows(void) const
get list of loaded table rows.
Definition: dbMetaTable.h:57
IRowBaseVec::difference_type rowCount(void) const
return number of rows.
Definition: dbMetaTable.h:54
type_dic join to model_type_dic table row.
Definition: dbMetaRow.h:266
const TRow * findFirst(RowEqual i_cmp) const
get first row by predicate or NULL if not found: first row where comparator to i_row return true...
Definition: dbMetaTable.h:83
const TRow * findKey(const IRowBaseUptr &i_row) const
binary search row by primary key, return NULL if not found.
Definition: dbMetaTable.h:124
table_dims table public interface.
Definition: dbMetaTable.h:522
unique_ptr< IRowBase > IRowBaseUptr
unique pointer to db row
Definition: omHelper.h:187
table_acc table public interface.
Definition: dbMetaTable.h:570
lang_word table public interface.
Definition: dbMetaTable.h:153
model_dic_txt table public interface.
Definition: dbMetaTable.h:202
table_expr_txt table row.
Definition: dbMetaRow.h:1140
table_expr_txt table public interface.
Definition: dbMetaTable.h:650