// Implementation for the definition of 'enum' type lists in the editor ////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "Others\CTL_EnLi.hpp" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //************************************************************************ CTL_Editor_EnumElement::CTL_Editor_EnumElement(CString _csElementName, long _lEnumValue, CString _csAdditionalString, void *_p_vAdditionnalPointer) { m_pri_csElementName = _csElementName; m_pri_lEnumValue = _lEnumValue; m_pri_csAdditionalString = _csAdditionalString; m_pri_p_vAdditionnalPointer = _p_vAdditionnalPointer; } //************************************************************************ CTL_Editor_EnumElement::~CTL_Editor_EnumElement() { } //Value //************************************************************************ void CTL_Editor_EnumElement::m_pub_fn_vSetValue(long lNewValue) { m_pri_lEnumValue = lNewValue; } //************************************************************************ long CTL_Editor_EnumElement::m_pub_fn_lGetValue() { return m_pri_lEnumValue; } //Element Name //************************************************************************ void CTL_Editor_EnumElement::m_pub_fn_vSetElementName(CString _csNewString) { m_pri_csElementName = _csNewString; } //************************************************************************ CString CTL_Editor_EnumElement::m_pub_fn_csGetElementName() { return m_pri_csElementName; } //Additional String //************************************************************************ void CTL_Editor_EnumElement::m_pub_fn_vSetAdditionalString(CString _csNewString) { m_pri_csAdditionalString = _csNewString; } //************************************************************************ CString CTL_Editor_EnumElement::m_pub_fn_csGetAdditionalString() { return m_pri_csAdditionalString; } //Additionnal Pointer //************************************************************************ void CTL_Editor_EnumElement::m_pub_fn_vSetAdditionnalPointer(void *_p_vAdditionnalPointer) { m_pri_p_vAdditionnalPointer = _p_vAdditionnalPointer; } //************************************************************************ void *CTL_Editor_EnumElement::m_pub_fn_pvGetAdditionnalPointer() { return m_pri_p_vAdditionnalPointer; } //************************************************************************ //************************************************************************ //************************************************************************ CTL_Editor_EnumDescriptor::CTL_Editor_EnumDescriptor(CString csEnumName, unsigned char ucSize) { m_csEnumName = csEnumName; m_ucEnumSize = ucSize; } //************************************************************************ CTL_Editor_EnumDescriptor::~CTL_Editor_EnumDescriptor() { m_fn_vEmptyList(); } //************************************************************************ void CTL_Editor_EnumDescriptor::m_fn_vEmptyList() { POSITION pos = GetHeadPosition(); while ( pos != NULL ) delete GetNext(pos); RemoveAll(); } //************************************************************************ CTL_Editor_EnumElement *CTL_Editor_EnumDescriptor::m_fn_pclAddElement(CString _csElementName, long _lEnumValue /*= LIST_ENUM_ERROR*/, CString _csAdditionalString /*= ""*/, void *_p_vAdditionnalPointer /*= NULL*/) { //Adds only if name is not found in list if ( m_fn_pclGetElementFromString(_csElementName) == NULL ) { CTL_Editor_EnumElement *pclNewElement = new CTL_Editor_EnumElement(_csElementName, _lEnumValue, _csAdditionalString, _p_vAdditionnalPointer); AddTail(pclNewElement); return pclNewElement; } else return NULL; } //************************************************************************ CString CTL_Editor_EnumDescriptor::m_fn_csGetStringFromEnumIndex(long lEnumIndex) { CTL_Editor_EnumElement *pclCurrentElement; BOOL bFound = FALSE; POSITION pos = GetHeadPosition(); while ( (pos != NULL) && !bFound ) { pclCurrentElement = GetNext(pos); bFound = ( pclCurrentElement->m_pub_fn_lGetValue() == lEnumIndex ); } if ( bFound ) return (pclCurrentElement->m_pub_fn_csGetElementName()); else return "*** E R R O R ***"; } //************************************************************************ CTL_Editor_EnumElement *CTL_Editor_EnumDescriptor::m_fn_pclGetElementFromEnumIndex(long lEnumIndex) { CTL_Editor_EnumElement *pclCurrentElement; BOOL bFound = FALSE; POSITION pos = GetHeadPosition(); while ( (pos != NULL) && !bFound ) { pclCurrentElement = GetNext(pos); bFound = ( pclCurrentElement->m_pub_fn_lGetValue() == lEnumIndex ); } if ( bFound ) return pclCurrentElement; else return NULL; } //************************************************************************ CTL_Editor_EnumElement *CTL_Editor_EnumDescriptor::m_fn_pclGetElementFromString(CString _csStringToFind) { CTL_Editor_EnumElement *pclCurrentElement; BOOL bFound = FALSE; POSITION pos = GetHeadPosition(); while ( (pos != NULL) && !bFound ) { pclCurrentElement = GetNext(pos); bFound = ( pclCurrentElement->m_pub_fn_csGetElementName().Compare(_csStringToFind) == 0 ); } if ( bFound ) return pclCurrentElement; else return NULL; } //************************************************************************ unsigned char CTL_Editor_EnumDescriptor::m_fn_ucGetEnumSize() { return m_ucEnumSize; } //************************************************************************ //************************************************************************ //************************************************************************ CTL_Editor_EnumDescriptorList::CTL_Editor_EnumDescriptorList() { } //************************************************************************ CTL_Editor_EnumDescriptorList::~CTL_Editor_EnumDescriptorList() { } //************************************************************************ CTL_Editor_EnumDescriptor *CTL_Editor_EnumDescriptorList::m_fn_pclGetEnumDescriptorByName(CString csDescriptorName) { CTL_Editor_EnumDescriptor *pclCurrent; BOOL bFound = FALSE; POSITION pos = GetHeadPosition(); while ( (pos != NULL) && !bFound ) { pclCurrent = GetNext(pos); bFound = ( pclCurrent->m_csEnumName == csDescriptorName ); } if ( bFound ) return pclCurrent; else return NULL; }