InteractiveInterfaces CATIniCleanerSettingCtrl

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 ;

}
 
See also:


Constructor and Destructor Index


o CATIniCleanerSettingCtrl()
Constructs an instance
o ~CATIniCleanerSettingCtrl()

Method Index


o GetController()
Retrieves the setting controller.
o SetController(CATBaseUnknown*)
Sets the setting controller.

Constructor and Destructor


o CATIniCleanerSettingCtrl
public CATIniCleanerSettingCtrl()
Constructs an instance
o ~CATIniCleanerSettingCtrl
public virtual ~CATIniCleanerSettingCtrl()

Methods


o GetController
public GetController()
Retrieves the setting controller.
o SetController
public SetController( iController)
Sets the setting controller.
Role: The last controller is released if it exists, and in all cases, the instance keeps a pointer on the setting controller. This pointer is released in the destructor of this class.

This object is included in the file: CATIniCleanerSettingCtrl.h
If needed, your Imakefile.mk should include the module: CATInteractiveInterfaces

Copyright © 1999-2014, Dassault Systèmes. All rights reserved.