#include "stdafx.h" #include "ElementChemistryClr.h" namespace OTSINTERFACE { CElementChemistryClr::CElementChemistryClr() { m_LpElementChemistry = new CElementChemistryPtr(new CElementChemistry()); } CElementChemistryClr::CElementChemistryClr(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); if (!a_pElementChemistry) { LogErrorTrace(__FILE__, __LINE__, _T("CElementChemistryClr: Generate CElementChemistryClr pointer failed.")); return; } m_LpElementChemistry = new CElementChemistryPtr(a_pElementChemistry); } CElementChemistryClr::CElementChemistryClr(CElementChemistry* a_pSource) { ASSERT(a_pSource); if (!a_pSource) { LogErrorTrace(__FILE__, __LINE__, _T("CElementChemistryClr: Generate CElementChemistryClr pointer failed.")); return; } 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; } } 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 (!strName) { LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version.")); } 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::GetMolar() { if (m_LpElementChemistry != nullptr) { return m_LpElementChemistry->get()->GetMolarPercentage(); } else { return 0.0; } } int CElementChemistryClr::GetAtomNum(String^ a_strElementName) { if (m_LpElementChemistry != nullptr) { return CElement::GetAtomicNum(a_strElementName); } else { return 0; } } }