OTSFeatureClr.cpp 1.8 KB

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