home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1995 by Oracle Corporation. All Rights Reserved.
- *
- * yo.h - Oracle OMX Object Layer Interface
- */
-
- #ifndef YO_ORACLE
- #define YO_ORACLE
-
- #ifndef SYSX_ORACLE
- #include <sysx.h>
- #endif
- #ifndef YS_ORACLE
- #include <ys.h>
- #endif
- #ifndef YSX_ORACLE
- #include <ysx.h>
- #endif
- #ifndef YTEX_ORACLE
- #include <ytex.h>
- #endif
- #ifndef YODEFS_ORACLE
- #include <yodefs.h>
- #endif
- #ifndef YOTK_ORACLE
- #include <yotk.h>
- #endif
- #ifndef MN_ORACLE
- #include <mn.h>
- #endif
-
- EXTC_START
-
- /* types */
- typedef YCIDL_sequence_ub1 yoRefData;
-
- /* Exceptions */
- externref ysidDecl(YO_EX_BADREFSTR); /* object reference string is bad */
- externref ysidDecl(YO_EX_UNIMPLEMENTED); /* function not implemented */
- externref ysidDecl(YO_EX_INTERNAL); /* YO internal error */
- externref ysidDecl(YO_EX_UNEXPECTED); /* unexpected exception was thrown */
- externref ysidDecl(YO_EX_NOOPT); /* required option not available */
- externref ysidDecl(YO_EX_BADOBJ); /* bad object reference */
- externref ysidDecl(YO_EX_BADOPER); /* bad operation */
- externref ysidDecl(YO_EX_NORES); /* required resources not available */
- externref ysidDecl(YO_EX_NOIMPL); /* implemenation not available */
-
- /*
- * yoInit - initialize the object manager
- *
- * DESCRIPTION
- * yoInit() initializes the object manager. The service layer and
- * transport layer must already be initialized.
- */
- void yoInit(void);
-
- /*
- * yoTerm - terminate the object manager
- *
- * DESCRIPTION
- * yoTerm() terminates the object manager. All active implementations
- * and objects are automatically deactivated at this time. Objects with
- * loaders have their loaders invoked to deactivate the object. Objects
- * without loaders are simply disposed of.
- */
- void yoTerm(void);
-
- /*
- * yoGetInterface, yoGetImplementation - get interface & implementation
- *
- * DESCRIPTION
- * yoGetInterface() and yoGetImplementation() return the interface id
- * and implementation id for an object, respectively.
- */
- CONST ysid *yoGetInterface(CONST dvoid *ref);
- CONST char *yoGetImplementation(CONST dvoid *ref);
-
- /*
- * yoDuplicate, yoRelease - duplicate & release an object reference
- *
- * DESCRIPTION
- * Object references are opaque so there are operations defined to copy
- * or release an object reference. yoDuplicate() duplicates an object
- * reference and returns a new one, and yoRelease() releases an object
- * reference. These operations typically no effect on the object itself.
- */
- dvoid *yoDuplicate(CONST dvoid *ref);
- void yoRelease(dvoid *ref);
-
- /*
- * yoRefCnt - object reference's reference count.
- *
- * DESCRIPTION
- * yoRefCnt() returns the number of references to the specified object
- * reference in this process.
- */
- ub4 yoRefCnt(CONST dvoid *ref);
-
- /*
- * yoIsEq - test references for equality
- *
- * DESCRIPTION
- * yoIsEq() returns TRUE if ref1 and ref2 both denote the same object;
- * FALSE otherwise.
- */
- boolean yoIsEq(CONST dvoid *ref1, CONST dvoid *ref2);
-
- /*
- * yoHash - hash an object reference
- *
- * DESCRIPTION
- * It is often necessary for an application to store a table of object
- * references. Since the object reference is opaque, the yoHash()
- * routine may be used to compute a hash value between zero and maxval-1.
- * The dummy parameter is ignored and exists for prototype compatibility
- * with the yshsh hash table interface.
- */
- ub4 yoHash(CONST dvoid *ref, size_t dummy, ub4 maxval);
-
- /*
- * yoCmp - compare / order object references
- *
- * DESCRIPTION
- * yoCmp() compares two object references. 0 is returned if the two references
- * are equal. Otherwise, a positive or negative value is returned. If ref1
- * is greater than ref2, a positive value is returned. yoCmp() should only be
- * used to order references within a process. This function can be used as a
- * tree comparison function when storing object references in trees.
- */
- sword yoCmp(CONST dvoid *ref1, CONST dvoid *ref2);
-
- /*
- * yoRefToStr, yoStrToRef - reference-to-string, string-to-reference conversion
- *
- * DESCRIPTION
- * Object references are opaque so writing them to persistent storage
- * and recovering them from persistent storage requires that the reference
- * can be converted into some external form. yoRefToStr() converts an
- * object reference to a form that may be manipulated as a normal C string.
- * Memory allocated to hold the string may be freed using yoFree().
- * yoStrToRef() converts a string back to an object reference.
- */
- char *yoRefToStr(CONST dvoid *ref);
- dvoid *yoStrToRef(CONST char *str);
-
- /*
- * yoAlloc, yoRealloc, yoFree - manage argument memory
- *
- * DESCRIPTION
- * The invoked operation may need to allocate memory that is to be
- * returned to the client. The client may retain allocated storage
- * indefinitely and must indicate when it is no longer needed by
- * calling yoFree(). The server should use yoAlloc() and yoRealloc()
- * to allocate memory that is to be returned as arguments to the client.
- *
- * The simple rule to remember is that the client owns all memory and
- * it is always the client's responsibility to free it, never the server's.
- * If the server wants to retain the memory, it must allocate a second
- * block of memory using a normal allocation routine and copy the
- * information.
- */
- dvoid *yoAlloc(size_t len);
- dvoid *yoRealloc(dvoid *ptr, size_t len);
- void yoFree(dvoid *ptr);
-
- /*
- * yoIsA, yoNarrow - narrow type
- *
- * DESCRIPTION
- * yoIsA() returns TRUE if the given object reference denotes an object
- * that is an instance of a derived interface of the given interface.
- * Note that the object may be an instance of the given interface itself.
- * A network trip may be required to answer the question if the object
- * is not an exact match for the requested interface type and no
- * implementation of the object is available in the requesting process.
- * FALSE is returned if there is no "is a" relationship between the
- * object and the target interface or if no implementation of the object
- * can be found.
- *
- * If there is an "is a" relationship (see above) between the given object
- * and the target interface, yoNarrow() returns a the object reference.
- * On failure, the exception YS_EX_BADPARAM is raised.
- */
- boolean yoIsA(CONST dvoid *ref, CONST ysid *intf);
- dvoid *yoNarrow(CONST dvoid *ref, CONST ysid *intf);
-
- /*
- * yoBind - bind to an object
- *
- * DESCRIPTION
- * yoBind() creates an object reference that is "loosely" bound to an
- * object. The object reference will denote any object that implements
- * the specified interface. If impl is non-null, then the object must
- * also use the specified implementation. If id is non-null, the
- * specified id is copied into the object reference. If id is
- * non-null, the specified reference data is attached to the reference.
- *
- * In any case, a method invoked on the returned object reference will
- * be delivered to any object that meets the requirements of the binding.
- * (Each invocation may bind to a different object.) The ORB may activate
- * a server if necessary to complete the invocation. If no such object
- * can be located, an error will be returned during the method invocation,
- * not during this call.
- */
- dvoid *yoBind(CONST ysid *intf, CONST char *impl, CONST yoRefData *id,
- CONST char *ignored);
-
- /*
- * yoExists - test existence
- *
- * DESCRIPTION
- * yoExists() returns TRUE if the the object denoted by the object
- * reference still exists. Since it may take time to determine this,
- * it is possible to start this operation asynchronously. If evt is
- * non-null the operation will be started asynchronously. The arg value
- * passed to the completed event is a pointer to the boolean result.
- */
- boolean yoExists(CONST dvoid *ref, ysevt *evt);
-
- /*
- * yoWatchOwner - watch the process which owns the specified object
- *
- * DESCRIPTION
- * The specified event is triggered when the owner of the object is no longer
- * alive. To cancel a watch before the event is triggered, destroy the event
- * passed to yoWatchOwner() using ysEvtDestroy(). Passinga loosely bound
- * object reference will result in a YS_EX_BADPARAM exception.
- */
- void yoWatchOwner(dvoid *ref, ysevt *evt);
-
- /*
- * yoGetAddr - get MN address of the process implementing the object
- *
- * DESCRIPTION
- * yoGetAddr() extracts the MNA of the process which implements the object
- * reference specified. If the object reference specified is loosely bound,
- * the addr is cleared.
- */
- void yoGetAddr(CONST dvoid *ref, mna *addr);
-
- /* yoClaim, yoAbandon - stake or abandon a property claim
- *
- * DESCRIPTION
- * yoClaim() attempts to associate the specified object reference with the
- * specified property name.
- * yoAbandon() abandons a claim. The call will only have an affect if you are
- * the owner of the property.
- */
- boolean yoClaim(CONST char *property, dvoid *obj);
- void yoAbandon(CONST char *property);
-
- /* yoListInitRefs, yoGetInitRef - list and get an inital references
- *
- * DESCRIPTION
- * yoListInitRefs() returns a list of the inital reference names currently
- * available. Inital references are intended for obtaining object references
- * to essential bootstrap services. This mechanism is not intended to replace
- * the NameService. In fact, the inital reference mechanism is used to locate
- * the NameService.
- * yoGetInitRef() returns the object reference associated with the given
- * inital reference name. If the reference is not available a null object
- * reference is returned.
- */
- void yoListInitRefs(YCIDL_sequence_string *nmlst);
- dvoid *yoGetInitRef(CONST char *name);
-
- /*
- * yoEnvInit, yoEnvCopy, yoEnvFree - YO environment
- *
- * DESCRIPTION
- * yoEnvInit() initializes the YO environment. yoEnvFree() frees the specified
- * YO environment. yoEnvCopy() copies the environment specified by src to into
- * the environment specified by dst.
- */
- void yoEnvInit(yoenv *ev);
- void yoEnvFree(yoenv *ev);
- void yoEnvCopy(yoenv *dst, CONST yoenv *src);
-
- /*
- * yoEnvGet, yoEnvSet - get or set an environment variable
- *
- * DESCRIPTION
- * yoEnvGet() copies the value for the requested environment variable into
- * value. If the variable is not found, false is returned.
- * yoEnvSet() copies value into the specified environment variable overwriting
- * any previously existing value. Passing a null pointer for value will remove
- * named value from the environment.
- */
- boolean yoEnvGet(CONST yoenv *ev, CONST char *name, yoany *value);
- void yoEnvSet(yoenv *ev, CONST char *name, CONST yoany *value);
-
- #ifndef yoevt_DECLARED
- #define yoevt_DECLARED
- typedef struct YCyoevt *yoevt;
- CONST yotk* yoevt__getTC(void);
- #define YCTC_yoevt (yoevt__getTC())
- #endif /* yoevt_DECLARED */
- /*
- * yoToRmtEvt - convert a local event to a remote one
- *
- * DESCRIPTION
- * yoToRmtEvt() converts a local event into a a remote event object reference.
- * This object reference is passed to server interfaces (IDL specified) which
- * require remote events. evt specifies the ysevt to be triggered when the
- * remote event is triggered. The arg value of the ysevt associated with a
- * triggered remote event will always point to a yoany.
- *
- * Example of remote event usage:
- *
- * ysevt *evt;
- * yoevt revt;
- * yoany *any;
- *
- * evt = ysEvtCreate(handler,usrp,q,FALSE);
- * revt = yoToRmtEvt(evt); // create remote event
- *
- * foo_op(ref, ev, revt); // invoke remote operation with a remote event
- *
- * void handler(dvoid *usrp, CONST ysid *exid, dvoid *arg, size_t argsz)
- * {
- * yoany *any = arg;
- *
- * // look at the exid and then any to see how things completed
- * ...
- * yotkFreeVal(yoTcAny,&any,yoFree); // free the any
- * }
- */
- yoevt yoToRmtEvt(ysevt *evt);
-
- /*
- * yoToLocalEvt - convert a remote event to a local one
- *
- * DESCRIPTION
- * Converts the yoevt passed to a server implementation function to a ysevt.
- * When the local event is triggered, the remote event is triggered. The
- * arg argument passed to ysTrigger() must point to a yoany.
- *
- * Example IDL which specifies an operation requiring a remote event:
- *
- * interface foo
- * {
- * op(yoevt revt);
- * }
- *
- *
- * Server implementation function which triggers a remote event with
- * a boolean argument:
- *
- * void foo_op_i(foo ref, yoenv *ev, yoevt revt)
- * {
- * ysevt *evt;
- * char *exid = (char *) 0;
- * boolean value = TRUE;
- * yoany any;
- *
- * evt = yoToLocalEvt(revt); // convert remote event to ysevt
- * ...
- * // populate the any
- * any._type = yoTcBoolean;
- * any._value = &value;
- * // ysTrigger() may be in server impl or happen sometime later
- * ysTrigger(evt, exid, (dvoid *)&any, sizeof(yoany));
- * }
- */
- ysevt *yoToLocalEvt(yoevt revt);
-
- /*
- * yoSetFilter - set a named filter
- *
- * DESCRIPTION
- * yoSetFilter() adds a filter function to the filter list. The type of filter
- * determines when the filter will be invoked. When invoked, the filter
- * function is passed the request or replys environment. The filter may
- * manipulate the environment or take actions based on settings in the
- * environment.
- */
- typedef void (*yofilter)(yoenv *ev, dvoid *usrp);
- /* filter types */
- #define YOFLTR_CSND 0 /* called before client request is marshalled */
- #define YOFLTR_CRCV 1 /* called after reply to client is unmarshalled */
- #define YOFLTR_SPREOP 2 /* called after server request is unmarshalled */
- #define YOFLTR_SPOSTOP 3 /* called before server reply is marshalled */
- void yoSetFilter(CONST char *name, sword type, yofilter filter, dvoid *usrp);
-
- /*
- * yoFilterRunEx - run filters with exception info
- * yoFilterRun - run filters
- *
- * DESCRIPTION
- * yoFilterRun/yoFilterRunEx run filters previously set up through
- * yoSetFilter. They should only be called to run client-side filters
- * around DII requests and requests through asynchronous stubs;
- * normal synchronous object requests have their filters run by the stubs.
- *
- * DII and async stub users who wish filters to be run should call
- * yoFilterRunEx(..., YOFLTR_CSND before invoking yoSendReq (or their async
- * stub), and yoFilterRunEx(..., YOFLTR_CRCV) after synch'ing with the
- * call completion event. If an exception has occurred, either during
- * dispatch or after synch'ing with completion, yoFilterRunEx should
- * be used to make that exception info available to the filters. If
- * no exception has occurred, pass in NULL for both exid & exobj.
- *
- * yoFilterRun has been deprecated and exists only for backward
- * compatibility.
- */
- void yoFilterRunEx(dvoid *ref, yoenv *ev, sword type,
- CONST ysid *exid, dvoid *exobj);
- #define yoFilterRun(ref,ev,type) \
- yoFilterRunEx(ref,ev,type,(CONST ysid*)0,(dvoid*)0);
-
- /*
- * yoreqsts - Request completion status
- *
- * Equivalent to CORBA::completion_status. Returned in the body of
- * CORBA style system exceptions.
- */
- /* DISABLE check_naming */
- typedef ub4 yoreqsts;
- #define YOREQ_COMPL_YES ((yoreqsts)0)
- #define YOREQ_COMPL_NO ((yoreqsts)1)
- #define YOREQ_COMPL_MAYBE ((yoreqsts)2)
-
- struct yosysex_t
- {
- ub4 minor;
- yoreqsts completed;
- };
- typedef struct yosysex_t yosysex;
- /* ENABLE check_naming */
-
- /*
- * yoCurGet, yoCurGetRef, yoCurGetPropCtx, yoSetPropCtx -- CORBA Current
- * operations.
- *
- * DESCRIPTION
- *
- * These routines support the CORBA Current pseudo-object. There is one
- * yocur assiciated with each thread. It may be obtained by calling
- * yoCurGet(). In a client, the yocur exists from the time of the first
- * yoCurGet() until yoCurDestroy() is called. In servers, the yocur is
- * instantiated when a request is received and is destroyed when the
- * processing of the request is completed. Therefore, in a server, the
- * contents of the yocur are local to the request, while in a client it
- * may persist across multiple operations.
- *
- * When a request is in progress on the thread, the affected object
- * reference can get retrieved with yoCurGetRef(), whose return must
- * be yoRelease()-ed. Then the interface and implemenation may be seen
- * with yoGetInterface() and yoGetImplementation().
- *
- * On both the client and server, yoCurGetExid may be used to retrieve
- * exception information from within filter. yoCurGetExid is
- * only valid from within filters; information about the last exception
- * does not persist after the completion of a request. Caller must
- * not modify or free the exid or exobj returned by yoCurGetExid.
- *
- * A CosTransactions::PropagationContext may be set in a client thread
- * with yoCurSetPropCtx(). This copies the argument propCtx, which may be
- * freed after the call returns. If the propCtx given to yoCurSetPropCtx
- * is null, then any existing one will be freed. The propCtx may be
- * retrieved in clients or servers by calling yoCurGetPropCtx(), which
- * returns a pointer to the saved copy. Servers may modify it
- * directly. It is allocated from the ysm global heap. If the propCtx is
- * set at the time of a request, it will be sent with the request and the
- * server's will be returned with the reply. On return the possibly
- * updated value will be put back in the client's copy.
- *
- * yoCurDestroy destroys the yocur for the client thread. It should
- * be called to before exit in each client thread that instantiated one
- * with a call to yoCurGet(). Server threads must not call this, as their
- * yocur's are instantiated by the runtime, which cleans up after itself.
- */
-
- yocur *yoCurGet(void);
- void yoCurDestroy(void);
- dvoid *yoCurGetRef(yocur *cur);
- void yoCurSetPropCtx(yocur *cur, CosTransactions_PropagationContext *pctx );
- CosTransactions_PropagationContext *yoCurGetPropCtx(yocur *cur);
- CONST ysid *yoCurGetExid(yocur *cur, dvoid **exobj);
-
- EXTC_END
- #endif /* YO_ORACLE */
-