//
//   COMPONENT_NAME: somd
//
//   ORIGINS: 27
//
//
//    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,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.
//
//#  @(#) 2.31 src/somd/somdserv.idl, somd, som3.0 9/26/96 14:02:21 [12/22/96 21:11:57]

//#  SOMDServer is a PUBLIC class derived from SOMObject.
//
//  Each DSOM server process is defined to have a (single instance)
//  SOMDServer object.  The SOMDServer object performs the following
//  functions:
//
//      1) creation of SOMObject factories
//      2) mapping between SOMObjects and SOMDObjects
//      3) method dispatching
//      4) any application-specific server methods
//
//  A particular SOMDServer subclass is specified in the ImplementationDef
//  for each server process.  SOMOA will instantiate one instance of the
//  specified SOMDServer subclass during server process initialization
//  (in SOMOA::impl_is_ready).


#ifndef somdserver_idl
#define somdserver_idl

#include <somobj.idl>
#include <somdtype.idl>
#include <snglicls.idl>
#include <xnaming.idl>

interface SOMDObject;

interface SOMDServer : SOMObject
{

  //### -- Methods called locally on server ONLY! -- ###//

  SOMDObject somdRefFromSOMObj(in SOMObject somobj);
  
  // This method returns a DSOM object reference for a SOM object in this server
  // process.  SOMOA will call this method whenever it returns a result from a
  // method call which includes a pointer to a SOMObject (versus a pointer to a
  // SOMDObject).  OWNERSHIP of the returned object reference is passed to the
  // caller EXCEPT when the somdObjReferencesCached method returns TRUE.  When the
  // input (somobj) is already an object reference, the default implementation
  // simply returns somobj, rather than creating a new reference.  (Subclasses
  // might override this method to duplicate the input reference, however.)
  // Hence, callers should note when the returned value is the same as
  // the input (somobj) when determining whether or not to free the result.

  SOMObject somdSOMObjFromRef(in SOMDObject objref);
  
  // This method maps a DSOM object reference into a SOM object.
  // This can be done in whatever way is appropriate for the application.
  // This method is called by SOMOA in order to translate any method call
  // parameters which are object references (created from somdRefFromSOMObj
  // above) into SOM objects.

  void somdDispatchMethod(in SOMObject somobj, out somToken retValue,
                          in somId methodId, in va_list ap);
  
  // This method is called by SOMOA to dispatch a method on a SOM object.
  // The intention is to give the Server object an opportunity to intercept
  // method calls, if desired.  The parameters to this method are the same
  // as the parameters passed to SOMObject::somDispatch.
  //
  // The default implementation invokes SOMObject::somDispatch on the
  // specified target object, "somobj", with the supplied arguments.


  //### -- Methods called remotely from clients -- ###//

  SOMObject somdCreateObj(in Identifier objclass, in string hints);
  
  // Creates an object of the specified class.  This method (if overridden)
  // may optionally define creation "hints" which the client may specify in 
  // this call. 
  //
  // Called indirectly by SOMDObjectMgr::somdNewObject.
  //
  // The default implementation calls somdGetClassObj to get the specified
  // SOMClass object, and invokes "somNew".  The "hints" argument is ignored.

  void somdDeleteObj(in SOMObject somobj);
  
  // Deletes a SOM object.  By default, simply calls somFree on the object.
  //
  // Called indirectly by SOMDObjectMgr::somdDestroyObject.

  SOMClass  somdGetClassObj(in Identifier objclass);
  
  // Creates/returns a class object for the specified class.  May result in
  // loading of a DLL for the class.  This method can be used by a client to
  // get a proxy to a class object on the server so that methods introduced
  // in the metaclass (e.g., class-specific constructors, etc.) may be invoked
  // directly.

  boolean   somdObjReferencesCached();

  // Whether the server retains ownership of the object references
  // it creates via the somdRefFromSOMObj method.

  SOMObject somdCreateFactory(in string className,
                           in ExtendedNaming::PropertyList props);
  // To be called from DSOM Factory Finder Service, a FactoryENC object.
  // Will return a factory specified in idl by the idl modifier "factory",
  // or if this doesn't exist will return a SOMClass for the object to be
  // used as the generic factory.  PropertyList is not used.


#ifdef __SOMIDL__

  implementation
  {
    releaseorder: somdSOMObjFromRef, somdRefFromSOMObj,
		  somdCreateObj, somdDeleteObj, somdGetClassObj,
                  somdDispatchMethod, somdObjReferencesCached,
                  private1, private2,
                  somdCreateFactory;
  
    //# class modifiers
    callstyle = idl;
    metaclass = SOMMSingleInstance;
    dllname = "somd.dll";
    majorversion = 2;
    minorversion = 2;
    functionprefix = "SOMDSvr_";

    //# method modifiers
    somDefaultInit: override;
    somDestruct: override;


    //# passthrus
    passthru C_h = "#include <naming.h>"
                   "#include <xnaming.h>";
    passthru C_xh = "#include <naming.xh>"
                   "#include <xnaming.xh>";
    passthru C_h_after  = ""
      "#include <somdtype.h>"
        "#ifndef SOM_IMPORTEXPORT_somd"
        "#if defined(_WIN32) && !defined(SOM_DLL_somd)"
        	"#define SOM_IMPORTEXPORT_somd SOMDLLIMPORT"
        "#else"
        	"#define SOM_IMPORTEXPORT_somd"
        "#endif"
        "#endif"
      "#ifdef SOM_STRICT_IDL"
      "SOMEXTERN SOM_IMPORTEXPORT_somd SOMDServer  SOMDLINK SOMD_ServerObject;"
      "#else"
      "SOMEXTERN SOM_IMPORTEXPORT_somd SOMDServer * SOMDLINK SOMD_ServerObject;"
      "#endif /* SOM_STRICT_IDL */"
      "";

    passthru C_xh_after = ""
      "class SOMDServer;"
      "#include <somdtype.xh>"
        "#ifndef SOM_IMPORTEXPORT_somd"
        "#if defined(_WIN32) && !defined(SOM_DLL_somd)"
        	"#define SOM_IMPORTEXPORT_somd SOMDLLIMPORT"
        "#else"
        	"#define SOM_IMPORTEXPORT_somd"
        "#endif"
        "#endif"
      "SOMEXTERN SOM_IMPORTEXPORT_somd SOMDServer * SOMDLINK SOMD_ServerObject;"
      "";

  };

#endif /* __SOMIDL__ */

};

#endif  /* somdserver_idl */
