Abstract:
A component based user self-definition event mechanism, including event manage part and event dispatch part; the connectable object is set in event dispatch part and the object event is dispatched; the event manage part realizes the storing of event processing function pointer, connecting with source object terminal and function invoking back, the event manage part and event dispatch part is related through the interface, it includes at least the user-defined interface register, realize the event processing function, and notify the function pointer to the event dispatch part object by registering, the object excites the event when the condition is met and invokes back the event processing function, the class intellectual pointer is utilized as the interface invoking pointer. Present invention generates component automatically, it has abilities of independent component upstage, easy and fast component co-operation, the realization of COM client program is greatly simplified.

Description:
FIELD OF THE INVENTION  
         [0001]    The present invention relates to a event manage mechanism and device in computer operation environment, especially relates to a user self-definition based user self-definition event mechanism of realizing the co-communication between client and component and on basis of component. The present invention belongs to the computer technology field.  
         BACKGROUND OF THE INVENTION  
         [0002]    In C++ programming model, for object oriented programming, the object couldn&#39;t be disassembled after linked, the stack couldn&#39;t packages the object, therefore has no flexibility. In component technology structure, the application program access the component through interface pointer.  
           [0003]    In present technology, the communication course between client and component is in unidirectional way, the component may be replaced dynamically. The client creates component object, then the client invokes the interface function provided by object, in this interactive course, client is always active, but component object is in passive state. For a overall interactive course, this unidirectional communication couldn&#39;t meet the practical requirements.  
           [0004]    The connectable object technology provided by Mirosoft Co could realize the invoking from component to client. However in this technology, the user is required to realize the connection between client program and component object, and also the event exciting and receiver compiling etc. And the register is only based on interface unit, i.e. it couldn&#39;t register respectively for each element function in interface. Moreover the Windows application programs must have a message circulation to process the message transferred from the Windows in message queue. In this way, each application program has a thread for waiting message and the more programs running at same time would occupy more resource.  
           [0005]    The COM technology resolves mainly the following problems: the components from various sources realize a co-operation, component upstage doesn&#39;t affect other component, independent from the programming language, transparent operation of component within process, over-process or even over-network.  
         BRIEF DESCRIPTION OF THE INVENTION  
         [0006]    The main purpose of present invention is providing a component based user self-definition event mechanism, it could realize a co-operation between component terminal and client terminal, component development, operation environment and component library over-platform.  
           [0007]    Another purpose of present invention is providing a component based user self-definition event mechanism, it could generate automatically in operation system the middleware (proxy component), provide the component location, invoking, managing, middleware starting &amp; generating, component communicating function of within process, over-process and over-network.  
           [0008]    Another purpose of present invention is providing a component based user self-definition event mechanism, it could guarantee the software co-operation and version independent upstage, it has the abilities of operation environment transparency, software co-development, software error tolerant, reliability, software re-using and version upstage.  
           [0009]    Another purpose of present invention is providing a component based user self-definition event mechanism, it has abilities of independent component upstage, easy and fast component co-operation, interface re-used, local/remote transparency, independent programming language.  
           [0010]    Another purpose of present invention is providing a component based user self-definition event mechanism, it realizes automatically the standard interface class package layer, the complicated detail of COM component object invoking is covered, the realization of COM client program is greatly simplified.  
           [0011]    The purposes of present invention are realized through the following technologies: a component based user self-definition event mechanism, including event manage part and event dispatch part, two parts are co-related through interface; the event dispatch part structures the connectable object event by different parameters, the connectable object event has interface, the user self-definition event function is registered through interface, a receiver is created in event manage part, the event function pointer is packeted in the receiver of event manage part, the receiver has interface, and could be connected with the connectable object terminal by registering, the connectable object interface pointer is written in the relative receiver, and the interface pointer provided by receiver containing event processing function pointer is set in the corresponding connectable object, when the condition is met, the event dispatch part excites event, the event manage part invokes back the function through receiver interface, opens the packet and executes program.  
           [0012]    In concrete, event dispatch part sets the event identification in connectable object event, the receiver of event manage part searches the event identification through interface, and obtains the connection interface pointer of the event connecting point object. The first parameter in event processing function parameter includes the class intellectual pointer of the event interface, and is for identifying event dispatch party; the second and hereafter parameters have same event parameter definition as the component definition. The interfaces include general interface and event interface, the general interface is a entry interface for providing service to client terminal, the event interface is a exit interface for invoking back the event processing function registered by client terminal when event occurs, the object communicates with client through event interface, each interface has a unique identifier, when the new function is added in component, the new interface description is defined first.  
           [0013]    In event exciting, the system would invoke each event processing function according to the register order of event processing function.  
           [0014]    Moreover, for the registered event, it may be canceled if doesn&#39;t needed, and the connection of event processing function corresponding to the connectable object event is canceled, in concrete, the receiver interface pointer in connectable object is canceled, and the receiver object is deleted (there aren&#39;t the event processing function pointer and connectable object pointer kept in it any more).  
           [0015]    In order to realize one versus more or more versus one, more than one connectable object events are set in event dispatch part, each event corresponds to a connectable object; more than one receivers may be created in event manage part.  
           [0016]    In order to register a same event process function into the different object event, the event manage part receiver may relates with more than one connectable objects; the event dispatch part connectable object may relates with more than one event manage part receivers, it may registers the more event processing functions corresponding to the same event, i.e. one event may corresponds to more event processing functions for executing respectively the different register request of same event.  
           [0017]    In order to better manage the connectable object state, the re-load process is set in connectable object for “on or off” of state in which the connectable object is able to be invoked, it manages if the connectable object could be invoked.  
           [0018]    Further, the re-load process is invoked when event manage part registers a connectable object in first time, i.e. set the invoke state of connectable object to “on”; the re-load process is invoked when event manage part cancels finally the connectable object, and set the invoke state of connectable object to “off”; execute idle operation when no re-load processing.  
           [0019]    In concrete, the connectable object sets connection counter for counting up the connection quantity created by the connectable object, for each register, the counter adds “1”; for each canceling, the counter decreases “1”. The re-load process is invoked when the counter reading is zero, and the invoking state of connectable object is set to “off”.  
           [0020]    Interface pointer container is set in event dispatch part for storing the description information of connectable object event and interface pointer, in the receiver registering within event manage part, the required connectable object event is searched through interface pointer container. The concrete search mode is an enumerative mode, in which, the event identification is searched one by one, the re-connection pointer transfers in the event identification corresponding to concrete event, and the connection interface pointer of the event connection point object is obtained.  
           [0021]    The event manage part has manage interface connected with the application program for receiving the invoking application program of application program, the pointer of event processing function is transferred to event manage part through the interface, the event manage part then registers the event processing function, this is because that the codes of register and revoke back in event manage part are generated automatically, and the interface is needed to co-interactive with application program.  
           [0022]    In present invention, the client terminal may be the event manage part or event dispatch part; the corresponding component terminal is event dispatch part or event manage part.  
           [0023]    Present invention may be utilized in operation system; It is utilized in graphic system. Only when event occurs, the system invokes back the event processing function of user program and doesn&#39;t need message circulation. The user process may has no thread; the-operation system starts the thread when a event occurs and executes the event processing function.  
           [0024]    Present invention is utilized also in driving program. The user program or operation system registers the event processing function into the device driving program component compiled with event mechanism, the driving program invokes back directly the user program or event processing function of operation system in hardware disconnecting.  
           [0025]    As mentioned above, present invention realizes a component develop and operate environment of over-platform, safety, reliable, good error tolerant, compact, high efficient, the operation system supports component improving property, simple and flexible.  
           [0026]    The present invention is applied in graphic system, the operation system invokes back the event processing function of user program only if a event occurs, and the message circulation isn&#39;t be required. The user process may has no thread, the operation system re-start the thread to execute event processing function when a event occurs, and the efficiency of operation system is greatly increased.  
           [0027]    The present invention is applied also in driving system. The user program or operation system registers the event processing function into the device driving program component compiled with event mechanism, the driving program invokes back directly the user program or event processing function of operation system in hardware disconnecting. Thus the resource needed to inquire periodically the device state with thread may be saved, and the program compiling is more easily. 
       
    
    
     BRIEF DESCRIPTION OF THE APPENDED DRAWINGS  
       [0028]    [0028]FIG. 1 is an illustrative view showing a system in present invention.  
         [0029]    [0029]FIG. 2 is an illustrative view showing the system structure corresponding to more component terminals from a client terminal.  
         [0030]    [0030]FIG. 3 is an illustrative view showing the system structure corresponding to one component terminal from more client terminals.  
         [0031]    [0031]FIG. 4 is a flowchart showing the register method in present invention.  
         [0032]    [0032]FIG. 5 is a flowchart showing the exciting method in present invention.  
         [0033]    [0033]FIG. 6 is a flowchart showing the cancel method in present invention.  
         [0034]    [0034]FIG. 7 is an illustrative view showing a better embodiment in present invention—word quiz set.  
         [0035]    [0035]FIG. 8 is an illustrative view showing a better embodiment in present invention—word quiz exciting program.  
         [0036]    [0036]FIG. 9 is an illustrative view showing the course of registering, exciting and canceling. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0037]    Next, a further description will be made as to the present invention with the Figures and concrete embodiment.  
         [0038]    In self-defining event mechanism in present invention, the courses of event dispatching, function pointer keeping, linking with source object terminal and invoking back function etc are completed. In component program compiling, user needs only to care about when to excite event, in compiling the client terminal program, user needs only to register the event processing function in suitable time. Other works, such as event dispatching and invoking back event processing function etc are all completed by present invention. Thus it is easy to compile the components with event interface and the program of client terminal utilizing the component.  
         [0039]    As FIG. 1 shows, present invention includes event manage part-client terminal and event dispatch part-component terminal. The event dispatch part dispatches the event, event manage part realizes the keeping of event processing function pointer, connecting with original object terminal, invoking back function, two parts communicate via interface, the communication itself includes at least the step of user self-defining interface register, excite event according to register information, and step-of canceling for canceling the event processing function.  
         [0040]    The client terminal may be a event manage part or event dispatch part; the corresponding component terminal is event dispatch part or event manage part.  
         [0041]    Each event corresponds to a connection point.  
         [0042]    As FIG. 1 shows, the connection point object records the interface pointer of receiver containing the registered event processing function pointer. ?: in event registering, keeps the IDispatch interface pointer to the connection point object;?: in event registering, keeps the dwCookie identifying this connection to the EventHandler;?: in event exciting, invoke its Invoke method with the kept IDispatch interface pointer;? cancel the event by the dwCookie kept by EventHandler.  
         [0043]    One event may corresponds more event processing functions for executing respectively the different register request of same event. The event processing function parameter stipulation is: the first parameter must include the class intellectual pointer of the event interface for indicating the event dispatch part; the second and hereafter parameters have same event parameter definition as the component definition.  
         [0044]    The event processing function includes also re-load function for “on or off” of state in which the connectable object may be invoked, it manages if the connectable object could be invoked. It is invoked only if a event is registered in client terminal for fist time; and it is invoked only if a event is canceled in client terminal for last time, execute idle operation when no re-load processing.  
         [0045]    The event manage part sets more than one receivers of independent respectively for interface connection. The event manage part has event manage interface for creating or releasing the event processing object. In the event processing object releasing, the event processing function pointer is stored, and the dispatch interface of event manage part receiver is provided; the event dispatch part includes more than one connectable objects; the receiver connects with connectable object by setting and interface. Event dispatch part transfers in the event identification corresponding to concrete event through searching the connection pointer, and obtains the connection interface pointer of the event connection point.  
         [0046]    The event dispatch part event connection point object is connected through dispatch interface connecting the interface pointer and event manage part receiver and communicates. The event dispatch part has also connecting pointer container for searching the relative connecting point by event identification.  
         [0047]    Refer to FIG. 2, the event manage part receiver in present invention may relates with more than one connectable objects as a client terminal; or as FIG. 3 shows, event dispatch part connectable object may relates with more than one event manage part receivers. Thus a same event processing function may be registered to different object event; a same event may has more event processing functions to be registered into them.  
         [0048]    Concretely, the interfaces include general interface and event interface, the general interface is a entry interface for providing service to client terminal, the event interface is a exit interface for invoking back the event processing function registered by client terminal in event occurs, the object communicates with client through event interface. A component terminal may has an or more general &amp; event interfaces. Each interface has a unique identifier, when the new function is added in component, the new interface description is defined first.  
         [0049]    The intellectual pointer is utilized in component object creating, general interface invoking &amp; registering, event canceling.  
         [0050]    When a client program needs a event processing function to response to the event, the event processing function is needed to be registered; When a client program doesn&#39;t need a event processing function to response to the event, the event processing function may be canceled. In event exciting, the system would invokes each event processing function in accordance with the event processing function register order.  
         [0051]    The event dispatch part is a connectable object. Each event corresponds with a connect point object. The event dispatching provides the connection pointer container interface. Through the FindconnectionPoint function of the interface and transferring in the event identification corresponding to the concrete event, the connect point interface pointer of the event connect point object may be obtained.  
         [0052]    The event manage part provides the event manage part interface, the event processor object may be created or released through this interface. The event processor object keeps the event processing function pointer and provides the manager part interface.  
         [0053]    If a object in present invention supports a or more event interfaces, the object is called connectable object, sometimes called source object. Each element function in event interface represents an event. When a special event occurs, e.g. a timing message or a user mouse operation, the component object generates a event, and the client program may process the event. The element function of event interface in component object is not realized by object, but by client program. The client program realizes the event processing functions, and notify the component object about the function pointer through registering, and the object excites the event and invokes back the event processing function suitable condition.  
         [0054]    The obtaining of legal intellectual pointer is like: created by component class operation, or initialized by legal intellectual pointer, or assigned by legal intellectual pointer.  
         [0055]    Concretely, as FIG. 4 shows, the client register event processing function in present invention would complete the following operations:  
         [0056]    Step  1 : obtain the event manage part interface pointer;  
         [0057]    Step  2 : create the receiver object (EventHandler) through event manage part interface, and store the pointer of event processing function to the object;  
         [0058]    Step  3 : find out the connect point object corresponding to the event by the search connection pointer in connect point container interface provided by source object;  
         [0059]    Step  4 : register the event manage part interface provided by event receiver to the source object terminal through the Advise function in connect point pointer interface provided by connect object;  
         [0060]    Step  5 : obtain the dwCookie identifying the connection in registering and store it in receiver object.  
         [0061]    As FIG. 5 shows, the component exciting event would completes the following operations:  
         [0062]    Step  1 : enumerate each connection in connect object corresponding to the event;  
         [0063]    Step  2 : packet the event parameter, and invoke the Invoke function in the IDspatch to each connection and excite the event;  
         [0064]    Step  3 : the receiver object un-packet the transferred Invoke parameter, and invoke the event processing function through the stored function pointer.  
         [0065]    As FIG. 6 shows, the client canceling event processing function would completes the following operations:  
         [0066]    Step  1 ; find out the corresponding receiver object through event processing function pointer and event EID(Event ID event identification);  
         [0067]    Step  2 : obtain the dwCookie identifying the connection stored in receiver object;  
         [0068]    Step  3 : find out the connect point object corresponding to the event by the FindConnectionPoint function in IConnectionPointContainer provided by source object;  
         [0069]    Step  4 : transfer in the dwCookie as a parameter by the Unadvise function in IconnectionPoint interface provided by connect point object, and cancel the IDispatch interface provided by event processor;  
         [0070]    Step  5 : release the receiver object.  
       CONCRETE EMBODIMENT 1  
       [0071]    Refer to FIG. 7, 8, take the course of creating and managing a number quiz program as a example.  
         [0072]    Create the component object, and obtain the legal class intellectual pointer. Register with this pointer. The event designs to print the win information, set the exit mark; print the failure information, set the exit mark; obtain the correct number, print the prompt information. So it needs the program to be registered in component terminal.  
         [0073]    Generate a soured file, a or more head files and CPP file, and make corresponding to a head files and a CPP file.  
         [0074]    Obtain four numbers; guess the number, judge the result, excite event, guess the number state per time, and record the guess times.  
         [0075]    In component programming, it needs only to invoke the method to excite event.  
         [0076]    In number guess quiz, after guess result judgment, excite TIP event, and dispatch the number guess information to the client terminal.  
         [0077]    In correct guessing, excite BINGO event, and in wrong guessing, excite YOULOSE event.  
         [0078]    The general flow in present invention is as FIG. 9:  
         [0079]    Step  1 : the client terminal creates the component object, and obtains the legal class intellectual pointer, and register the event processing function to component terminal by the class intellectual pointer;  
         [0080]    Step  2 : The component terminal excite the event in suitable condition, such as timing message or user mouse operation occurs, and invoke back the event processing function registered in step  1 , the event may be invoked more times;  
         [0081]    Step  3 : When client terminal doesn&#39;t wish to response the event, the event processing function registered in step  1  is canceled through the class intellectual pointer.