250 lines
8.3 KiB
C++
250 lines
8.3 KiB
C++
/*=========================================================================
|
|
*
|
|
* CPASectO.hpp - CPA_SectionObject : implementation
|
|
*
|
|
*
|
|
* Version 1.0
|
|
* Creation date 20.06.97
|
|
* Revision date
|
|
*
|
|
* Shaitan
|
|
*=======================================================================*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#ifdef ACTIVE_EDITOR
|
|
|
|
#include "itf/CPASectO.hpp"
|
|
|
|
//#################################################################################
|
|
// INIT
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
Constructor
|
|
=========================================================================*/
|
|
CPA_SectionObject::CPA_SectionObject (const CString csReferencedSectionName, char *p_szDataPath,
|
|
SCR_tdpfn_Ntfy_Callback pCallBack,
|
|
void *pSectionData, BOOL bExistingSection)
|
|
{
|
|
// init parameters
|
|
m_csReferencedSectionName = csReferencedSectionName;
|
|
m_csInitialReferencedSectionName.Empty();
|
|
m_p_szDataPath = p_szDataPath;
|
|
// parameters for save
|
|
m_p_fnCallBackSave = pCallBack;
|
|
m_bExistingSection = bExistingSection;
|
|
m_pSectionData = pSectionData;
|
|
|
|
// init notifications
|
|
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
|
|
}
|
|
|
|
/*===========================================================================
|
|
Copy-Constructor
|
|
=========================================================================*/
|
|
CPA_SectionObject::CPA_SectionObject (CPA_SectionObject &r_oSource)
|
|
{
|
|
// init parameters
|
|
m_csReferencedSectionName = r_oSource.GetReferencedSectionName();
|
|
m_csInitialReferencedSectionName.Empty();
|
|
m_p_szDataPath = r_oSource.m_p_szDataPath;
|
|
// parameters for save
|
|
m_p_fnCallBackSave = r_oSource.m_p_fnCallBackSave;
|
|
m_pSectionData = r_oSource.m_pSectionData;
|
|
m_bExistingSection = FALSE;
|
|
|
|
// init notifications
|
|
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
|
|
}
|
|
|
|
/*===========================================================================
|
|
Destructor
|
|
=========================================================================*/
|
|
CPA_SectionObject::~CPA_SectionObject (void)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// REFERENCES
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: return referenced (minimum) name of the section
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CString CPA_SectionObject::GetReferencedSectionName (void)
|
|
{
|
|
return m_csReferencedSectionName;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: return complete name of the section
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CString CPA_SectionObject::GetCompleteSectionName (void)
|
|
{
|
|
CString csCompleteName;
|
|
|
|
// complete name : data path + short name
|
|
csCompleteName = m_p_szDataPath;
|
|
csCompleteName += "\\" + m_csReferencedSectionName;
|
|
|
|
return csCompleteName;
|
|
}
|
|
|
|
//#################################################################################
|
|
// NOTIFICATIONS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: notify section for Add or Rebuild, according to flag
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SectionObject::fn_vWriteSection(void)
|
|
{
|
|
fn_vNotifySection( m_bExistingSection ? SCR_EA_Ntfy_RebuildSection : SCR_EA_Ntfy_AddSection );
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: notify section for Delete, and save current notification
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SectionObject::fn_vDeleteSection (void)
|
|
{
|
|
if( m_bExistingSection || (m_eCurrentNotify != SCR_EA_Ntfy_Dummy) )
|
|
{
|
|
// save current notification
|
|
m_eLastNotify = m_eCurrentNotify;
|
|
|
|
// add delete notification
|
|
fn_vNotifySection( SCR_EA_Ntfy_DeleteSection ) ;
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: cancel Delete notification and restore previous one
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SectionObject::fn_vRestoreSection (void)
|
|
{
|
|
// remove current script notification
|
|
if ( m_eCurrentNotify == SCR_EA_Ntfy_DeleteSection )
|
|
SCR_fn_v_SvL1_DeleteRegisterNotify((char*) (LPCTSTR)GetCompleteSectionName(), SCR_CDR_c_RdL0_Match);
|
|
|
|
// restore previous notification
|
|
if( m_eLastNotify != SCR_EA_Ntfy_Dummy )
|
|
{
|
|
fn_vNotifySection( m_eLastNotify );
|
|
m_eLastNotify = SCR_EA_Ntfy_Dummy;
|
|
}
|
|
else
|
|
m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: rename section => Delete previous and Add new one
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SectionObject::fn_vRenameSection (const CString csNewReferencedSectionName)
|
|
{
|
|
// delete previous section
|
|
fn_vDeleteSection();
|
|
|
|
// back to initial name ?
|
|
if (csNewReferencedSectionName == m_csInitialReferencedSectionName)
|
|
{
|
|
// initial name => section exists !
|
|
m_bExistingSection = TRUE;
|
|
// rename section
|
|
m_csReferencedSectionName = csNewReferencedSectionName;
|
|
// notify for Rebuild
|
|
m_eLastNotify = SCR_EA_Ntfy_RebuildSection;
|
|
fn_vRestoreSection();
|
|
}
|
|
// new name
|
|
else
|
|
{
|
|
// first rename of existing section
|
|
if (m_bExistingSection)
|
|
{
|
|
// save initial name
|
|
m_csInitialReferencedSectionName = m_csReferencedSectionName;
|
|
// update flag
|
|
m_bExistingSection = FALSE;
|
|
}
|
|
|
|
// rename and save new section
|
|
m_csReferencedSectionName = csNewReferencedSectionName;
|
|
fn_vWriteSection();
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: notify section without any test
|
|
* Creation date: 20.06.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SectionObject::fn_vNotifySection(SCR_tde_Ntfy_Action eAction)
|
|
{
|
|
if (m_eCurrentNotify != eAction)
|
|
{
|
|
// update current notification
|
|
m_eCurrentNotify = eAction;
|
|
|
|
// register notification
|
|
SCR_fn_v_SvL1_RegisterNotify((char*) (LPCTSTR) GetCompleteSectionName(),
|
|
m_p_fnCallBackSave, m_pSectionData, eAction);
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: reinit parameters when section was written or deleted
|
|
* Creation date: 03.07.97
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SectionObject::fn_vSectionSaved (void)
|
|
{
|
|
// section exists
|
|
SetExistingSection(TRUE);
|
|
// no more notifications
|
|
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
|
|
}
|
|
//===========================================================================
|
|
|
|
void CPA_SectionObject::fn_vSectionDeleted (void)
|
|
{
|
|
// section doesn't exist
|
|
SetExistingSection(FALSE);
|
|
// no more notifications
|
|
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
|
|
}
|
|
|
|
#endif ACTIVE_EDITOR
|
|
|