SegmentDB.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "SegmentDB.h"
  4. #include "SegmentTable.h"
  5. namespace OTSSQLITE
  6. {
  7. CSegmentDB::CSegmentDB(CDBStoreBasePtr a_datastore)
  8. {
  9. m_tableInfo.reset(new CSegmentTable());
  10. myDB = CreateNewSQLiteDB(a_datastore,m_tableInfo);
  11. }
  12. CSegmentDB::~CSegmentDB()
  13. {
  14. }
  15. COTSFeaturePtr CSegmentDB::GetFeatureById(const long a_nXrayId, const long a_nFieldId, const long a_nSegmentSize)
  16. {
  17. COTSFeaturePtr pFeatureNew = nullptr;
  18. if (!m_listParticle.empty())
  19. {
  20. for (auto pParticle : m_listParticle)
  21. {
  22. COTSFeaturePtr pFeature = pParticle->GetFeature();
  23. ASSERT(pFeature);
  24. if (!pFeature)
  25. {
  26. return nullptr;
  27. }
  28. if (pParticle->GetAnalysisId() == (DWORD)a_nXrayId && pParticle->GetFieldId() == a_nFieldId && (int)pFeature->GetSegmentsList().size() == a_nSegmentSize)
  29. {
  30. pFeatureNew = COTSFeaturePtr(new COTSFeature(*pFeature.get()));
  31. }
  32. }
  33. }
  34. else
  35. {
  36. // read element list
  37. for (int i = 0; i < a_nSegmentSize; i++)
  38. {
  39. auto tableQuery = GetQueryById(a_nXrayId, a_nFieldId, i, a_nSegmentSize);
  40. ASSERT(tableQuery);
  41. if (!tableQuery)
  42. {
  43. return nullptr;
  44. }
  45. COTSParticlePtr pParticle = ReadParticleInfo(tableQuery);
  46. ASSERT(pParticle);
  47. if (!pParticle)
  48. {
  49. return nullptr;
  50. }
  51. COTSFeaturePtr pFeature = pParticle->GetFeature();
  52. ASSERT(pFeature);
  53. if (!pFeature)
  54. {
  55. return nullptr;
  56. }
  57. pFeatureNew = COTSFeaturePtr(new COTSFeature(*pFeature.get()));
  58. }
  59. }
  60. return pFeatureNew;
  61. }
  62. COTSParticleList& CSegmentDB::GetParticleInfoList(const BOOL a_bForce/* = FALSE*/)
  63. {
  64. if (a_bForce)
  65. {
  66. m_listParticle.clear();
  67. }
  68. if (m_listParticle.size() == 0)
  69. {
  70. ReadParticleInfoList();
  71. }
  72. return m_listParticle;
  73. }
  74. BOOL CSegmentDB::SaveFeature(const COTSParticleList& a_ParticleList)
  75. {
  76. if (!Init())
  77. {
  78. ASSERT(FALSE);
  79. return FALSE;
  80. }
  81. auto tableInfoPtr = GetTableInfo();
  82. ASSERT(tableInfoPtr);
  83. if (!tableInfoPtr)
  84. {
  85. return FALSE;
  86. }
  87. auto datastorePtr = GetDatastore();
  88. ASSERT(datastorePtr);
  89. if (!datastorePtr)
  90. {
  91. return FALSE;
  92. }
  93. CString sInsertFormat = tableInfoPtr->GetInsertCommandFormatString(TRUE);
  94. CString sSQLCommand;
  95. for (auto pParticle : a_ParticleList)
  96. {
  97. COTSFeaturePtr pFeature = pParticle->GetFeature();
  98. ASSERT(pFeature);
  99. if (!pFeature)
  100. {
  101. return FALSE;
  102. }
  103. COTSSegmentsList listSegments = pFeature->GetSegmentsList();
  104. int nSize = (int)listSegments.size();
  105. int nSegmentIndex = 0;
  106. for (auto pSegment : listSegments)
  107. {
  108. sSQLCommand.Format(sInsertFormat,
  109. pParticle->GetAnalysisId(),
  110. pParticle->GetFieldId(),
  111. nSegmentIndex,
  112. nSize,
  113. pSegment->GetStart(),
  114. pSegment->GetHeight(),
  115. pSegment->GetLength()),
  116. pParticle->GetTagId();
  117. if (!datastorePtr->RunCommand(sSQLCommand))
  118. {
  119. LogErrorTrace(__FILE__, __LINE__, _T("Insert segment(%d:%d:%d:%d) failed: %s command error"),
  120. pParticle->GetAnalysisId(),
  121. pParticle->GetFieldId(),
  122. nSegmentIndex,
  123. nSize,
  124. pSegment->GetStart(),
  125. pSegment->GetHeight(),
  126. pSegment->GetLength(),
  127. pParticle->GetTagId(),
  128. sSQLCommand);
  129. ASSERT(FALSE);
  130. return FALSE;
  131. }
  132. nSegmentIndex++;
  133. }
  134. }
  135. return TRUE;
  136. }
  137. BOOL CSegmentDB::SaveFeature(COTSParticlePtr a_pParticle)
  138. {
  139. if (!Init())
  140. {
  141. ASSERT(FALSE);
  142. return FALSE;
  143. }
  144. auto tableInfoPtr = GetTableInfo();
  145. ASSERT(tableInfoPtr);
  146. if (!tableInfoPtr)
  147. {
  148. return FALSE;
  149. }
  150. auto datastorePtr = GetDatastore();
  151. ASSERT(datastorePtr);
  152. if (!datastorePtr)
  153. {
  154. return FALSE;
  155. }
  156. CString sInsertFormat = tableInfoPtr->GetInsertCommandFormatString(TRUE);
  157. CString sSQLCommand;
  158. ASSERT(a_pParticle);
  159. if (!a_pParticle)
  160. {
  161. return FALSE;
  162. }
  163. COTSFeaturePtr pFeature = a_pParticle->GetFeature();
  164. COTSSegmentsList listSegments = pFeature->GetSegmentsList();
  165. int nSize = (int)listSegments.size();
  166. int nSegmentIndex = 0;
  167. for (auto pSegment : listSegments)
  168. {
  169. sSQLCommand.Format(sInsertFormat,
  170. a_pParticle->GetAnalysisId(),
  171. a_pParticle->GetFieldId(),
  172. nSegmentIndex,
  173. nSize,
  174. pSegment->GetStart(),
  175. pSegment->GetHeight(),
  176. pSegment->GetLength(),
  177. a_pParticle->GetTagId ());
  178. if (!datastorePtr->RunCommand(sSQLCommand))
  179. {
  180. LogErrorTrace(__FILE__, __LINE__, _T("Insert element(%d:%d:%d:%d) failed: %s command error"),
  181. a_pParticle->GetAnalysisId(),
  182. a_pParticle->GetFieldId(),
  183. nSegmentIndex,
  184. nSize,
  185. pSegment->GetStart(),
  186. pSegment->GetHeight(),
  187. pSegment->GetLength(),
  188. a_pParticle->GetTagId(),
  189. sSQLCommand);
  190. ASSERT(FALSE);
  191. return FALSE;
  192. }
  193. nSegmentIndex++;
  194. }
  195. return TRUE;
  196. }
  197. BOOL CSegmentDB::DeleteFeatureById(const long a_nFieldId, const long a_nXrayId)
  198. {
  199. if (!m_listParticle.empty())
  200. {
  201. std::remove_if(m_listParticle.begin(), m_listParticle.end(), [a_nFieldId, a_nXrayId](const COTSParticlePtr p) { return(p->GetAnalysisId() == (DWORD)a_nXrayId) && (p->GetFieldId() == (DWORD)a_nFieldId); });
  202. }
  203. auto tableInfoPtr = GetTableInfo();
  204. ASSERT(tableInfoPtr);
  205. if (!tableInfoPtr)
  206. {
  207. return FALSE;
  208. }
  209. auto datastorePtr = GetDatastore();
  210. ASSERT(datastorePtr);
  211. if (!datastorePtr)
  212. {
  213. return FALSE;
  214. }
  215. CString sTableName = tableInfoPtr->GetTableName();
  216. if (!datastorePtr->IsTableExists(sTableName))
  217. {
  218. LogTrace(__FILE__, __LINE__, _T("Table %s not exist"), sTableName);
  219. return TRUE;
  220. }
  221. CString sXrayIdColumnName = tableInfoPtr->GetColumnName((int)CSegmentTable::ColumnID::N_XRAY_INDEX - (int)CSegmentTable::ColumnID::MIN);
  222. CString sFieldIdColumnName = tableInfoPtr->GetColumnName((int)CSegmentTable::ColumnID::N_FIELD_ID - (int)CSegmentTable::ColumnID::MIN);
  223. CString sSQLCommand;
  224. sSQLCommand.Format(_T("DELETE FROM \'%s\' WHERE %s = %d AND %s = %d AND %s = %d AND %s = %d;"),
  225. (LPCTSTR)tableInfoPtr->GetTableName(),
  226. (LPCTSTR)sXrayIdColumnName,
  227. a_nXrayId,
  228. (LPCTSTR)sFieldIdColumnName,
  229. a_nFieldId);
  230. return datastorePtr->RunCommand(sSQLCommand);
  231. }
  232. CDBTableBasePtr CSegmentDB::GetTableInfo()
  233. {
  234. /*if (!m_tableInfo)
  235. {
  236. m_tableInfo.reset(new CSegmentTable);
  237. }
  238. */
  239. return m_tableInfo;
  240. }
  241. BOOL CSegmentDB::ReadParticleInfoList()
  242. {
  243. auto tableInfoPtr = GetTableInfo();
  244. ASSERT(tableInfoPtr);
  245. if (!tableInfoPtr)
  246. {
  247. return FALSE;
  248. }
  249. auto query = GetTableQuery();
  250. ASSERT(query);
  251. if (!query)
  252. {
  253. return FALSE;
  254. }
  255. m_listParticle = ReadParticleInfoList(query);
  256. return TRUE;
  257. }
  258. COTSParticleList CSegmentDB::ReadParticleInfoList(CDBQueryBasePtr a_query)
  259. {
  260. COTSParticleList listParticle;
  261. int nRowId = 0;
  262. int nWrongItems = 0;
  263. while (!a_query->IsEOF())
  264. {
  265. auto ParticleInfo = ReadParticleInfo(a_query); //current x-ray point
  266. if (!ParticleInfo)
  267. {
  268. LogErrorTrace(__FILE__, __LINE__, _T("Read particle info item failed: row id: %d"), nRowId);
  269. nWrongItems++;
  270. }
  271. else
  272. {
  273. if (!listParticle.empty())
  274. {
  275. int nXrayId = ParticleInfo->GetAnalysisId();
  276. int nFieldId = ParticleInfo->GetFieldId();
  277. COTSFeaturePtr pFeature = ParticleInfo->GetFeature();
  278. ASSERT(pFeature);
  279. if (!pFeature)
  280. {
  281. return listParticle;
  282. }
  283. COTSSegmentsList listSegmentNew = pFeature->GetSegmentsList();
  284. int nIndex = 0;
  285. for (auto pParticle : listParticle)
  286. {
  287. listParticle.erase(listParticle.begin() + nIndex);
  288. if ((pParticle->GetAnalysisId() == nXrayId)
  289. && (pParticle->GetFieldId() == nFieldId))
  290. {
  291. COTSFeaturePtr pFeature = pParticle->GetFeature();
  292. ASSERT(pFeature);
  293. if (!pFeature)
  294. {
  295. return listParticle;
  296. }
  297. COTSSegmentsList listSegmentOld = pFeature->GetSegmentsList();
  298. for (auto pSegment : listSegmentNew)
  299. {
  300. listSegmentOld.push_back(COTSSegmentPtr(new COTSSegment(*pSegment.get())));
  301. }
  302. pFeature->SetSegmentsList(listSegmentOld);
  303. ParticleInfo->SetFeature(pFeature);
  304. break;
  305. }
  306. nIndex++;
  307. }
  308. }
  309. listParticle.push_back(ParticleInfo);
  310. }
  311. a_query->NextRow();
  312. nRowId++;
  313. }
  314. return listParticle;
  315. }
  316. COTSParticlePtr CSegmentDB::ReadParticleInfo(CDBQueryBasePtr a_query)
  317. {
  318. int nCol;
  319. COTSParticlePtr pParticle(new COTSParticle());
  320. int nXrayIdNow;
  321. int nFieldIdNow;
  322. nCol = (int)CSegmentTable::ColumnID::N_XRAY_INDEX - (int)CSegmentTable::ColumnID::MIN;
  323. nXrayIdNow = a_query->GetColIntValue(nCol, -1);
  324. pParticle->SetAnalysisId(nXrayIdNow);
  325. nCol = (int)CSegmentTable::ColumnID::N_FIELD_ID - (int)CSegmentTable::ColumnID::MIN;
  326. nFieldIdNow = a_query->GetColIntValue(nCol, -1);
  327. pParticle->SetFieldId(nFieldIdNow);
  328. nCol = (int)CSegmentTable::ColumnID::N_SEGMENT_ID - (int)CSegmentTable::ColumnID::MIN;
  329. int nSegmentIndex = a_query->GetColIntValue(nCol, -1);
  330. nCol = (int)CSegmentTable::ColumnID::N_SEGMENT_TOTAL - (int)CSegmentTable::ColumnID::MIN;
  331. int nSegmentTotal = a_query->GetColIntValue(nCol, -1);
  332. //pParticle->SetElementNum(nElementTotal);
  333. if (nSegmentIndex > nSegmentTotal - 1)
  334. {
  335. return nullptr;
  336. }
  337. COTSSegmentPtr pSegment = COTSSegmentPtr(new COTSSegment());
  338. nCol = (int)CSegmentTable::ColumnID::N_START - (int)CSegmentTable::ColumnID::MIN;
  339. int nStart = a_query->GetColIntValue(nCol, -1);
  340. pSegment->SetStart(nStart);
  341. nCol = (int)CSegmentTable::ColumnID::N_HEIGHT - (int)CSegmentTable::ColumnID::MIN;
  342. int nHeight = a_query->GetColIntValue(nCol, -1);
  343. pSegment->SetHeight(nHeight);
  344. nCol = (int)CSegmentTable::ColumnID::N_LENGTH - (int)CSegmentTable::ColumnID::MIN;
  345. int nLength = a_query->GetColIntValue(nCol, -1);
  346. pSegment->SetLength(nLength);
  347. COTSSegmentsList listSegment;
  348. listSegment.push_back(pSegment);
  349. a_query->NextRow();
  350. int nXrayNew, nFieldIdNew;
  351. int nRowId = 0;
  352. while (!a_query->IsEOF())
  353. {
  354. nCol = (int)CSegmentTable::ColumnID::N_XRAY_INDEX - (int)CSegmentTable::ColumnID::MIN;
  355. nXrayNew = a_query->GetColIntValue(nCol, -1);
  356. nCol = (int)CSegmentTable::ColumnID::N_FIELD_ID - (int)CSegmentTable::ColumnID::MIN;
  357. nFieldIdNew = a_query->GetColIntValue(nCol, -1);
  358. if (nXrayNew == nXrayIdNow && nFieldIdNew == nFieldIdNow)
  359. {
  360. nCol = (int)CSegmentTable::ColumnID::N_SEGMENT_ID - (int)CSegmentTable::ColumnID::MIN;
  361. int nSegmentIndex = a_query->GetColIntValue(nCol, -1);
  362. nCol = (int)CSegmentTable::ColumnID::N_SEGMENT_TOTAL - (int)CSegmentTable::ColumnID::MIN;
  363. int nSegmentTotal = a_query->GetColIntValue(nCol, -1);
  364. if (nSegmentIndex > nSegmentTotal - 1)
  365. {
  366. return nullptr;
  367. }
  368. COTSSegmentPtr pSegment = COTSSegmentPtr(new COTSSegment());
  369. nCol = (int)CSegmentTable::ColumnID::N_START - (int)CSegmentTable::ColumnID::MIN;
  370. int nStart = a_query->GetColIntValue(nCol, -1);
  371. pSegment->SetStart(nStart);
  372. nCol = (int)CSegmentTable::ColumnID::N_HEIGHT - (int)CSegmentTable::ColumnID::MIN;
  373. int nHeight = a_query->GetColIntValue(nCol, -1);
  374. pSegment->SetHeight(nHeight);
  375. nCol = (int)CSegmentTable::ColumnID::N_LENGTH - (int)CSegmentTable::ColumnID::MIN;
  376. int nLength = a_query->GetColIntValue(nCol, -1);
  377. pSegment->SetLength(nLength);
  378. listSegment.push_back(pSegment);
  379. if (nSegmentIndex == nSegmentTotal - 1)
  380. {
  381. break;
  382. }
  383. }
  384. else
  385. {
  386. continue;
  387. }
  388. a_query->NextRow();
  389. nRowId++;
  390. }
  391. COTSFeaturePtr pFeature = COTSFeaturePtr(new COTSFeature());
  392. pFeature->SetSegmentsList(listSegment);
  393. pParticle->SetFeature(pFeature);
  394. return pParticle;
  395. }
  396. CDBQueryBasePtr CSegmentDB::GetQueryById(const long a_nXrayId, const long a_nFieldId, const long a_nSegmentId, const long a_nSegmentNum)
  397. {
  398. CDBQueryBasePtr query;
  399. auto datastorePtr = GetDatastore();
  400. ASSERT(datastorePtr);
  401. if (!datastorePtr)
  402. {
  403. return query;
  404. }
  405. auto tableInfoPtr = GetTableInfo();
  406. ASSERT(tableInfoPtr);
  407. if (!tableInfoPtr)
  408. {
  409. return query;
  410. }
  411. CString sXrayIdColumnName = tableInfoPtr->GetColumnName((int)CSegmentTable::ColumnID::N_XRAY_INDEX - (int)CSegmentTable::ColumnID::MIN);
  412. CString sFieldIdColumnName = tableInfoPtr->GetColumnName((int)CSegmentTable::ColumnID::N_FIELD_ID - (int)CSegmentTable::ColumnID::MIN);
  413. CString sElementIdColumnName = tableInfoPtr->GetColumnName((int)CSegmentTable::ColumnID::N_SEGMENT_ID - (int)CSegmentTable::ColumnID::MIN);
  414. CString sElementNumColumnName = tableInfoPtr->GetColumnName((int)CSegmentTable::ColumnID::N_SEGMENT_TOTAL - (int)CSegmentTable::ColumnID::MIN);
  415. CString sSQLCommand;
  416. sSQLCommand.Format(_T("SELECT * FROM \'%s\' WHERE %s = %d AND %s = %d AND %s = %d AND %s = %d;"),
  417. (LPCTSTR)tableInfoPtr->GetTableName(),
  418. (LPCTSTR)sFieldIdColumnName,
  419. a_nFieldId,
  420. (LPCTSTR)sXrayIdColumnName,
  421. a_nXrayId,
  422. (LPCTSTR)sElementIdColumnName,
  423. a_nSegmentId,
  424. (LPCTSTR)sElementNumColumnName,
  425. a_nSegmentNum);
  426. query = datastorePtr->QueryByCommand(sSQLCommand);
  427. ASSERT(query);
  428. if (!query || !query->IsValid())
  429. {
  430. LogErrorTrace(__FILE__, __LINE__, _T("Invalid quary command (%s)."), (LPCTSTR)sSQLCommand);
  431. ASSERT(FALSE);
  432. return (CDBQueryBasePtr());
  433. }
  434. // do the table related valid checking
  435. if (query->GetColCount() != GetTableInfo()->GetColumnCount())
  436. {
  437. LogErrorTrace(__FILE__, __LINE__, _T("query col num value is %d, but not %d"), query->GetColCount(), GetTableInfo()->GetColumnCount());
  438. ASSERT(FALSE);
  439. return (CDBQueryBasePtr());
  440. }
  441. return query;
  442. }
  443. CDBQueryBasePtr CSegmentDB::GetQueryOfAllRecord()
  444. {
  445. CDBQueryBasePtr query;
  446. auto datastorePtr = GetDatastore();
  447. ASSERT(datastorePtr);
  448. if (!datastorePtr)
  449. {
  450. return query;
  451. }
  452. auto tableInfoPtr = GetTableInfo();
  453. ASSERT(tableInfoPtr);
  454. if (!tableInfoPtr)
  455. {
  456. return query;
  457. }
  458. CString sSQLCommand;
  459. sSQLCommand.Format(_T("SELECT * FROM \'%s\';"),
  460. (LPCTSTR)tableInfoPtr->GetTableName());
  461. query = datastorePtr->QueryByCommand(sSQLCommand);
  462. ASSERT(query);
  463. if (!query || !query->IsValid())
  464. {
  465. LogErrorTrace(__FILE__, __LINE__, _T("Invalid quary command (%s)."), (LPCTSTR)sSQLCommand);
  466. ASSERT(FALSE);
  467. return (CDBQueryBasePtr());
  468. }
  469. // do the table related valid checking
  470. if (query->GetColCount() != GetTableInfo()->GetColumnCount())
  471. {
  472. LogErrorTrace(__FILE__, __LINE__, _T("query col num value is %d, but not %d"), query->GetColCount(), GetTableInfo()->GetColumnCount());
  473. ASSERT(FALSE);
  474. return (CDBQueryBasePtr());
  475. }
  476. return query;
  477. }
  478. bool CSegmentDB::GetAllSegmentsRecord(std::map<std::vector <int>, COTSSegmentsList>& mapSegments)
  479. {
  480. //std::map<std::vector <int>, COTSSegmentsList> mapSegments;//the vector contains two value: fieldId and XrayId
  481. auto allRecords = this->GetQueryOfAllRecord();
  482. while (!allRecords->IsEOF())
  483. {
  484. int curFldId= allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_FIELD_ID);
  485. int curParticleId = allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_PARTICLE_ID);
  486. std::vector <int> fldvec;
  487. fldvec.push_back(curFldId);
  488. fldvec.push_back(curParticleId);
  489. auto itr = mapSegments.find(fldvec);
  490. if (itr == mapSegments.end())
  491. {
  492. COTSSegmentsList segments;
  493. COTSSegmentPtr segment = COTSSegmentPtr(new COTSSegment());
  494. segment->SetStart(allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_START));
  495. segment->SetHeight(allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_HEIGHT));
  496. segment->SetLength(allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_LENGTH));
  497. segments.push_back(segment);
  498. mapSegments.insert(std::pair <std::vector <int>, COTSSegmentsList>(fldvec, segments));
  499. //mapSegments[fldvec] = segments;
  500. }
  501. else
  502. {
  503. //auto pairseg = *itr;
  504. COTSSegmentsList& segments = itr->second;
  505. COTSSegmentPtr segment = COTSSegmentPtr(new COTSSegment());
  506. segment->SetStart(allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_START));
  507. segment->SetHeight(allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_HEIGHT));
  508. segment->SetLength(allRecords->GetColIntValue((int)CSegmentTable::ColumnID::N_LENGTH));
  509. segments.push_back(segment);
  510. }
  511. allRecords->NextRow();
  512. } ;
  513. allRecords->Close();
  514. return true;
  515. }
  516. BOOL CSegmentDB::Init(const BOOL a_bClean /*= FALSE*/)
  517. {
  518. return myDB->Init(a_bClean);
  519. }
  520. BOOL CSegmentDB::CreateTable(const BOOL a_bForce /*= FALSE*/)
  521. {
  522. return myDB->CreateTable(a_bForce);
  523. }
  524. BOOL CSegmentDB::DeleteTable()
  525. {
  526. return myDB->DeleteTable();
  527. }
  528. BOOL CSegmentDB::RemoveAllRows()
  529. {
  530. return myDB->RemoveAllRows();
  531. }
  532. BOOL CSegmentDB::IsDBExist()
  533. {
  534. return myDB->IsDBExist();
  535. }
  536. OTSSQLITE::CDBStoreBasePtr CSegmentDB::GetDatastore()
  537. {
  538. return myDB->GetDatastore();
  539. }
  540. OTSSQLITE::CDBQueryBasePtr CSegmentDB::GetTableQuery(LPCTSTR a_sOrderColumnName /*= nullptr*/)
  541. {
  542. return myDB->GetTableQuery(a_sOrderColumnName);
  543. }
  544. }