TriTempFileClr.cpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. #include "stdafx.h"
  2. #include "TriTempFileClr.h"
  3. namespace OTSINTERFACE {
  4. CTriTempFileClr::CTriTempFileClr() // constructor
  5. {
  6. m_LpTempFile = new CTriTempFilePtr(new CTriTempFile());
  7. }
  8. CTriTempFileClr::CTriTempFileClr(CTriTempFilePtr a_pTriTempFile) // copy constructor
  9. {
  10. if (a_pTriTempFile == nullptr)
  11. {
  12. LogErrorTrace(__FILE__, __LINE__, _T("CTriTempFileClr: invalid pointer"));
  13. return;
  14. }
  15. m_LpTempFile = new CTriTempFilePtr(a_pTriTempFile);
  16. }
  17. CTriTempFileClr::!CTriTempFileClr()
  18. {
  19. if (m_LpTempFile != nullptr)
  20. {
  21. delete m_LpTempFile;
  22. m_LpTempFile = nullptr;
  23. }
  24. }
  25. CTriTempFileClr::~CTriTempFileClr()
  26. {
  27. if (m_LpTempFile != nullptr)
  28. {
  29. delete m_LpTempFile;
  30. m_LpTempFile = nullptr;
  31. }
  32. }
  33. CTriTempFilePtr CTriTempFileClr::GetTriTempFilePtr()
  34. {
  35. return *m_LpTempFile;
  36. }
  37. bool CTriTempFileClr::Init()
  38. {
  39. if (m_LpTempFile == nullptr)
  40. {
  41. LogErrorTrace(__FILE__, __LINE__, _T("Init:empty pointer."));
  42. return false;
  43. }
  44. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  45. ASSERT(pTriTempFile);
  46. if (!pTriTempFile)
  47. {
  48. LogErrorTrace(__FILE__, __LINE__, _T("Init: invalide pointer."));
  49. return false;
  50. }
  51. return true;
  52. }
  53. // name
  54. String^ CTriTempFileClr::GetName()
  55. {
  56. if (m_LpTempFile == nullptr)
  57. {
  58. LogErrorTrace(__FILE__, __LINE__, _T("GetName: current CLR point is invalid."));
  59. return nullptr;
  60. }
  61. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  62. ASSERT(pTriTempFile);
  63. if (!pTriTempFile)
  64. {
  65. LogErrorTrace(__FILE__, __LINE__, _T("GetName:invalid pointer."));
  66. return nullptr;
  67. }
  68. CString sTriTemp = pTriTempFile->GetName();
  69. String^ sTriTempClr = gcnew String(sTriTemp);
  70. return sTriTempClr;
  71. }
  72. void CTriTempFileClr::SetName(String^ a_strName)
  73. {
  74. if (m_LpTempFile == nullptr)
  75. {
  76. LogErrorTrace(__FILE__, __LINE__, _T("SetName: current CLR point is invalid."));
  77. return;
  78. }
  79. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  80. ASSERT(a_strName);
  81. if (!pTriTempFile)
  82. {
  83. LogErrorTrace(__FILE__, __LINE__, _T("SetName:invalid pointer."));
  84. return;
  85. }
  86. ASSERT(a_strName);
  87. if (!a_strName)
  88. {
  89. LogErrorTrace(__FILE__, __LINE__, _T("SetName:invalid pointer."));
  90. return;
  91. }
  92. pTriTempFile->SetName(a_strName);
  93. }
  94. // version
  95. String^ CTriTempFileClr::GetVersion()
  96. {
  97. if (m_LpTempFile == nullptr)
  98. {
  99. LogErrorTrace(__FILE__, __LINE__, _T("GetVersion: current CLR point is invalid."));
  100. return nullptr;
  101. }
  102. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  103. ASSERT(pTriTempFile);
  104. if (!pTriTempFile)
  105. {
  106. LogErrorTrace(__FILE__, __LINE__, _T("GetVersion:invalid pointer."));
  107. return nullptr;
  108. }
  109. CString sVersion = pTriTempFile->GetVersion();
  110. String^ sVersionClr = gcnew String(sVersion);
  111. return sVersionClr;
  112. }
  113. void CTriTempFileClr::SetVersion(String^ a_strVersion)
  114. {
  115. if (m_LpTempFile == nullptr)
  116. {
  117. LogErrorTrace(__FILE__, __LINE__, _T("SetVersion: current CLR point is invalid."));
  118. return;
  119. }
  120. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  121. ASSERT(pTriTempFile);
  122. if (!pTriTempFile)
  123. {
  124. LogErrorTrace(__FILE__, __LINE__, _T("SetVersion:invalid pointer."));
  125. return;
  126. }
  127. ASSERT(a_strVersion);
  128. if (!a_strVersion)
  129. {
  130. LogErrorTrace(__FILE__, __LINE__, _T("SetVersion:invalid pointer."));
  131. return;
  132. }
  133. pTriTempFile->SetVersion(a_strVersion);
  134. }
  135. // triangle template list
  136. CTriTempItemListClr^ CTriTempFileClr::GetTriTempItemList()
  137. {
  138. if (m_LpTempFile == nullptr)
  139. {
  140. LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempList:empty pointer."));
  141. return nullptr;
  142. }
  143. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  144. ASSERT(pTriTempFile);
  145. if (!pTriTempFile)
  146. {
  147. LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempList: invalide pointer."));
  148. return nullptr;
  149. }
  150. CTriTempItemList listTriTempItem = pTriTempFile->GetTriTempItemList();
  151. CTriTempItemListClr^ listTriTempItemClr = gcnew CTriTempItemListClr();
  152. for (auto pTriTempItem: listTriTempItem)
  153. {
  154. CTriTempItemClr^ TriTempItemClr = gcnew CTriTempItemClr(pTriTempItem);
  155. listTriTempItemClr->Add(TriTempItemClr);
  156. }
  157. return listTriTempItemClr;
  158. }
  159. void CTriTempFileClr::SetTriTempItemList(CTriTempItemListClr^ a_listTriTemp, bool a_bClear)
  160. {
  161. if (m_LpTempFile == nullptr)
  162. {
  163. LogErrorTrace(__FILE__, __LINE__, _T("SetTriTempList:empty pointer."));
  164. return;
  165. }
  166. CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  167. ASSERT(pTriTempFile);
  168. if (!pTriTempFile)
  169. {
  170. LogErrorTrace(__FILE__, __LINE__, _T("SetTriTempList: invalide pointer."));
  171. return;
  172. }
  173. ASSERT(a_listTriTemp);
  174. if (!a_listTriTemp)
  175. {
  176. LogErrorTrace(__FILE__, __LINE__, _T("SetTriTempList: invalid listTriTemp pointer."));
  177. return;
  178. }
  179. CTriTempItemList listTriTempItem;
  180. int nSize = a_listTriTemp->Count;
  181. for (int i = 0; i < nSize; i++)
  182. {
  183. CTriTempItemPtr pTriTempItem = a_listTriTemp[i]->GetTriTempItemPtr();
  184. ASSERT(pTriTempItem);
  185. if (!pTriTempItem)
  186. {
  187. LogErrorTrace(__FILE__, __LINE__, _T("SetTriTempList: invalid TriTemp pointer."));
  188. return;
  189. }
  190. listTriTempItem.push_back(pTriTempItem);
  191. }
  192. pTriTempFile->SetTriTempItemList(listTriTempItem, a_bClear);
  193. }
  194. //CTriTempItemClr^ CTriTempFileClr::GetTriTempByIndex(int a_nIndex)
  195. //{
  196. // if (m_LpTempFile == nullptr)
  197. // {
  198. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByIndex:empty pointer."));
  199. // return nullptr;
  200. // }
  201. //
  202. // CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  203. //
  204. // ASSERT(pTriTempFile);
  205. // if (!pTriTempFile)
  206. // {
  207. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByIndex: invalide pointer."));
  208. // return nullptr;
  209. // }
  210. //
  211. // CTriTempItemPtr pTriTempItem = pTriTempFile->GetTriTempByIndex(a_nIndex);
  212. // ASSERT(pTriTempItem);
  213. // if (!pTriTempItem)
  214. // {
  215. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByIndex: invalide triangle template item pointer."));
  216. // return nullptr;
  217. // }
  218. // CTriTempItemClr^ pTriTemItemClr = gcnew CTriTempItemClr(pTriTempItem);
  219. // return pTriTemItemClr;
  220. //}
  221. //CTriTempItemClr^ CTriTempFileClr::GetTriTempByName(String^ a_strPartSizeName)
  222. //{
  223. // if (m_LpTempFile == nullptr)
  224. // {
  225. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByName:empty pointer."));
  226. // return nullptr;
  227. // }
  228. // ASSERT(a_strPartSizeName);
  229. // if (!a_strPartSizeName)
  230. // {
  231. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByName:empty pointer."));
  232. // return nullptr;
  233. // }
  234. // CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  235. // ASSERT(pTriTempFile);
  236. // if (!pTriTempFile)
  237. // {
  238. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByName: invalide pointer."));
  239. // return nullptr;
  240. // }
  241. // CTriTempItemPtr pTriTempItem = pTriTempFile->GetTriTempByName(a_strPartSizeName);
  242. // ASSERT(pTriTempItem);
  243. // if (!pTriTempItem)
  244. // {
  245. // LogErrorTrace(__FILE__, __LINE__, _T("GetTriTempByName: invalide triangle template item pointer."));
  246. // return nullptr;
  247. // }
  248. // CTriTempItemClr^ pTriTemItemClr = gcnew CTriTempItemClr(pTriTempItem);
  249. // return pTriTemItemClr;
  250. //}
  251. //CPartSTDDataClr^ CTriTempFileClr::GetPartSTDData()
  252. //{
  253. // if (m_LpTempFile == nullptr)
  254. // {
  255. // LogErrorTrace(__FILE__, __LINE__, _T("GetPartSTDData:empty pointer."));
  256. // return nullptr;
  257. // }
  258. // CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  259. // ASSERT(pTriTempFile);
  260. // if (!pTriTempFile)
  261. // {
  262. // LogErrorTrace(__FILE__, __LINE__, _T("GetPartSTDData: invalide pointer."));
  263. // return nullptr;
  264. // }
  265. // CPartSTDDataPtr pPartSTD = pTriTempFile->GetPartSTDData();
  266. // CPartSTDDataClr^ pPartSTDClr = gcnew CPartSTDDataClr(pPartSTD);
  267. // return pPartSTDClr;
  268. //
  269. //}
  270. //// part STD data
  271. //void CTriTempFileClr::SetPartSTDData(CPartSTDDataClr^ a_pPartSTDData)
  272. //{
  273. // if (m_LpTempFile == nullptr)
  274. // {
  275. // LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData:empty pointer."));
  276. // return;
  277. // }
  278. // CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  279. // ASSERT(pTriTempFile);
  280. // if (!pTriTempFile)
  281. // {
  282. // LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalide pointer."));
  283. // return;
  284. // }
  285. // ASSERT(a_pPartSTDData);
  286. // if (!a_pPartSTDData)
  287. // {
  288. // LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid PartSTDData pointer."));
  289. // return;
  290. // }
  291. //
  292. // CPartSTDDataPtr pPartSTDData = a_pPartSTDData->GetPartSTDDataPtr();
  293. // ASSERT(pPartSTDData);
  294. // if (!pPartSTDData)
  295. // {
  296. // LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid PartSTDData pointer."));
  297. // return;
  298. // }
  299. // pTriTempFile->SetPartSTDData(pPartSTDData);
  300. //}
  301. //bool CTriTempFileClr::GetPartNameList(List<String^>^% a_listPartName)
  302. //{
  303. // if (m_LpTempFile == nullptr)
  304. // {
  305. // LogErrorTrace(__FILE__, __LINE__, _T("GetPartNameList:empty pointer."));
  306. // return false;
  307. // }
  308. // CTriTempFilePtr pTriTempFile = GetTriTempFilePtr();
  309. // ASSERT(pTriTempFile);
  310. // if (!pTriTempFile)
  311. // {
  312. // LogErrorTrace(__FILE__, __LINE__, _T("GetPartNameList: invalide pointer."));
  313. // return false;
  314. // }
  315. // std::vector<CString> listPartName;
  316. // BOOL bRet = pTriTempFile->GetPartNameList(listPartName);
  317. // if (!bRet)
  318. // {
  319. // LogErrorTrace(__FILE__, __LINE__, _T("GetPartNameList: failed to get part name list."));
  320. // return false;
  321. // }
  322. // for (auto strPartName : listPartName)
  323. // {
  324. // String^ strPartNameClr = gcnew String(strPartName);
  325. // a_listPartName->Add(strPartNameClr);
  326. // }
  327. // return true;
  328. //}
  329. }