CPI_Indicators.c
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:4k
- ////////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "globals.h"
- #include "CPI_InterfacePart.h"
- ////////////////////////////////////////////////////////////////////////////////
- //
- typedef struct _CPs_IndicatorValue
- {
- char* m_pcName;
- char* m_pcValue;
- void* m_pNext;
- } CPs_IndicatorValue;
- //
- //
- typedef struct _CPs_IndicatorBinding
- {
- char* m_pcName;
- CP_HINTERFACEPART m_hPart;
- void* m_pNext;
- } CPs_IndicatorBinding;
- //
- ////////////////////////////////////////////////////////////////////////////////
- CPs_IndicatorValue* glb_pIndicatorValue = NULL;
- CPs_IndicatorBinding* glb_pIndicatorBinding = NULL;
- ////////////////////////////////////////////////////////////////////////////////
- //
- //
- //
- void CPIC_FreeIndicators()
- {
- CPs_IndicatorValue* pValueCursor;
- CPs_IndicatorValue* pValueCursor_next;
- for(pValueCursor = glb_pIndicatorValue; pValueCursor; pValueCursor = pValueCursor_next)
- {
- pValueCursor_next = (CPs_IndicatorValue*)pValueCursor->m_pNext;
- free(pValueCursor->m_pcName);
- free(pValueCursor->m_pcValue);
- free(pValueCursor);
- }
- }
- //
- //
- //
- CPs_IndicatorValue* CPIC_LookupIndicator_Value(const char* pcName)
- {
- CPs_IndicatorValue* pValueCursor;
- for(pValueCursor = glb_pIndicatorValue; pValueCursor; pValueCursor = (CPs_IndicatorValue*)pValueCursor->m_pNext)
- {
- if(stricmp(pValueCursor->m_pcName, pcName) == 0)
- return pValueCursor;
- }
- return NULL;
- }
- //
- //
- //
- void CPIC_SetIndicatorValue(const char* pcName, const char* pcValue)
- {
- CPs_IndicatorValue* pIndicatorValue;
- pIndicatorValue = CPIC_LookupIndicator_Value(pcName);
- // No value found - create one
- if(!pIndicatorValue)
- {
- pIndicatorValue = (CPs_IndicatorValue*)malloc(sizeof(CPs_IndicatorValue));
- STR_AllocSetString(&pIndicatorValue->m_pcName, pcName, FALSE);
- pIndicatorValue->m_pcValue = NULL;
- // Link in
- pIndicatorValue->m_pNext = glb_pIndicatorValue;
- glb_pIndicatorValue = pIndicatorValue;
- }
- // Set value
- STR_AllocSetString(&pIndicatorValue->m_pcValue, pcValue, TRUE);
- // Invalidate any bound controls
- {
- CPs_IndicatorBinding* pBindingCursor;
- for(pBindingCursor = glb_pIndicatorBinding; pBindingCursor; pBindingCursor = (CPs_IndicatorBinding*)pBindingCursor->m_pNext)
- {
- if(stricmp(pBindingCursor->m_pcName, pcName) == 0)
- IP_Invalidate(pBindingCursor->m_hPart);
- }
- }
- }
- //
- //
- //
- const char* CPIC_GetIndicatorValue(const char* pcName)
- {
- CPs_IndicatorValue* pIndicatorValue;
- pIndicatorValue = CPIC_LookupIndicator_Value(pcName);
- if(pIndicatorValue)
- return pIndicatorValue->m_pcValue;
- return NULL;
- }
- //
- //
- //
- void CPIC_BindIndicatorToControl(const char* pcName, CP_HINTERFACEPART hPart)
- {
- CPs_IndicatorBinding* pIndicatorBinding;
- pIndicatorBinding = (CPs_IndicatorBinding*)malloc(sizeof(CPs_IndicatorBinding));
- STR_AllocSetString(&pIndicatorBinding->m_pcName, pcName, FALSE);
- pIndicatorBinding->m_hPart = hPart;
- // Link in
- pIndicatorBinding->m_pNext = glb_pIndicatorBinding;
- glb_pIndicatorBinding = pIndicatorBinding;
- }
- //
- //
- //
- void CPIC_UnBindControl(CP_HINTERFACEPART hPart)
- {
- CPs_IndicatorBinding* pBindingCursor;
- CPs_IndicatorBinding** ppBindingCursor_Referrer;
- for(pBindingCursor = glb_pIndicatorBinding, ppBindingCursor_Referrer = &glb_pIndicatorBinding;
- pBindingCursor;
- pBindingCursor = (CPs_IndicatorBinding*)pBindingCursor->m_pNext,
- ppBindingCursor_Referrer = (CPs_IndicatorBinding**)&pBindingCursor->m_pNext)
- {
- if(pBindingCursor->m_hPart == hPart)
- {
- *ppBindingCursor_Referrer = (CPs_IndicatorBinding*)pBindingCursor->m_pNext;
- free(pBindingCursor->m_pcName);
- free(pBindingCursor);
- return;
- }
- }
- }
- //
- //
- //