#include "stdafx.h" #include "ElementChemistryClr.h" namespace OTSCLRINTERFACE { CElementChemistryClr::CElementChemistryClr() { m_LpElementChemistry = new CElementChemistryPtr(new CElementChemistry()); } CElementChemistryClr::CElementChemistryClr(System::String^ a_strName, double a_dPercentage) { ASSERT(a_strName); /*if (!a_strName) { ////LogErrorTrace(__FILE__, __LINE__, _T("CElementChemistryClr: Generate CElementChemistryClr pointer failed.")); return; }*/ m_LpElementChemistry = new CElementChemistryPtr(new CElementChemistry(a_strName, a_dPercentage)); } CElementChemistryClr::CElementChemistryClr(CElementChemistryPtr a_pElementChemistry) { ASSERT(a_pElementChemistry); m_LpElementChemistry = new CElementChemistryPtr(a_pElementChemistry); } CElementChemistryClr::CElementChemistryClr(CElementChemistryClr^ a_pSource) { auto src = a_pSource->GetElementChemistryPtr(); m_LpElementChemistry = new CElementChemistryPtr(new CElementChemistry(src.get())); } CElementChemistryClr::CElementChemistryClr(CElementChemistry* a_pSource) { ASSERT(a_pSource); m_LpElementChemistry = new CElementChemistryPtr(new CElementChemistry(a_pSource)); } CElementChemistryClr::~CElementChemistryClr() { if (m_LpElementChemistry != nullptr) { delete m_LpElementChemistry; m_LpElementChemistry = nullptr; } } CElementChemistryClr::!CElementChemistryClr() { if (m_LpElementChemistry != nullptr) { delete m_LpElementChemistry; m_LpElementChemistry = nullptr; } } OTSDATA::CElementChemistryPtr CElementChemistryClr::GetElementChemistryPtr() { return *m_LpElementChemistry; } String^ CElementChemistryClr::GetName() { String^ NameClr; if (m_LpElementChemistry != nullptr) { CString sName = m_LpElementChemistry->get()->GetName(); NameClr = gcnew String(sName); } return NameClr; } void CElementChemistryClr::SetName(String^ strName) { ASSERT(strName); if (m_LpElementChemistry != nullptr) { m_LpElementChemistry->get()->SetName(strName); } } double CElementChemistryClr::GetPercentage() { double nPercentage = -1; if (m_LpElementChemistry != nullptr) { nPercentage = m_LpElementChemistry->get()->GetPercentage(); } return nPercentage; } void CElementChemistryClr::SetPercentage(double a_dPercentage) { if (m_LpElementChemistry != nullptr) { m_LpElementChemistry->get()->SetPercentage( a_dPercentage); } } double CElementChemistryClr::GetMolarPercentage() { if (m_LpElementChemistry != nullptr) { return m_LpElementChemistry->get()->GetMolarPercentage(); } } int CElementChemistryClr::GetAtomNum(String^ a_strElementName) { if (m_LpElementChemistry != nullptr) { return CElement::GetAtomicNum(a_strElementName); } } }