Usage: you must use this class as is. You should never derive it.
public class CATIniCleanerSettingCtrl
Class to delete a setting controller.
Role:This class must be a static data of your
setting controller implementation.
Sample to create the setting controller implementation:
Header file:
#include "CATBaseUnknown.h" // To derive from
#include "CATIniCleanerSettingCtrl.h"
class MySettingCtrl : public CATBaseUnknown
{
// Used in conjunction with CATImplementClass in the .cpp file
CATDeclareClass;
public:
MySettingCtrl();
virtual ~MySettingCtrl();
// Method called by a global function
// This method creates an unic controler or retrieves it.
//
static HRESULT GetSettingController(MySettingCtrl ** oCtrl);
private:
// Copy constructor, not implemented
// Set as private to prevent from compiler automatic creation as public.
MySettingCtrl(const MySettingCtrl &iObjectToCopy);
private:
static CATIniCleanerSettingCtrl _CleanerCtrl ;
};
Cpp file:
#include "MySettingCtrl.h"
#include "CATErrorDef.h"
//To initialize the static data
CATIniCleanerSettingCtrl MySettingCtrl::_CleanerCtrl ;
//To declare that this class is a component main class
CATImplementClass(MySettingCtrl,
Implementation, CATBaseUnknown , CATNull);
MySettingCtrl::MySettingCtrl()
{
}
MySettingCtrl::~MySettingCtrl()
{
}
HRESULT MySettingCtrl::GetSettingController(
MySettingCtrl ** oCtrl)
{
HRESULT rc = S_OK ;
if ( NULL != oCtrl )
{
CATBaseUnknown * Ctrl = _CleanerCtrl.GetController();
if ( NULL == Ctrl )
{
MySettingCtrl * SettingController = NULL;
SettingController = new MySettingCtrl();
if ( NULL == SettingController )
{
rc = E_OUTOFMEMORY ;
}else
{
// The cleaner keeps the unic instance
// SetController has made an Addref
_CleanerCtrl.SetController(SettingController);
*oCtrl = SettingController ;
}
}else
{
*oCtrl = (MySettingCtrl*) Ctrl ;
}
}else rc = E_FAIL ;
return rc ;
}
| public CATIniCleanerSettingCtrl( | ) |
| public virtual ~CATIniCleanerSettingCtrl( | ) |
| public GetController( | ) |
| public SetController( | iController) |
Copyright © 1999-2014, Dassault Systèmes. All rights reserved.