/* @(#)Z 1.4 com/src/registry/RManager.cpp, odconfig, od96nt, odnt9712d 97/03/21 17:16:14 (96/10/29 09:29:28) */
//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odconfig
//
//   CLASSES: none
//
//   ORIGINS: 27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//

/********************************************************************/
/*  Licensed Materials - Property of IBM                            */
/*                                                                  */
/*                                                                  */
/* Copyright (C) International Business Machines Corp., 1994.       */
/* Copyright (C) Apple Computer, Inc., 1994                         */
/*                                                                  */
/*  US Government Users Restricted Rights -                         */
/*  Use, duplication, or disclosure restricted                      */
/*  by GSA ADP Schedule Contract with IBM Corp.                     */
/*                                                                  */
/*  IBM Change History (most recent first):                         */
/*  <OS2>  11/13/95 aht  143334 Implement GetCompMgr method         */
/*  <OS2>  11/01/95 jso  142527 Added Refresh method                */
/*  <OS2>   6/28/95 jso  123479 Added check for Initialization      */
/*  <WIN>   4/05/96 vsm  port   Removed Component manager reference */
/*                                                                  */
/*                                                                  */
/********************************************************************/
/*
 *  This file was generated by the SOM Compiler.
 *  Generated using:
 *     SOM incremental update: somc/smmain.c
 */

/*
 *  This file was generated by the SOM Compiler and Emitter Framework.
 *  Generated using:
 *      SOM Emitter emitxtm: somc/smmain.c
 */

#define RegistryManager_Class_Source

#if WANT_DSOM
#include <somd.xh>
#endif

#ifdef _PLATFORM_OS2_
#include <ODPagtun.h>
#endif

#ifndef _ODEXCEPT_
#include "ODExcept.h"
#endif

#include <ODTypes.h>
#include <RManager.xih>
#include <ODPrtRei.xh>
//#include <comp.xh>
//#include <compmgr.xh>

/*********************************************************************/
/* Global Variable used in somInit                                   */
/*********************************************************************/

static ODBoolean initialized = kODFalse;


SOM_Scope ODPartHandlerRegistry*  SOMLINK RegistryManagerGetODPartHandlerRegistry(RegistryManager *somSelf,
                                                                    Environment *ev)
{
    RegistryManagerData *somThis = RegistryManagerGetData(somSelf);
    RegistryManagerMethodDebug("RegistryManager","GetODPartHandlerRegistry");

  try {
    if ( !somThis-> partHandlerRegistry )
    {

        #if WANT_DSOM
        ODPartHandlerRegistryIntNewClass( 0, 0);
        somThis-> partHandlerRegistry = (ODPartHandlerRegistryInt*)
                                        SOMD_ObjectMgr-> somdNewObject( ev,
                                                         "ODPartHandlerRegistryInt", "");
        #else
            somThis-> partHandlerRegistry = new ODPartHandlerRegistryInt;
        #endif
        somThis-> partHandlerRegistry-> InitODPartHandlerRegistryIntWithStorage( ev);
    }
  } // try
  catch (ODException _exception  ) {
     SetErrorCode(kODNoError);
  } /* end catch */

    return somThis-> partHandlerRegistry;
}


/*****************************************************/
/*  Component manager is not supported at this time  */
/*****************************************************/
//
//SOM_Scope ComponentManager*  SOMLINK RegistryManagerGetComponentManager(RegistryManager *somSelf,
//                                                          Environment *ev)
//{
//    /* RegistryManagerData *somThis = RegistryManagerGetData(somSelf); */
//    RegistryManagerMethodDebug("RegistryManager","GetComponentManager");
//
//    return (new ComponentManager);
//}
//

SOM_Scope void  SOMLINK RegistryManagersomInit(RegistryManager *somSelf)
{
    RegistryManagerData *somThis = RegistryManagerGetData(somSelf);
    RegistryManagerMethodDebug("RegistryManager","somInit");

    #if WANT_DSOM
    SOMD_Init( somGetGlobalEnvironment());
    #endif

    if(initialized == kODFalse) /* [123479] */
    {
      somThis-> partHandlerRegistry = 0;
      initialized = kODTrue;
    }


    parent_somInit( somSelf);
}

SOM_Scope void  SOMLINK RegistryManagersomUninit(RegistryManager *somSelf)
{
    RegistryManagerData *somThis = RegistryManagerGetData(somSelf);
    RegistryManagerMethodDebug("RegistryManager","somUninit");

  try {
    if ( somThis-> partHandlerRegistry)
    {
        #if WANT_DSOM
        SOMD_ObjectMgr-> somdDestroyObject( somGetGlobalEnvironment(), somThis-> partHandlerRegistry);
        #else
        delete somThis-> partHandlerRegistry;
        somThis-> partHandlerRegistry = 0;  // 142527
        initialized = kODFalse;
        #endif
    }

    #if WANT_DSOM
    SOMD_Uninit( somGetGlobalEnvironment());
    #endif
  } // try
  catch (ODException _exception  ) {
     SetErrorCode(kODNoError);
  } /* end catch */

}

SOM_Scope ODPartHandlerRegistry*  SOMLINK RegistryManagerRefreshODPartHandlerRegistry(RegistryManager *somSelf,
                                                                    Environment *ev)
{
    RegistryManagerData *somThis = RegistryManagerGetData(somSelf);
    RegistryManagerMethodDebug("RegistryManager","RefreshODPartHandlerRegistry");

    // 142527 - Added this method
  try {
    if ( somThis-> partHandlerRegistry )
    {

        #if WANT_DSOM
        ODPartHandlerRegistryIntNewClass( 0, 0);
        somThis-> partHandlerRegistry = (ODPartHandlerRegistryInt*)
                                        SOMD_ObjectMgr-> somdNewObject( ev,
                                                         "ODPartHandlerRegistryInt", "");
        #else
        SOMClass * ODClass =
          ODPartHandlerRegistryIntNewClass( ODPartHandlerRegistryInt_MajorVersion,
                                            ODPartHandlerRegistryInt_MinorVersion);

        somThis-> partHandlerRegistry->somUninit();
        somThis-> partHandlerRegistry = (ODPartHandlerRegistryInt *)
                                        ODClass->somRenew(somThis-> partHandlerRegistry);
        #endif
        somThis-> partHandlerRegistry-> InitODPartHandlerRegistryIntWithStorage( ev);
    }
  } // try
  catch (ODException _exception  ) {
     SetErrorCode(kODNoError);
  } /* end catch */

    return somThis-> partHandlerRegistry;
}
