OTSFeatureClr.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include "stdafx.h"
  2. #include "OTSFeatureClr.h"
  3. #include "../OTSLog/COTSUtilityDllFunExport.h"
  4. namespace OTSCLRINTERFACE {
  5. COTSFeatureClr::COTSFeatureClr()
  6. {
  7. mFeature =new COTSFeaturePtr( new COTSFeature());
  8. }
  9. COTSFeatureClr::COTSFeatureClr(COTSFeatureClr^ pOTSFeature)
  10. {
  11. auto src = pOTSFeature->GetOTSFeaturePtr();
  12. mFeature = new COTSFeaturePtr(src.get());
  13. }
  14. COTSFeatureClr::COTSFeatureClr(COTSFeaturePtr pOTSFeature) // copy constructor
  15. {
  16. mFeature = new COTSFeaturePtr(pOTSFeature);
  17. }
  18. COTSFeatureClr::!COTSFeatureClr()
  19. {
  20. if (mFeature != nullptr)
  21. {
  22. delete mFeature;
  23. mFeature = NULL;
  24. }
  25. }
  26. COTSFeatureClr::~COTSFeatureClr()
  27. {
  28. if (mFeature != nullptr)
  29. {
  30. delete mFeature;
  31. mFeature = NULL;
  32. }
  33. }
  34. COTSFeaturePtr COTSFeatureClr::GetOTSFeaturePtr()
  35. {
  36. return *mFeature;
  37. }
  38. COTSSegmentListClr ^ COTSFeatureClr::GetSegmentsList()
  39. {
  40. auto fs = mFeature->get()->GetSegmentsList();
  41. COTSSegmentListClr ^ segList = gcnew COTSSegmentListClr();
  42. for each (auto s in fs)
  43. {
  44. segList->Add(gcnew COTSSegmentClr(s));
  45. }
  46. return segList;
  47. }
  48. void COTSFeatureClr::SetSegmentsList(COTSSegmentListClr^ a_plistSegment, bool a_bClear)
  49. {
  50. if (a_plistSegment == nullptr)
  51. {
  52. LogErrorTrace(__FILE__, __LINE__, _T("SetSegmentsList::set invalid pointer."));
  53. return;
  54. }
  55. COTSSegmentsList flist;
  56. for(auto s = a_plistSegment->GetEnumerator();s.MoveNext ();)
  57. {
  58. flist.push_back(s.Current ->GetOTSSegmentPtr());
  59. }
  60. mFeature->get()->SetSegmentsList(flist, a_bClear);
  61. }
  62. COTSSegmentClr^ COTSFeatureClr::GetSegmentByIndex(int a_nIndex)
  63. {
  64. COTSFeaturePtr pFeature = GetOTSFeaturePtr();
  65. ASSERT(pFeature);
  66. if (pFeature)
  67. {
  68. LogErrorTrace(__FILE__, __LINE__, _T("GetSegmentByIndex: can't get feature pointer."));
  69. return nullptr;
  70. }
  71. COTSSegmentPtr pSegment = pFeature->GetSegmentByIndex(a_nIndex);
  72. COTSSegmentClr^ pSegmentClr = gcnew COTSSegmentClr(pSegment);
  73. return pSegmentClr;
  74. }
  75. }